From 56c6120e83e45214beaecd00abd05ef6d0193302 Mon Sep 17 00:00:00 2001 From: Jukka Laitinen Date: Fri, 8 Oct 2021 09:13:56 +0300 Subject: [PATCH] Use IOCTL for board_read_VBUS_state in NuttX protected builds Direct gpio read is not possible from user side applications, so use boardctl interface instead. Signed-off-by: Jukka Laitinen --- boards/px4/fmu-v5/src/stm32_userspace.c | 1 - .../common/include/px4_platform_common/board_common.h | 9 ++++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/boards/px4/fmu-v5/src/stm32_userspace.c b/boards/px4/fmu-v5/src/stm32_userspace.c index c7260d8ef1..2c52f986bb 100644 --- a/boards/px4/fmu-v5/src/stm32_userspace.c +++ b/boards/px4/fmu-v5/src/stm32_userspace.c @@ -143,5 +143,4 @@ int CONFIG_USER_ENTRYPOINT(int argc, char *argv[]) return nsh_main(argc, argv); } - #endif /* !CONFIG_BUILD_FLAT && !__KERNEL__ */ diff --git a/platforms/common/include/px4_platform_common/board_common.h b/platforms/common/include/px4_platform_common/board_common.h index 08a23476a6..4acfa65549 100644 --- a/platforms/common/include/px4_platform_common/board_common.h +++ b/platforms/common/include/px4_platform_common/board_common.h @@ -502,7 +502,14 @@ static inline bool board_rc_invert_input(const char *device, bool invert) { retu * ************************************************************************************/ -#if defined(GPIO_OTGFS_VBUS) +#if defined(__PX4_NUTTX) && !defined(CONFIG_BUILD_FLAT) +inline static int board_read_VBUS_state(void) +{ + platformiocvbusstate_t state = {false}; + boardctl(PLATFORMIOCVBUSSTATE, (uintptr_t)&state); + return state.ret; +} +#elif defined(GPIO_OTGFS_VBUS) # define board_read_VBUS_state() (px4_arch_gpioread(GPIO_OTGFS_VBUS) ? 0 : 1) #else int board_read_VBUS_state(void);