AP_CANSensor: add get_driver_type() accessor

This commit is contained in:
Tom Pittenger 2023-04-15 14:56:06 -07:00 committed by Andrew Tridgell
parent 9cf5759435
commit 84b7444047

View File

@ -40,11 +40,22 @@ public:
#ifdef HAL_BUILD_AP_PERIPH
static void set_periph(const uint8_t i, const AP_CANManager::Driver_Type protocol, AP_HAL::CANIface* iface) {
if (i < HAL_NUM_CAN_IFACES) {
if (i < ARRAY_SIZE(_periph)) {
_periph[i].protocol = protocol;
_periph[i].iface = iface;
}
}
// return driver type index i
static AP_CANManager::Driver_Type get_driver_type(const uint8_t i)
{
if (i < ARRAY_SIZE(_periph)) {
return _periph[i].protocol;
}
return AP_CANManager::Driver_Type_None;
}
#else
static AP_CANManager::Driver_Type get_driver_type(const uint8_t i) { return AP::can().get_driver_type(i); }
#endif
protected: