mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
AP_HAL: add the possibility to have more than 1 i2c
Bebop drone has 3 i2c
This commit is contained in:
parent
b33ed8ce39
commit
7275e33e79
@ -19,7 +19,9 @@ public:
|
||||
AP_HAL::UARTDriver* _uartC, // telem1
|
||||
AP_HAL::UARTDriver* _uartD, // telem2
|
||||
AP_HAL::UARTDriver* _uartE, // 2nd GPS
|
||||
AP_HAL::I2CDriver* _i2c,
|
||||
AP_HAL::I2CDriver* _i2c0,
|
||||
AP_HAL::I2CDriver* _i2c1,
|
||||
AP_HAL::I2CDriver* _i2c2,
|
||||
AP_HAL::SPIDeviceManager* _spi,
|
||||
AP_HAL::AnalogIn* _analogin,
|
||||
AP_HAL::Storage* _storage,
|
||||
@ -35,7 +37,9 @@ public:
|
||||
uartC(_uartC),
|
||||
uartD(_uartD),
|
||||
uartE(_uartE),
|
||||
i2c(_i2c),
|
||||
i2c(_i2c0),
|
||||
i2c1(_i2c1),
|
||||
i2c2(_i2c2),
|
||||
spi(_spi),
|
||||
analogin(_analogin),
|
||||
storage(_storage),
|
||||
@ -55,6 +59,8 @@ public:
|
||||
AP_HAL::UARTDriver* uartD;
|
||||
AP_HAL::UARTDriver* uartE;
|
||||
AP_HAL::I2CDriver* i2c;
|
||||
AP_HAL::I2CDriver* i2c1;
|
||||
AP_HAL::I2CDriver* i2c2;
|
||||
AP_HAL::SPIDeviceManager* spi;
|
||||
AP_HAL::AnalogIn* analogin;
|
||||
AP_HAL::Storage* storage;
|
||||
|
@ -43,6 +43,8 @@ HAL_AVR_APM1::HAL_AVR_APM1() :
|
||||
NULL, /* no uartD */
|
||||
NULL, /* no uartE */
|
||||
&avrI2CDriver,
|
||||
NULL, /* only 1 i2c */
|
||||
NULL, /* only 1 i2c */
|
||||
&apm1SPIDriver,
|
||||
&avrAnalogIn,
|
||||
&avrEEPROMStorage,
|
||||
|
@ -42,6 +42,8 @@ HAL_AVR_APM2::HAL_AVR_APM2() :
|
||||
NULL, /* no uartD */
|
||||
NULL, /* no uartE */
|
||||
&avrI2CDriver,
|
||||
NULL, /* only one i2c */
|
||||
NULL, /* only one i2c */
|
||||
&apm2SPIDriver,
|
||||
&avrAnalogIn,
|
||||
&avrEEPROMStorage,
|
||||
|
@ -29,6 +29,8 @@ HAL_Empty::HAL_Empty() :
|
||||
NULL, /* no uartD */
|
||||
NULL, /* no uartE */
|
||||
&i2cDriver,
|
||||
NULL, /* only one i2c */
|
||||
NULL, /* only one i2c */
|
||||
&spiDeviceManager,
|
||||
&analogIn,
|
||||
&storageDriver,
|
||||
|
@ -50,6 +50,8 @@ HAL_FLYMAPLE::HAL_FLYMAPLE() :
|
||||
NULL, /* no uartD */
|
||||
NULL, /* no uartE */
|
||||
&i2cDriver,
|
||||
NULL, /* only 1 i2c */
|
||||
NULL, /* only 1 i2c */
|
||||
&spiDeviceManager,
|
||||
&analogIn,
|
||||
&storageDriver,
|
||||
|
@ -24,11 +24,19 @@ static LinuxUARTDriver uartBDriver(false);
|
||||
static LinuxUARTDriver uartCDriver(false);
|
||||
static LinuxUARTDriver uartEDriver(false);
|
||||
|
||||
static LinuxSemaphore i2cSemaphore;
|
||||
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BBBMINI
|
||||
static LinuxI2CDriver i2cDriver(&i2cSemaphore, "/dev/i2c-2");
|
||||
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP
|
||||
static LinuxSemaphore i2cSemaphore0;
|
||||
static LinuxI2CDriver i2cDriver0(&i2cSemaphore0, "/dev/i2c-0");
|
||||
static LinuxSemaphore i2cSemaphore1;
|
||||
static LinuxI2CDriver i2cDriver1(&i2cSemaphore1, "/dev/i2c-1");
|
||||
static LinuxSemaphore i2cSemaphore2;
|
||||
static LinuxI2CDriver i2cDriver2(&i2cSemaphore2, "/dev/i2c-2");
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BBBMINI
|
||||
static LinuxSemaphore i2cSemaphore0;
|
||||
static LinuxI2CDriver i2cDriver0(&i2cSemaphore0, "/dev/i2c-2");
|
||||
#else
|
||||
static LinuxI2CDriver i2cDriver(&i2cSemaphore, "/dev/i2c-1");
|
||||
static LinuxSemaphore i2cSemaphore0;
|
||||
static LinuxI2CDriver i2cDriver0(&i2cSemaphore0, "/dev/i2c-1");
|
||||
#endif
|
||||
static LinuxSPIDeviceManager spiDeviceManager;
|
||||
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_NAVIO
|
||||
@ -103,7 +111,15 @@ HAL_Linux::HAL_Linux() :
|
||||
&uartCDriver,
|
||||
NULL, /* no uartD */
|
||||
&uartEDriver,
|
||||
&i2cDriver,
|
||||
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP
|
||||
&i2cDriver0,
|
||||
&i2cDriver1,
|
||||
&i2cDriver2,
|
||||
#else
|
||||
&i2cDriver0,
|
||||
NULL,
|
||||
NULL,
|
||||
#endif
|
||||
&spiDeviceManager,
|
||||
&analogIn,
|
||||
&storageDriver,
|
||||
@ -183,7 +199,13 @@ void HAL_Linux::init(int argc,char* const argv[]) const
|
||||
|
||||
scheduler->init(NULL);
|
||||
gpio->init();
|
||||
i2c->begin();
|
||||
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_BEBOP
|
||||
i2c0->begin();
|
||||
i2c1->begin();
|
||||
i2c2->begin();
|
||||
#else
|
||||
i2c0->begin();
|
||||
#endif
|
||||
rcout->init(NULL);
|
||||
rcin->init(NULL);
|
||||
uartA->begin(115200);
|
||||
|
@ -72,6 +72,8 @@ HAL_PX4::HAL_PX4() :
|
||||
&uartDDriver, /* uartD */
|
||||
&uartEDriver, /* uartE */
|
||||
&i2cDriver, /* i2c */
|
||||
NULL, /* only one i2c */
|
||||
NULL, /* only one i2c */
|
||||
&spiDeviceManager, /* spi */
|
||||
&analogIn, /* analogin */
|
||||
&storageDriver, /* storage */
|
||||
|
@ -50,6 +50,8 @@ HAL_SITL::HAL_SITL() :
|
||||
&sitlUart3Driver, /* uartD */
|
||||
&sitlUart4Driver, /* uartE */
|
||||
&emptyI2C, /* i2c */
|
||||
&emptyI2C, /* i2c */
|
||||
&emptyI2C, /* i2c */
|
||||
&emptySPI, /* spi */
|
||||
&sitlAnalogIn, /* analogin */
|
||||
&sitlEEPROMStorage, /* storage */
|
||||
|
@ -103,7 +103,9 @@ HAL_VRBRAIN::HAL_VRBRAIN() :
|
||||
&uartCDriver, /* uartC */
|
||||
&uartDDriver, /* uartD */
|
||||
&uartEDriver, /* uartE */
|
||||
&i2cDriver, /* i2c */
|
||||
&i2cDriver, /* Empty i2c */
|
||||
&i2cDriver, /* Empty i2c */
|
||||
&i2cDriver, /* Empty i2c */
|
||||
&spiDeviceManager, /* spi */
|
||||
&analogIn, /* analogin */
|
||||
&storageDriver, /* storage */
|
||||
|
Loading…
Reference in New Issue
Block a user