From 531f4f92838a5266fd3f8962f2fc3c47ce69a45c Mon Sep 17 00:00:00 2001 From: Lokesh-Ramina Date: Mon, 20 Nov 2023 19:38:43 -0800 Subject: [PATCH] AP_EFI: fixed build on boards without EFI support Currawong and DroneCAN --- libraries/AP_EFI/AP_EFI_Currawong_ECU.cpp | 8 ++++--- libraries/AP_EFI/AP_EFI_Currawong_ECU.h | 12 ++++------ libraries/AP_EFI/AP_EFI_DroneCAN.cpp | 11 ++++----- libraries/AP_EFI/AP_EFI_DroneCAN.h | 11 ++++----- libraries/AP_EFI/AP_EFI_config.h | 28 +++++++++++++++++++++++ 5 files changed, 46 insertions(+), 24 deletions(-) diff --git a/libraries/AP_EFI/AP_EFI_Currawong_ECU.cpp b/libraries/AP_EFI/AP_EFI_Currawong_ECU.cpp index 091537807c..4a2d23a74f 100644 --- a/libraries/AP_EFI/AP_EFI_Currawong_ECU.cpp +++ b/libraries/AP_EFI/AP_EFI_Currawong_ECU.cpp @@ -19,10 +19,12 @@ * Author: Reilly Callaway / Currawong Engineering Pty Ltd */ -#include "AP_EFI_Currawong_ECU.h" +#include "AP_EFI_config.h" + -#if HAL_EFI_CURRAWONG_ECU_ENABLED +#if HAL_EFI_ENABLED && HAL_EFI_CURRAWONG_ECU_ENABLED +#include "AP_EFI_Currawong_ECU.h" #include #include #include @@ -103,4 +105,4 @@ bool AP_EFI_Currawong_ECU::handle_message(AP_HAL::CANFrame &frame) return valid; } -#endif // HAL_EFI_CURRAWONG_ECU_ENABLED +#endif // HAL_EFI_CURRAWONG_ECU_ENABLED && HAL_EFI_ENABLED diff --git a/libraries/AP_EFI/AP_EFI_Currawong_ECU.h b/libraries/AP_EFI/AP_EFI_Currawong_ECU.h index 89387e9dd4..f87a15d2b7 100644 --- a/libraries/AP_EFI/AP_EFI_Currawong_ECU.h +++ b/libraries/AP_EFI/AP_EFI_Currawong_ECU.h @@ -21,14 +21,12 @@ #pragma once -#include "AP_EFI.h" -#include "AP_EFI_Backend.h" +#include "AP_EFI_config.h" -#ifndef HAL_EFI_CURRAWONG_ECU_ENABLED -#define HAL_EFI_CURRAWONG_ECU_ENABLED HAL_MAX_CAN_PROTOCOL_DRIVERS && (BOARD_FLASH_SIZE > 1024) -#endif +#if HAL_EFI_ENABLED && HAL_EFI_CURRAWONG_ECU_ENABLED -#if HAL_EFI_CURRAWONG_ECU_ENABLED +#include "AP_EFI.h" +#include "AP_EFI_Backend.h" class AP_EFI_Currawong_ECU : public AP_EFI_Backend { public: @@ -49,5 +47,5 @@ class AP_EFI_Currawong_ECU : public AP_EFI_Backend { friend class AP_PiccoloCAN; }; -#endif // HAL_EFI_CURRAWONG_ECU_ENABLED +#endif // HAL_EFI_CURRAWONG_ECU_ENABLED && HAL_EFI_ENABLED diff --git a/libraries/AP_EFI/AP_EFI_DroneCAN.cpp b/libraries/AP_EFI/AP_EFI_DroneCAN.cpp index 21d374250f..bbabee1fed 100644 --- a/libraries/AP_EFI/AP_EFI_DroneCAN.cpp +++ b/libraries/AP_EFI/AP_EFI_DroneCAN.cpp @@ -1,11 +1,9 @@ -#include #include "AP_EFI_config.h" -#if HAL_EFI_ENABLED -#include "AP_EFI_DroneCAN.h" - -#if HAL_EFI_DRONECAN_ENABLED +#if HAL_EFI_ENABLED && HAL_EFI_DRONECAN_ENABLED +#include +#include "AP_EFI_DroneCAN.h" #include #include @@ -167,5 +165,4 @@ void AP_EFI_DroneCAN::handle_status(const uavcan::equipment::ice::reciprocating: copy_to_frontend(); } -#endif // HAL_EFI_DRONECAN_ENABLED -#endif // HAL_EFI_ENABLED +#endif // HAL_EFI_DRONECAN_ENABLED && HAL_EFI_ENABLED diff --git a/libraries/AP_EFI/AP_EFI_DroneCAN.h b/libraries/AP_EFI/AP_EFI_DroneCAN.h index 35c02d5e37..7d2d5e2b40 100644 --- a/libraries/AP_EFI/AP_EFI_DroneCAN.h +++ b/libraries/AP_EFI/AP_EFI_DroneCAN.h @@ -1,13 +1,10 @@ #pragma once +#include "AP_EFI_config.h" + +#if HAL_EFI_ENABLED && HAL_EFI_DRONECAN_ENABLED #include "AP_EFI.h" #include "AP_EFI_Backend.h" - -#ifndef HAL_EFI_DRONECAN_ENABLED -#define HAL_EFI_DRONECAN_ENABLED HAL_MAX_CAN_PROTOCOL_DRIVERS && BOARD_FLASH_SIZE > 1024 && HAL_CANMANAGER_ENABLED -#endif - -#if HAL_EFI_DRONECAN_ENABLED #include #include @@ -28,5 +25,5 @@ class AP_EFI_DroneCAN : public AP_EFI_Backend { // singleton for trampoline static AP_EFI_DroneCAN *driver; }; -#endif // HAL_EFI_DRONECAN_ENABLED +#endif // HAL_EFI_DRONECAN_ENABLED && HAL_EFI_ENABLED diff --git a/libraries/AP_EFI/AP_EFI_config.h b/libraries/AP_EFI/AP_EFI_config.h index 368e71e3f6..257da4b9bf 100644 --- a/libraries/AP_EFI/AP_EFI_config.h +++ b/libraries/AP_EFI/AP_EFI_config.h @@ -23,3 +23,31 @@ #ifndef AP_EFI_THROTTLE_LINEARISATION_ENABLED #define AP_EFI_THROTTLE_LINEARISATION_ENABLED AP_EFI_SERIAL_HIRTH_ENABLED #endif + +#ifndef HAL_EFI_CURRAWONG_ECU_ENABLED +#define HAL_EFI_CURRAWONG_ECU_ENABLED HAL_MAX_CAN_PROTOCOL_DRIVERS && (BOARD_FLASH_SIZE > 1024) +#endif + +#ifndef HAL_EFI_DRONECAN_ENABLED +#define HAL_EFI_DRONECAN_ENABLED HAL_MAX_CAN_PROTOCOL_DRIVERS && BOARD_FLASH_SIZE > 1024 && HAL_CANMANAGER_ENABLED +#endif + +#ifndef AP_EFI_MAV_ENABLED +#define AP_EFI_MAV_ENABLED AP_EFI_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_EFI_NWPWU_ENABLED +#define AP_EFI_NWPWU_ENABLED AP_EFI_BACKEND_DEFAULT_ENABLED && HAL_MAX_CAN_PROTOCOL_DRIVERS +#endif + +#ifndef AP_EFI_SCRIPTING_ENABLED +#define AP_EFI_SCRIPTING_ENABLED (AP_EFI_BACKEND_DEFAULT_ENABLED && AP_SCRIPTING_ENABLED) +#endif + +#ifndef AP_EFI_SERIAL_MS_ENABLED +#define AP_EFI_SERIAL_MS_ENABLED AP_EFI_BACKEND_DEFAULT_ENABLED +#endif + +#ifndef AP_EFI_SERIAL_LUTAN_ENABLED +#define AP_EFI_SERIAL_LUTAN_ENABLED AP_EFI_BACKEND_DEFAULT_ENABLED +#endif \ No newline at end of file