diff --git a/conf/firmwares/subsystems/shared/actuators_mkk2.makefile b/conf/firmwares/subsystems/shared/actuators_mkk_v2.makefile similarity index 53% rename from conf/firmwares/subsystems/shared/actuators_mkk2.makefile rename to conf/firmwares/subsystems/shared/actuators_mkk_v2.makefile index 9c4a879063d..d41b51e1406 100644 --- a/conf/firmwares/subsystems/shared/actuators_mkk2.makefile +++ b/conf/firmwares/subsystems/shared/actuators_mkk_v2.makefile @@ -5,40 +5,40 @@ # # ... # -# +# # # # # # # required xml configuration: -#
+#
# # #
# -# 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 diff --git a/sw/airborne/modules/config/config_mkk.c b/sw/airborne/modules/config/config_mkk.c index 699a1582b98..dfae4872c41 100644 --- a/sw/airborne/modules/config/config_mkk.c +++ b/sw/airborne/modules/config/config_mkk.c @@ -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); } diff --git a/sw/airborne/subsystems/actuators/actuators_mkk2.c b/sw/airborne/subsystems/actuators/actuators_mkk_v2.c similarity index 55% rename from sw/airborne/subsystems/actuators/actuators_mkk2.c rename to sw/airborne/subsystems/actuators/actuators_mkk_v2.c index 4a4f900d388..0a3a0bbd791 100644 --- a/sw/airborne/subsystems/actuators/actuators_mkk2.c +++ b/sw/airborne/subsystems/actuators/actuators_mkk_v2.c @@ -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> 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]); } } diff --git a/sw/airborne/subsystems/actuators/actuators_mkk2.h b/sw/airborne/subsystems/actuators/actuators_mkk_v2.h similarity index 61% rename from sw/airborne/subsystems/actuators/actuators_mkk2.h rename to sw/airborne/subsystems/actuators/actuators_mkk_v2.h index f35c5f7e355..b9634c26961 100644 --- a/sw/airborne/subsystems/actuators/actuators_mkk2.h +++ b/sw/airborne/subsystems/actuators/actuators_mkk_v2.h @@ -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 */