AP_BoardConfig: add ToshibaCAN

This commit is contained in:
Randy Mackay 2019-01-15 13:49:40 +09:00 committed by Andrew Tridgell
parent b3b3385143
commit a37c86af6e
3 changed files with 14 additions and 2 deletions

View File

@ -18,6 +18,7 @@
#include <AP_HAL/AP_HAL.h>
#include <AP_Common/AP_Common.h>
#include "AP_BoardConfig.h"
#include "AP_BoardConfig_CAN.h"
#if HAL_WITH_UAVCAN
@ -39,6 +40,7 @@
#include <AP_UAVCAN/AP_UAVCAN.h>
#include <AP_KDECAN/AP_KDECAN.h>
#include <AP_ToshibaCAN/AP_ToshibaCAN.h>
extern const AP_HAL::HAL& hal;
@ -160,6 +162,13 @@ void AP_BoardConfig_CAN::init()
AP_Param::load_object_from_eeprom(_drivers[i]._kdecan, AP_KDECAN::var_info);
#endif
} else if (prot_type == Protocol_Type_ToshibaCAN) {
_drivers[i]._driver = _drivers[i]._tcan = new AP_ToshibaCAN;
if (_drivers[i]._driver == nullptr) {
AP_BoardConfig::sensor_config_error("ToshibaCAN init failed");
continue;
}
} else {
continue;
}

View File

@ -26,6 +26,7 @@ public:
Protocol_Type_None = 0,
Protocol_Type_UAVCAN = 1,
Protocol_Type_KDECAN = 2,
Protocol_Type_ToshibaCAN = 3
};
void init(void);
@ -123,6 +124,7 @@ private:
AP_HAL::CANProtocol* _driver;
AP_HAL::CANProtocol* _uavcan;
AP_HAL::CANProtocol* _kdecan;
AP_HAL::CANProtocol* _tcan;
};
Interface _interfaces[MAX_NUMBER_OF_CAN_INTERFACES];

View File

@ -20,6 +20,7 @@
#include <AP_Vehicle/AP_Vehicle.h>
#include <AP_UAVCAN/AP_UAVCAN.h>
#include <AP_ToshibaCAN/AP_ToshibaCAN.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)
@ -31,8 +32,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
// @Values: 0:Disabled,1:UAVCAN
// @Values{Copter,Plane,Sub}: 0:Disabled,1:UAVCAN,2:KDECAN,3:ToshibaCAN
// @Values: 0:Disabled,1:UAVCAN,3:ToshibaCAN
// @User: Advanced
// @RebootRequired: True
AP_GROUPINFO("PROTOCOL", 1, AP_BoardConfig_CAN::Driver, _protocol_type, AP_BoardConfig_CAN::Protocol_Type_UAVCAN),