From 2c3aa87ed2db31ebfe433171f7d2e700ca698ef3 Mon Sep 17 00:00:00 2001 From: David Sidrane Date: Tue, 6 Aug 2019 04:29:46 -0700 Subject: [PATCH] fmuv5x:Use ADC3 for HW VER/REV detection fmu-v5x:hrt needs to be running for ADC time out Fixes bug introduced in 320d2e adding platform layer. --- boards/px4/fmu-v5x/nuttx-config/nsh/defconfig | 1 + boards/px4/fmu-v5x/src/board_config.h | 11 ++++++++--- boards/px4/fmu-v5x/src/init.c | 5 ++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/boards/px4/fmu-v5x/nuttx-config/nsh/defconfig b/boards/px4/fmu-v5x/nuttx-config/nsh/defconfig index 1a93d8b349bd..80d510ce8dae 100644 --- a/boards/px4/fmu-v5x/nuttx-config/nsh/defconfig +++ b/boards/px4/fmu-v5x/nuttx-config/nsh/defconfig @@ -162,6 +162,7 @@ CONFIG_START_DAY=30 CONFIG_START_MONTH=11 CONFIG_STDIO_BUFFER_SIZE=32 CONFIG_STM32F7_ADC1=y +CONFIG_STM32F7_ADC3=y CONFIG_STM32F7_BBSRAM=y CONFIG_STM32F7_BBSRAM_FILES=5 CONFIG_STM32F7_BKPSRAM=y diff --git a/boards/px4/fmu-v5x/src/board_config.h b/boards/px4/fmu-v5x/src/board_config.h index 1397d988b1ec..7a0f0c9867dd 100644 --- a/boards/px4/fmu-v5x/src/board_config.h +++ b/boards/px4/fmu-v5x/src/board_config.h @@ -318,6 +318,7 @@ #define ADC_ADC1_6V6_CHANNEL /* PC0 */ ADC1_CH(10) #define ADC_SCALED_VDD_3V3_SENSORS4_CHANNEL /* PC2 */ ADC1_CH(12) #define ADC_ADC1_3V3_CHANNEL /* PC3 */ ADC1_CH(13) + #define ADC_HW_VER_SENSE_CHANNEL /* PF4 */ ADC3_CH(14) #define ADC_HW_REV_SENSE_CHANNEL /* PF5 */ ADC3_CH(15) @@ -328,12 +329,16 @@ (1 << ADC_SCALED_V5_CHANNEL) | \ (1 << ADC_ADC1_6V6_CHANNEL) | \ (1 << ADC_SCALED_VDD_3V3_SENSORS4_CHANNEL) | \ - (1 << ADC_ADC1_3V3_CHANNEL) | \ - (1 << ADC_HW_VER_SENSE_CHANNEL) | \ - (1 << ADC_HW_REV_SENSE_CHANNEL)) + (1 << ADC_ADC1_3V3_CHANNEL)) /* HW has to large of R termination on ADC todo:change when HW value is chosen */ +#define HW_REV_VER_ADC_BASE STM32_ADC3_BASE + +#define SYSTEM_ADC_BASE STM32_ADC1_BASE + + + #define BOARD_ADC_OPEN_CIRCUIT_V (5.6f) /* HW Version and Revision drive signals Default to 1 to detect */ diff --git a/boards/px4/fmu-v5x/src/init.c b/boards/px4/fmu-v5x/src/init.c index a3544aeda7d3..3122d0d4c1d5 100644 --- a/boards/px4/fmu-v5x/src/init.c +++ b/boards/px4/fmu-v5x/src/init.c @@ -222,6 +222,10 @@ __EXPORT int board_app_initialize(uintptr_t arg) VDD_3V3_SENSORS4_EN(true); VDD_3V3_SPEKTRUM_POWER_EN(true); + /* Need hrt running before using the ADC */ + + px4_platform_init(); + if (OK == board_determine_hw_info()) { syslog(LOG_INFO, "[boot] Rev 0x%1x : Ver 0x%1x %s\n", board_get_hw_revision(), board_get_hw_version(), @@ -231,7 +235,6 @@ __EXPORT int board_app_initialize(uintptr_t arg) syslog(LOG_ERR, "[boot] Failed to read HW revision and version\n"); } - px4_platform_init(); /* configure the DMA allocator */