AP_HAL_AVR: add semaphore to I2CDriver

This commit is contained in:
Pat Hickey 2013-01-04 16:19:38 -08:00
parent 3da864499d
commit 4c31cc0c2b
4 changed files with 9 additions and 4 deletions

View File

@ -21,7 +21,8 @@ AVRUARTDriverInstance(avrUart0Driver, 0);
AVRUARTDriverInstance(avrUart1Driver, 1);
AVRUARTDriverInstance(avrUart3Driver, 3);
static AVRI2CDriver avrI2CDriver;
static AVRSemaphore i2cSemaphore;
static AVRI2CDriver avrI2CDriver(&i2cSemaphore);
static APM1SPIDeviceManager apm1SPIDriver;
static AVRAnalogIn avrAnalogIn;
static AVREEPROMStorage avrEEPROMStorage;

View File

@ -21,7 +21,8 @@ AVRUARTDriverInstance(avrUart0Driver, 0);
AVRUARTDriverInstance(avrUart1Driver, 1);
AVRUARTDriverInstance(avrUart2Driver, 2);
static AVRI2CDriver avrI2CDriver;
static AVRSemaphore i2cSemaphore;
static AVRI2CDriver avrI2CDriver(&i2cSemaphore);
static APM2SPIDeviceManager apm2SPIDriver;
static AVRAnalogIn avrAnalogIn;
static AVREEPROMStorage avrEEPROMStorage;

View File

@ -316,5 +316,4 @@ SIGNAL(TWI_vect)
}
}
#endif

View File

@ -9,7 +9,7 @@
class AP_HAL_AVR::AVRI2CDriver : public AP_HAL::I2CDriver {
public:
AVRI2CDriver() {}
AVRI2CDriver(AP_HAL::Semaphore *sem) : _sem(sem) {}
void begin();
void end();
@ -26,6 +26,8 @@ public:
uint8_t len, uint8_t* data);
uint8_t lockup_count() { return _lockup_count; }
AP_HAL::Semaphore* get_semaphore() { return _sem; }
private:
uint8_t _start();
uint8_t _stop();
@ -39,6 +41,8 @@ private:
uint8_t _lockup_count;
uint16_t _timeoutDelay;
AP_HAL::Semaphore *_sem;
};
#endif // __AP_HAL_AVR_I2C_DRIVER_H__