HAL_Linux: implement device IDs for I2C and SPI

This commit is contained in:
Andrew Tridgell 2016-11-04 20:34:21 +11:00
parent de7913e8e9
commit a6ac02b61f
3 changed files with 12 additions and 5 deletions

View File

@ -137,6 +137,14 @@ int I2CBus::open(uint8_t n)
return fd;
}
I2CDevice::I2CDevice(I2CBus &bus, uint8_t address)
: _bus(bus)
, _address(address)
{
set_device_bus(bus.bus);
set_device_address(address);
}
I2CDevice::~I2CDevice()
{
// Unregister itself from the I2CDeviceManager

View File

@ -38,11 +38,7 @@ public:
/* AP_HAL::I2CDevice implementation */
I2CDevice(I2CBus &bus, uint8_t address)
: _bus(bus)
, _address(address)
{
}
I2CDevice(I2CBus &bus, uint8_t address);
~I2CDevice();

View File

@ -212,6 +212,9 @@ SPIDevice::SPIDevice(SPIBus &bus, SPIDesc &device_desc)
: _bus(bus)
, _desc(device_desc)
{
set_device_bus(_bus.bus);
set_device_address(_desc.subdev);
if (_desc.cs_pin != SPI_CS_KERNEL) {
_cs = hal.gpio->channel(_desc.cs_pin);
if (!_cs) {