From feacec468d6b0127716fa23183977faa2fa4abad Mon Sep 17 00:00:00 2001 From: Stacey Sheldon Date: Sat, 12 Nov 2011 21:39:41 -0500 Subject: [PATCH] i2c: compile-time decoupling of i2c devices from adapters This allows each device to be moved (at compile time) to a different adapter. This is the first step to allowing devices to be attached to different i2c adapters. --- flight/PiOS/Boards/STM32103CB_CC_Rev1.h | 1 + flight/PiOS/Boards/STM3210E_OP.h | 1 + flight/PiOS/Common/pios_i2c_esc.c | 8 ++++---- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/flight/PiOS/Boards/STM32103CB_CC_Rev1.h b/flight/PiOS/Boards/STM32103CB_CC_Rev1.h index 437a49109..ff37debdc 100644 --- a/flight/PiOS/Boards/STM32103CB_CC_Rev1.h +++ b/flight/PiOS/Boards/STM32103CB_CC_Rev1.h @@ -112,6 +112,7 @@ TIM4 | RC In 1 | Servo 3 | Servo 2 | Servo 1 #define PIOS_I2C_MAX_DEVS 1 extern uint32_t pios_i2c_main_adapter_id; #define PIOS_I2C_MAIN_ADAPTER (pios_i2c_main_adapter_id) +#define PIOS_I2C_ESC_ADAPTER (pios_i2c_main_adapter_id) //------------------------- // SPI diff --git a/flight/PiOS/Boards/STM3210E_OP.h b/flight/PiOS/Boards/STM3210E_OP.h index a7754c2ed..1cc4249f3 100644 --- a/flight/PiOS/Boards/STM3210E_OP.h +++ b/flight/PiOS/Boards/STM3210E_OP.h @@ -115,6 +115,7 @@ TIM8 | Servo 5 | Servo 6 | Servo 7 | Servo 8 #define PIOS_I2C_MAX_DEVS 1 extern uint32_t pios_i2c_main_adapter_id; #define PIOS_I2C_MAIN_ADAPTER (pios_i2c_main_adapter_id) +#define PIOS_I2C_ESC_ADAPTER (pios_i2c_main_adapter_id) //------------------------ // PIOS_BMP085 diff --git a/flight/PiOS/Common/pios_i2c_esc.c b/flight/PiOS/Common/pios_i2c_esc.c index fdb58eba0..d440bfa48 100644 --- a/flight/PiOS/Common/pios_i2c_esc.c +++ b/flight/PiOS/Common/pios_i2c_esc.c @@ -93,7 +93,7 @@ bool PIOS_I2C_ESC_SetSpeed(uint8_t speed[4]) } }; - return PIOS_I2C_Transfer(PIOS_I2C_MAIN_ADAPTER, txn_list, NELEMENTS(txn_list)); + return PIOS_I2C_Transfer(PIOS_I2C_ESC_ADAPTER, txn_list, NELEMENTS(txn_list)); } bool PIOS_SetMKSpeed(uint8_t motornum, uint8_t speed) { @@ -115,7 +115,7 @@ bool PIOS_SetMKSpeed(uint8_t motornum, uint8_t speed) { } }; - return PIOS_I2C_Transfer(PIOS_I2C_MAIN_ADAPTER, txn_list, NELEMENTS(txn_list)); + return PIOS_I2C_Transfer(PIOS_I2C_ESC_ADAPTER, txn_list, NELEMENTS(txn_list)); } bool PIOS_SetAstec4Address(uint8_t new_address) { @@ -134,7 +134,7 @@ bool PIOS_SetAstec4Address(uint8_t new_address) { } }; - return PIOS_I2C_Transfer(PIOS_I2C_MAIN_ADAPTER, txn_list, NELEMENTS(txn_list)); + return PIOS_I2C_Transfer(PIOS_I2C_ESC_ADAPTER, txn_list, NELEMENTS(txn_list)); } bool PIOS_SetAstec4Speed(uint8_t motornum, uint8_t speed) { @@ -161,7 +161,7 @@ bool PIOS_SetAstec4Speed(uint8_t motornum, uint8_t speed) { } }; - return PIOS_I2C_Transfer(PIOS_I2C_MAIN_ADAPTER, txn_list, NELEMENTS(txn_list)); + return PIOS_I2C_Transfer(PIOS_I2C_ESC_ADAPTER, txn_list, NELEMENTS(txn_list)); } #endif