mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-28 02:23:34 +08:00
adc: refactor into arch-specific directories
This commit is contained in:
@@ -196,30 +196,6 @@
|
||||
# error Unsuported BOARD_NUMBER_BRICKS number.
|
||||
#endif
|
||||
|
||||
/* Historically PX4 used one ADC1 With FMUvnX this has changes.
|
||||
* These defines maintain compatibility while allowing the
|
||||
* new boards to override the ADC used from HW VER/REV and
|
||||
* the system one.
|
||||
*
|
||||
* Depending on HW configuration (VER/REV POP options) hardware detection
|
||||
* may or may NOT initialize a given ADC. SYSTEM_ADC_COUNT is used to size the
|
||||
* singleton array to ensure this is only done once per ADC.
|
||||
*/
|
||||
|
||||
#if !defined(HW_REV_VER_ADC_BASE)
|
||||
# define HW_REV_VER_ADC_BASE STM32_ADC1_BASE
|
||||
#endif
|
||||
|
||||
#if !defined(SYSTEM_ADC_BASE)
|
||||
# define SYSTEM_ADC_BASE STM32_ADC1_BASE
|
||||
#endif
|
||||
|
||||
#if SYSTEM_ADC_BASE == HW_REV_VER_ADC_BASE
|
||||
# define SYSTEM_ADC_COUNT 1
|
||||
#else
|
||||
# define SYSTEM_ADC_COUNT 2
|
||||
#endif
|
||||
|
||||
/* Choose the source for ADC_SCALED_V5_SENSE */
|
||||
#if defined(ADC_5V_RAIL_SENSE)
|
||||
#define ADC_SCALED_V5_SENSE ADC_5V_RAIL_SENSE
|
||||
|
||||
@@ -45,40 +45,6 @@
|
||||
* Included Files
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Name: board_adc_init
|
||||
*
|
||||
* Description:
|
||||
* boards may provide this function to allow complex version-ing.
|
||||
*
|
||||
* Input Parameters:
|
||||
* base_address - base address of the ADC
|
||||
*
|
||||
* Returned Value:
|
||||
*
|
||||
* OK, or -1 if the function failed.
|
||||
*/
|
||||
|
||||
__EXPORT int board_adc_init(uint32_t base_address);
|
||||
|
||||
/************************************************************************************
|
||||
* Name: board_adc_sample
|
||||
*
|
||||
* Description:
|
||||
* boards provide this function to allow complex version-ing.
|
||||
*
|
||||
* Input Parameters:
|
||||
* base_address - base address of the ADC
|
||||
* channel - The number of the adc channel to read.
|
||||
*
|
||||
* Returned Value:
|
||||
* The ADC DN read for the channel or 0xffff if there
|
||||
* is an error reading the channel.
|
||||
*/
|
||||
|
||||
__EXPORT uint16_t board_adc_sample(uint32_t base_address, unsigned channel);
|
||||
|
||||
|
||||
/************************************************************************************
|
||||
* Name: board_gpio_init
|
||||
*
|
||||
|
||||
@@ -39,5 +39,7 @@ add_library(drivers_boards_common_arch
|
||||
board_critmon.c
|
||||
)
|
||||
add_dependencies(drivers_boards_common_arch prebuild_targets)
|
||||
add_dependencies(drivers_boards_common_arch arch_adc)
|
||||
target_compile_options(drivers_boards_common_arch PRIVATE -Wno-cast-align) # TODO: fix and enable
|
||||
target_link_libraries(drivers_boards_common_arch PRIVATE nuttx_arch)
|
||||
target_link_libraries(drivers_boards_common_arch PRIVATE arch_adc)
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
* Implementation of STM32 based Board Hardware Revision and Version ID API
|
||||
*/
|
||||
|
||||
#include <drivers/drv_adc.h>
|
||||
#include <px4_arch_adc.h>
|
||||
#include <px4_config.h>
|
||||
#include <stdio.h>
|
||||
#include "board_config.h"
|
||||
@@ -199,11 +201,11 @@ static int read_id_dn(int *id, uint32_t gpio_drive, uint32_t gpio_sense, int adc
|
||||
|
||||
/* Yes - Fire up the ADC (it has once control) */
|
||||
|
||||
if (board_adc_init(HW_REV_VER_ADC_BASE) == OK) {
|
||||
if (px4_arch_adc_init(HW_REV_VER_ADC_BASE) == OK) {
|
||||
|
||||
/* Read the value */
|
||||
for (unsigned av = 0; av < samples; av++) {
|
||||
dn = board_adc_sample(HW_REV_VER_ADC_BASE, adc_channel);
|
||||
dn = px4_arch_adc_sample(HW_REV_VER_ADC_BASE, adc_channel);
|
||||
|
||||
if (dn == 0xffff) {
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user