AP_BoardConfig: added support for Piccolo CAN ESCs

This commit is contained in:
Oliver Walters 2019-12-09 15:31:29 +11:00 committed by Andrew Tridgell
parent 2e0d2e2db0
commit 7c3391d0d8
3 changed files with 20 additions and 6 deletions

View File

@ -36,6 +36,8 @@
#include <AP_KDECAN/AP_KDECAN.h>
#include <AP_ToshibaCAN/AP_ToshibaCAN.h>
#include <AP_SerialManager/AP_SerialManager.h>
#include <AP_PiccoloCAN/AP_PiccoloCAN.h>
extern const AP_HAL::HAL& hal;
// table of user settable parameters
@ -174,6 +176,15 @@ void AP_BoardConfig_CAN::init()
AP_BoardConfig::config_error("ToshibaCAN init failed");
continue;
}
#if HAL_PICCOLO_CAN_ENABLE
} else if (prot_type == Protocol_Type_PiccoloCAN) {
_drivers[i]._driver = _drivers[i]._pcan = new AP_PiccoloCAN;
if (_drivers[i]._driver == nullptr) {
AP_BoardConfig::config_error("PiccoloCAN init failed");
continue;
}
#endif
} else {
continue;
}

View File

@ -26,7 +26,8 @@ public:
Protocol_Type_None = 0,
Protocol_Type_UAVCAN = 1,
Protocol_Type_KDECAN = 2,
Protocol_Type_ToshibaCAN = 3
Protocol_Type_ToshibaCAN = 3,
Protocol_Type_PiccoloCAN = 4,
};
void init(void);
@ -126,9 +127,10 @@ private:
AP_Int8 _protocol_type;
Protocol_Type _protocol_type_cache;
AP_HAL::CANProtocol* _driver;
AP_HAL::CANProtocol* _uavcan;
AP_HAL::CANProtocol* _kdecan;
AP_HAL::CANProtocol* _tcan;
AP_HAL::CANProtocol* _uavcan; // UAVCAN
AP_HAL::CANProtocol* _kdecan; // KDECAN
AP_HAL::CANProtocol* _tcan; // ToshibaCAN
AP_HAL::CANProtocol* _pcan; // PiccoloCAN
};
#if AP_UAVCAN_SLCAN_ENABLED

View File

@ -21,6 +21,7 @@
#include <AP_UAVCAN/AP_UAVCAN.h>
#include <AP_ToshibaCAN/AP_ToshibaCAN.h>
#include <AP_PiccoloCAN/AP_PiccoloCAN.h>
// To be replaced with macro saying if KDECAN library is included
#if APM_BUILD_TYPE(APM_BUILD_ArduCopter) || APM_BUILD_TYPE(APM_BUILD_ArduPlane) || APM_BUILD_TYPE(APM_BUILD_ArduSub)
@ -32,8 +33,8 @@ const AP_Param::GroupInfo AP_BoardConfig_CAN::Driver::var_info[] = {
// @Param: PROTOCOL
// @DisplayName: Enable use of specific protocol over virtual driver
// @Description: Enabling this option starts selected protocol that will use this virtual driver
// @Values{Copter,Plane,Sub}: 0:Disabled,1:UAVCAN,2:KDECAN,3:ToshibaCAN
// @Values: 0:Disabled,1:UAVCAN,3:ToshibaCAN
// @Values{Copter,Plane,Sub}: 0:Disabled,1:UAVCAN,2:KDECAN,3:ToshibaCAN,4:PiccoloCAN
// @Values: 0:Disabled,1:UAVCAN,3:ToshibaCAN,4:PiccoloCAN
// @User: Advanced
// @RebootRequired: True
AP_GROUPINFO("PROTOCOL", 1, AP_BoardConfig_CAN::Driver, _protocol_type, AP_BoardConfig_CAN::Protocol_Type_UAVCAN),