[mkk_v2] Rename subsystem and its internal structures from mkk2 -> mkk_v2

This commit is contained in:
Christophe De Wagter
2013-03-01 08:36:03 +01:00
parent 45e07b1a94
commit 5b6984c8e9
4 changed files with 53 additions and 53 deletions
@@ -5,40 +5,40 @@
# <firmware name="rotorcraft">
# ...
# <subsystem name="actuators" type="mkk">
# <configure name="MKK_I2C_SCL_TIME" value="50"/> <!-- this is optional, 150 is default, use 50 for 8 motors-->
# <configure name="MKK_V2_I2C_SCL_TIME" value="50"/> <!-- this is optional, 150 is default, use 50 for 8 motors-->
# </subsystem>
# <define name="I2C_TRANSACTION_QUEUE_LEN" value="10"/> <!-- default is 8, increase to 10 or more for 8 motors-->
# </firmware>
#
#
# required xml configuration:
# <section name="ACTUATORS_MKK2" prefix="ACTUATORS_MKK2_">
# <section name="ACTUATORS_MKK_V2" prefix="ACTUATORS_MKK_V2_">
# <define name="NB" value="4"/>
# <define name="ADDR" value="{ 0x52, 0x54, 0x56, 0x58 }"/>
# </section>
#
# servo section with driver="Mkk"
# servo section with driver="Mkk_v2"
# command_laws section to map motor_mixing commands to servos
# max command = 2047
$(TARGET).CFLAGS += -DACTUATORS
ap.srcs += subsystems/actuators/actuators_mkk2.c
ap.srcs += subsystems/actuators/actuators_mkk_v2.c
ifeq ($(ARCH), lpc21)
# set default i2c timing if not already configured
ifeq ($(MKK2_I2C_SCL_TIME), )
MKK_I2C2_SCL_TIME=150
ifeq ($(MKK_V2_I2C_SCL_TIME), )
MKK_V2_I2C2_SCL_TIME=150
endif
ap.CFLAGS += -DACTUATORS_MKK2_DEVICE=i2c0
ap.CFLAGS += -DUSE_I2C0 -DI2C0_SCLL=$(MKK2_I2C_SCL_TIME) -DI2C0_SCLH=$(MKK2_I2C_SCL_TIME)
ap.CFLAGS += -DACTUATORS_MKK_V2_DEVICE=i2c0
ap.CFLAGS += -DUSE_I2C0 -DI2C0_SCLL=$(MKK_V2_I2C_SCL_TIME) -DI2C0_SCLH=$(MKK_V2_I2C_SCL_TIME)
else ifeq ($(ARCH), stm32)
ap.CFLAGS += -DACTUATORS_MKK2_DEVICE=i2c1
ap.CFLAGS += -DACTUATORS_MKK_V2_DEVICE=i2c1
ap.CFLAGS += -DUSE_I2C1
endif
# Simulator
nps.srcs += subsystems/actuators/actuators_mkk.c
nps.CFLAGS += -DUSE_I2C0 -DACTUATORS_MKK_DEVICE=i2c0
# Simulator:
nps.srcs += subsystems/actuators/actuators_mkk_v2.c
nps.CFLAGS += -DUSE_I2C0 -DACTUATORS_MKK_V2_DEVICE=i2c0
+6 -6
View File
@@ -35,7 +35,7 @@ uint8_t config_mkk_crc(uint8_t offset);
struct config_mkk_struct config_mkk;
#define MAX_MOTORS ACTUATORS_MKK2_NB
#define MAX_MOTORS ACTUATORS_MKK_V2_NB
typedef struct
@@ -111,13 +111,13 @@ void init_config_mkk(void)
}
}
#include "subsystems/actuators/actuators_mkk2.h"
#include "subsystems/actuators/actuators_mkk_v2.h"
void periodic_config_mkk_read_status(void)
{
static int read_nr = 0;
if (!actuators_mkk2.actuators_delay_done)
if (!actuators_mkk_v2.actuators_delay_done)
return;
switch (config_mkk.trans.status) {
@@ -149,7 +149,7 @@ void periodic_config_mkk_read_status(void)
config_mkk_read_eeprom();
i2c_submit(&ACTUATORS_MKK2_DEVICE, &config_mkk.trans);
i2c_submit(&ACTUATORS_MKK_V2_DEVICE, &config_mkk.trans);
}
// Read Status
else
@@ -157,7 +157,7 @@ void periodic_config_mkk_read_status(void)
read_nr++;
if (read_nr >= MAX_MOTORS)
read_nr = 0;
const uint8_t actuators_addr[ACTUATORS_MKK2_NB] = ACTUATORS_MKK2_ADDR;
const uint8_t actuators_addr[ACTUATORS_MKK_V2_NB] = ACTUATORS_MKK_V2_ADDR;
config_mkk.trans.type = I2CTransRx;
config_mkk.trans.len_r = 3;
config_mkk.trans.slave_addr = actuators_addr[read_nr];
@@ -246,7 +246,7 @@ void config_mkk_send_eeprom(void)
config_mkk.trans.buf[8] = config_mkk_eeprom.BitConfig;
config_mkk.trans.buf[9] = config_mkk_crc(2);
i2c_submit(&ACTUATORS_MKK2_DEVICE, &config_mkk.trans);
i2c_submit(&ACTUATORS_MKK_V2_DEVICE, &config_mkk.trans);
}
@@ -19,60 +19,60 @@
* Boston, MA 02111-1307, USA.
*/
/** @file actuators_mkk.c
/** @file actuators_mkk_v2.c
* Actuators driver for Mikrokopter motor controllers.
*/
#include "subsystems/actuators.h"
#include "subsystems/actuators/actuators_mkk2.h"
#include "subsystems/actuators/actuators_mkk_v2.h"
#include "mcu_periph/i2c.h"
#include "mcu_periph/sys_time.h"
struct ActuatorsMkk2 actuators_mkk2;
struct actuators_mkk_v2_struct actuators_mkk_v2;
static uint32_t actuators_delay_time;
void actuators_mkk2_init(void) {
void actuators_mkk_v2_init(void) {
const uint8_t actuators_addr[ACTUATORS_MKK2_NB] = ACTUATORS_MKK2_ADDR;
for (uint8_t i=0; i<ACTUATORS_MKK2_NB; i++) {
actuators_mkk2.trans[i].type = I2CTransTx;
actuators_mkk2.trans[i].len_w = 2;
actuators_mkk2.trans[i].slave_addr = actuators_addr[i];
actuators_mkk2.trans[i].status = I2CTransSuccess;
const uint8_t actuators_addr[ACTUATORS_MKK_V2_NB] = ACTUATORS_MKK_V2_ADDR;
for (uint8_t i=0; i<ACTUATORS_MKK_V2_NB; i++) {
actuators_mkk_v2.trans[i].type = I2CTransTx;
actuators_mkk_v2.trans[i].len_w = 2;
actuators_mkk_v2.trans[i].slave_addr = actuators_addr[i];
actuators_mkk_v2.trans[i].status = I2CTransSuccess;
}
#if defined ACTUATORS_START_DELAY && ! defined SITL
actuators_mkk2.actuators_delay_done = FALSE;
actuators_mkk_v2.actuators_delay_done = FALSE;
SysTimeTimerStart(actuators_delay_time);
#else
actuators_mkk2.actuators_delay_done = TRUE;
actuators_mkk_v2.actuators_delay_done = TRUE;
actuators_delay_time = 0;
#endif
}
void actuators_mkk2_set(void) {
void actuators_mkk_v2_set(void) {
#if defined ACTUATORS_START_DELAY && ! defined SITL
if (!actuators_mkk2.actuators_delay_done) {
if (!actuators_mkk_v2.actuators_delay_done) {
if (SysTimeTimer(actuators_delay_time) < USEC_OF_SEC(ACTUATORS_START_DELAY)) return;
else actuators_mkk2.actuators_delay_done = TRUE;
else actuators_mkk_v2.actuators_delay_done = TRUE;
}
#endif
for (uint8_t i=0; i<ACTUATORS_MKK2_NB; i++) {
for (uint8_t i=0; i<ACTUATORS_MKK_V2_NB; i++) {
#ifdef KILL_MOTORS
actuators_mkk2.trans[i].buf[0] = 0;
actuators_mkk2.trans[i].buf[1] = 0;
actuators_mkk_v2.trans[i].buf[0] = 0;
actuators_mkk_v2.trans[i].buf[1] = 0;
#else
actuators_mkk2.trans[i].buf[0] = (actuators_mkk2.setpoint[i] >> 3);
actuators_mkk2.trans[i].buf[1] = actuators_mkk2.setpoint[i] & 0x07;
actuators_mkk_v2.trans[i].buf[0] = (actuators_mkk_v2.setpoint[i] >> 3);
actuators_mkk_v2.trans[i].buf[1] = actuators_mkk_v2.setpoint[i] & 0x07;
#endif
i2c_submit(&ACTUATORS_MKK2_DEVICE, &actuators_mkk2.trans[i]);
i2c_submit(&ACTUATORS_MKK_V2_DEVICE, &actuators_mkk_v2.trans[i]);
}
}
@@ -19,12 +19,12 @@
* Boston, MA 02111-1307, USA.
*/
/** @file actuators_mkk.h
/** @file actuators_mkk_v2.h
* Actuators driver for Mikrokopter motor controllers.
*/
#ifndef ACTUATORS_MKK_H
#define ACTUATORS_MKK_H
#ifndef ACTUATORS_MKK_V2_H
#define ACTUATORS_MKK_V2_H
#include "std.h"
#include "mcu_periph/i2c.h"
@@ -32,19 +32,19 @@
#include "generated/airframe.h"
struct ActuatorsMkk2 {
bool_t actuators_delay_done; // mkk_config module wants to know state
uint16_t setpoint[ACTUATORS_MKK2_NB];
struct i2c_transaction trans[ACTUATORS_MKK2_NB];
struct actuators_mkk_v2_struct {
bool_t actuators_delay_done; // config_mkk module wants to know state
uint16_t setpoint[ACTUATORS_MKK_V2_NB];
struct i2c_transaction trans[ACTUATORS_MKK_V2_NB];
};
extern struct ActuatorsMkk2 actuators_mkk2;
extern struct actuators_mkk_v2_struct actuators_mkk_v2;
extern void actuators_mkk2_init(void);
extern void actuators_mkk2_set(void);
extern void actuators_mkk_v2_init(void);
extern void actuators_mkk_v2_set(void);
#define ActuatorMkk2Set(_i, _v) { actuators_mkk2.setpoint[_i] = _v; }
#define ActuatorsMkk2Init() actuators_mkk2_init()
#define ActuatorsMkk2Commit() actuators_mkk2_set()
#define ActuatorMkk_v2Set(_i, _v) { actuators_mkk_v2.setpoint[_i] = _v; }
#define ActuatorsMkk_v2Init() actuators_mkk_v2_init()
#define ActuatorsMkk_v2Commit() actuators_mkk_v2_set()
#endif /* ACTUATORS_MKK_H */
#endif /* ACTUATORS_MKK_V2_H */