board_ctrl: Clean up usage of VBUS, nARMED from user/kernelspace

Move logic implemented in the header files to source files, this way
it will be simpler to define which is compiled to kernel space and
which to user space

Also allows to remove some headers that pull in half the universe
from the board definitions (which should just be pin definitions and
no functionality)
This commit is contained in:
Ville Juven
2022-09-05 07:37:28 +02:00
committed by Beat Küng
parent a56f654651
commit 9ed35debec
10 changed files with 357 additions and 180 deletions
+3 -19
View File
@@ -43,17 +43,13 @@
* Included Files
****************************************************************************************************/
#include <px4_platform/board_ctrl.h>
#include <px4_platform_common/px4_config.h>
#include <nuttx/compiler.h>
#include <stdint.h>
#include <stm32_gpio.h>
#if !defined(CONFIG_BUILD_FLAT)
#include <sys/boardctl.h>
#include <px4_platform/board_ctrl.h>
#endif
/****************************************************************************************************
* Definitions
****************************************************************************************************/
@@ -229,20 +225,8 @@
#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()
#define BOARD_INDICATE_EXTERNAL_LOCKOUT_STATE(enabled) boardctrl_indicate_external_lockout_state(enabled)
#define BOARD_GET_EXTERNAL_LOCKOUT_STATE() boardctrl_get_external_lockout_state()
#endif
/* PWM