From 0645a5b11a4e6278fb18949af3de96b37fe32755 Mon Sep 17 00:00:00 2001 From: Francisco Ferreira Date: Tue, 27 Feb 2018 23:53:37 +0000 Subject: [PATCH] AP_HAL: introduce a CANProtocol interface and remove HAL CAN thread management --- libraries/AP_HAL/AP_HAL_Namespace.h | 1 + libraries/AP_HAL/CAN.h | 15 ++++++++++++--- libraries/AP_HAL/Scheduler.h | 2 -- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/libraries/AP_HAL/AP_HAL_Namespace.h b/libraries/AP_HAL/AP_HAL_Namespace.h index 158e20c8da..464213b606 100644 --- a/libraries/AP_HAL/AP_HAL_Namespace.h +++ b/libraries/AP_HAL/AP_HAL_Namespace.h @@ -29,6 +29,7 @@ namespace AP_HAL { class Semaphore; class OpticalFlow; + class CANProtocol; class CANManager; class CAN; diff --git a/libraries/AP_HAL/CAN.h b/libraries/AP_HAL/CAN.h index 663bf15fd3..917d7ba46f 100644 --- a/libraries/AP_HAL/CAN.h +++ b/libraries/AP_HAL/CAN.h @@ -32,7 +32,18 @@ #define MAX_NUMBER_OF_CAN_INTERFACES 2 #define MAX_NUMBER_OF_CAN_DRIVERS 2 -class AP_UAVCAN; +/** + * Interface that CAN protocols need to implement + */ +class AP_HAL::CANProtocol { +public: + /* method called when initializing the CAN interfaces + * + * if initialization doesn't have errors, protocol class + * should create a thread to do send and receive operations + */ + virtual void init(uint8_t driver_index) = 0; +}; /** * Single non-blocking CAN interface. @@ -115,8 +126,6 @@ public: virtual bool is_initialized() = 0; virtual void initialized(bool val) = 0; - virtual AP_UAVCAN *get_UAVCAN(void) = 0; - virtual void set_UAVCAN(AP_UAVCAN *uavcan) = 0; uavcan::ICanDriver* get_driver() { return _driver; } private: uavcan::ICanDriver* _driver; diff --git a/libraries/AP_HAL/Scheduler.h b/libraries/AP_HAL/Scheduler.h index 77a47b0ef4..76c51d3660 100644 --- a/libraries/AP_HAL/Scheduler.h +++ b/libraries/AP_HAL/Scheduler.h @@ -63,8 +63,6 @@ public: virtual bool in_main_thread() const = 0; - virtual void create_uavcan_thread() {}; - /* disable interrupts and return a context that can be used to restore the interrupt state. This can be used to protect