diff --git a/libraries/AP_PiccoloCAN/AP_PiccoloCAN_Device.h b/libraries/AP_PiccoloCAN/AP_PiccoloCAN_Device.h index d03f76365d..82c9bbb43c 100644 --- a/libraries/AP_PiccoloCAN/AP_PiccoloCAN_Device.h +++ b/libraries/AP_PiccoloCAN/AP_PiccoloCAN_Device.h @@ -21,6 +21,12 @@ #include #include +#ifndef HAL_PICCOLO_CAN_ENABLE +#define HAL_PICCOLO_CAN_ENABLE (HAL_NUM_CAN_IFACES && !HAL_MINIMIZE_FEATURES) +#endif + +#if HAL_PICCOLO_CAN_ENABLE + // Piccolo message groups form part of the CAN ID of each frame enum class PiccoloCAN_MessageGroup : uint8_t { SIMULATOR = 0x00, // Simulator messages @@ -65,4 +71,6 @@ public: //! Timestamp of most recently received CAN message uint64_t last_msg_timestamp = 0; -}; \ No newline at end of file +}; + +#endif // HAL_PICCOLO_CAN_ENABLE diff --git a/libraries/AP_PiccoloCAN/AP_PiccoloCAN_ECU.cpp b/libraries/AP_PiccoloCAN/AP_PiccoloCAN_ECU.cpp index 8863224df4..c4343a3685 100644 --- a/libraries/AP_PiccoloCAN/AP_PiccoloCAN_ECU.cpp +++ b/libraries/AP_PiccoloCAN/AP_PiccoloCAN_ECU.cpp @@ -17,6 +17,8 @@ #include "AP_PiccoloCAN_ECU.h" +#if HAL_PICCOLO_CAN_ENABLE + // Protocol files for the ECU #include #include @@ -88,3 +90,5 @@ uint32_t getECUPacketID(const void* pkt) // Extract the message ID field from the 29-bit ID return (uint32_t) ((frame->id >> 16) & 0xFF); } + +#endif // HAL_PICCOLO_CAN_ENABLE \ No newline at end of file diff --git a/libraries/AP_PiccoloCAN/AP_PiccoloCAN_ECU.h b/libraries/AP_PiccoloCAN/AP_PiccoloCAN_ECU.h index d8d962e1b0..59da746362 100644 --- a/libraries/AP_PiccoloCAN/AP_PiccoloCAN_ECU.h +++ b/libraries/AP_PiccoloCAN/AP_PiccoloCAN_ECU.h @@ -25,6 +25,8 @@ #define PICCOLO_CAN_ECU_ID_DEFAULT 0 +#if HAL_PICCOLO_CAN_ENABLE + /* * Class representing an individual PiccoloCAN ECU */ @@ -32,4 +34,6 @@ class AP_PiccoloCAN_ECU : public AP_PiccoloCAN_Device { public: // TODO -}; \ No newline at end of file +}; + +#endif // HAL_PICCOLO_CAN_ENABLE diff --git a/libraries/AP_PiccoloCAN/AP_PiccoloCAN_ESC.cpp b/libraries/AP_PiccoloCAN/AP_PiccoloCAN_ESC.cpp index 6ca1bc1caf..8f45dda700 100644 --- a/libraries/AP_PiccoloCAN/AP_PiccoloCAN_ESC.cpp +++ b/libraries/AP_PiccoloCAN/AP_PiccoloCAN_ESC.cpp @@ -17,6 +17,7 @@ #include "AP_PiccoloCAN_ESC.h" +#if HAL_PICCOLO_CAN_ENABLE /* * Decode a recevied CAN frame. @@ -145,4 +146,6 @@ uint32_t getESCVelocityPacketID(const void* pkt) // Extract the message ID field from the 29-bit ID return (uint32_t) ((frame->id >> 16) & 0xFF); -} \ No newline at end of file +} + +#endif // HAL_PICCOLO_CAN_ENABLE diff --git a/libraries/AP_PiccoloCAN/AP_PiccoloCAN_ESC.h b/libraries/AP_PiccoloCAN/AP_PiccoloCAN_ESC.h index 6a616ffd11..82b44d82ad 100644 --- a/libraries/AP_PiccoloCAN/AP_PiccoloCAN_ESC.h +++ b/libraries/AP_PiccoloCAN/AP_PiccoloCAN_ESC.h @@ -25,6 +25,8 @@ #include "AP_PiccoloCAN_Device.h" #include "piccolo_protocol/ESCPackets.h" +#if HAL_PICCOLO_CAN_ENABLE + #define PICCOLO_CAN_MAX_NUM_ESC 16 #define PICCOLO_CAN_MAX_GROUP_ESC (PICCOLO_CAN_MAX_NUM_ESC / 4) @@ -69,4 +71,6 @@ public: ESC_Address_t address; ESC_EEPROMSettings_t eeprom; } settings; -}; \ No newline at end of file +}; + +#endif // HAL_PICCOLO_CAN_ENABLE diff --git a/libraries/AP_PiccoloCAN/AP_PiccoloCAN_Servo.cpp b/libraries/AP_PiccoloCAN/AP_PiccoloCAN_Servo.cpp index adb9b78755..c0afa6c6f6 100644 --- a/libraries/AP_PiccoloCAN/AP_PiccoloCAN_Servo.cpp +++ b/libraries/AP_PiccoloCAN/AP_PiccoloCAN_Servo.cpp @@ -17,6 +17,7 @@ #include "AP_PiccoloCAN_Servo.h" +#if HAL_PICCOLO_CAN_ENABLE /* * Decode a recevied CAN frame. @@ -112,4 +113,6 @@ uint32_t getServoPacketID(const void* pkt) // Extract the message ID field from the 29-bit ID return (uint32_t) ((frame->id >> 16) & 0xFF); -} \ No newline at end of file +} + +#endif // HAL_PICCOLO_CAN_ENABLE \ No newline at end of file diff --git a/libraries/AP_PiccoloCAN/AP_PiccoloCAN_Servo.h b/libraries/AP_PiccoloCAN/AP_PiccoloCAN_Servo.h index 6e61a721c2..13f430d71b 100644 --- a/libraries/AP_PiccoloCAN/AP_PiccoloCAN_Servo.h +++ b/libraries/AP_PiccoloCAN/AP_PiccoloCAN_Servo.h @@ -22,6 +22,8 @@ #include "AP_PiccoloCAN_Device.h" #include "piccolo_protocol/ServoPackets.h" +#if HAL_PICCOLO_CAN_ENABLE + #define PICCOLO_CAN_MAX_NUM_SERVO 16 #define PICCOLO_CAN_MAX_GROUP_SERVO (PICCOLO_CAN_MAX_NUM_SERVO / 4) @@ -62,4 +64,6 @@ public: Servo_Address_t address; Servo_SettingsInfo_t settings; } settings; -}; \ No newline at end of file +}; + +#endif // HAL_PICCOLO_CAN_ENABLE