mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-01 13:38:38 -04:00
AP_HAL: added I2C bus mask functions and macros
This commit is contained in:
parent
8516fa43c2
commit
44685bbb7b
@ -89,6 +89,28 @@ public:
|
||||
// Not implemented
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/*
|
||||
get mask of bus numbers for all configured I2C buses
|
||||
*/
|
||||
virtual uint32_t get_bus_mask(void) const { return 0x0F; }
|
||||
|
||||
/*
|
||||
get mask of bus numbers for all configured external I2C buses
|
||||
*/
|
||||
virtual uint32_t get_bus_mask_external(void) const { return 0x0F; }
|
||||
|
||||
/*
|
||||
get mask of bus numbers for all configured internal I2C buses
|
||||
*/
|
||||
virtual uint32_t get_bus_mask_internal(void) const { return 0x01; }
|
||||
};
|
||||
|
||||
/*
|
||||
convenient macros for iterating over I2C bus numbers
|
||||
*/
|
||||
#define FOREACH_I2C_EXTERNAL(i) for (uint32_t _bmask=hal.i2c_mgr->get_bus_mask_external(), i=0; i<32; i++) if ((1U<<i)&_bmask)
|
||||
#define FOREACH_I2C_INTERNAL(i) for (uint32_t _bmask=hal.i2c_mgr->get_bus_mask_internal(), i=0; i<32; i++) if ((1U<<i)&_bmask)
|
||||
#define FOREACH_I2C(i) for (uint32_t _bmask=hal.i2c_mgr->get_bus_mask(), i=0; i<32; i++) if ((1U<<i)&_bmask)
|
||||
|
||||
}
|
||||
|
@ -382,3 +382,16 @@
|
||||
#ifndef HAL_BOARD_CAN_IFACE_NAME
|
||||
#define HAL_BOARD_CAN_IFACE_NAME "can0"
|
||||
#endif
|
||||
|
||||
// if bus masks are not setup above then use these defaults
|
||||
#ifndef HAL_LINUX_I2C_BUS_MASK
|
||||
#define HAL_LINUX_I2C_BUS_MASK 0x1f
|
||||
#endif
|
||||
|
||||
#ifndef HAL_LINUX_I2C_INTERNAL_BUS_MASK
|
||||
#define HAL_LINUX_I2C_INTERNAL_BUS_MASK 0x01
|
||||
#endif
|
||||
|
||||
#ifndef HAL_LINUX_I2C_EXTERNAL_BUS_MASK
|
||||
#define HAL_LINUX_I2C_EXTERNAL_BUS_MASK 0x1E
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user