From 0cf307940139794c741474929a528a0db5027169 Mon Sep 17 00:00:00 2001 From: Jukka Laitinen Date: Tue, 6 Oct 2020 15:37:45 +0300 Subject: [PATCH] px4_fmuv5: Implement BOARD_*_LOCKOUT_STATE in protected/kernel builds In memory protected builds these perform nuttx boardctl ioctl calls to kerenel Signed-off-by: Jukka Laitinen --- boards/px4/fmu-v5/src/board_config.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/boards/px4/fmu-v5/src/board_config.h b/boards/px4/fmu-v5/src/board_config.h index f1b2a0edc9..12e41ab0ba 100644 --- a/boards/px4/fmu-v5/src/board_config.h +++ b/boards/px4/fmu-v5/src/board_config.h @@ -49,6 +49,11 @@ #include +#if !defined(CONFIG_BUILD_FLAT) +#include +#include +#endif + /**************************************************************************************************** * Definitions ****************************************************************************************************/ @@ -211,8 +216,26 @@ #define GPIO_nARMED_INIT /* PI0 */ (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTI|GPIO_PIN0) #define GPIO_nARMED /* PI0 */ (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTI|GPIO_PIN0) +/* For protected build, define the LOCKOUT_STATE macros as function calls */ +#ifdef CONFIG_BUILD_FLAT #define BOARD_INDICATE_EXTERNAL_LOCKOUT_STATE(enabled) px4_arch_configgpio((enabled) ? GPIO_nARMED : GPIO_nARMED_INIT) #define BOARD_GET_EXTERNAL_LOCKOUT_STATE() px4_arch_gpioread(GPIO_nARMED) +#else +static inline void board_indicate_external_lockout_state(bool enable) +{ + platformioclockoutstate_t state = {enable}; + boardctl(PLATFORMIOCINDICATELOCKOUT, (uintptr_t)&state); +} + +static inline bool board_get_external_lockout_state(void) +{ + platformioclockoutstate_t state = {false}; + boardctl(PLATFORMIOCGETLOCKOUT, (uintptr_t)&state); + return state.enabled; +} +#define BOARD_INDICATE_EXTERNAL_LOCKOUT_STATE(enabled) board_indicate_external_lockout_state(enabled) +#define BOARD_GET_EXTERNAL_LOCKOUT_STATE() board_get_external_lockout_state() +#endif /* PWM */