mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-29 06:23:34 +08:00
Hoist the ADC and CAN board-specific pieces.
This commit is contained in:
@@ -1,9 +1,6 @@
|
|||||||
/************************************************************************************
|
/****************************************************************************
|
||||||
* configs/stm3240g-eval/src/up_adc.c
|
|
||||||
* arch/arm/src/board/up_adc.c
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2012 PX4 Development Team. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -15,7 +12,7 @@
|
|||||||
* notice, this list of conditions and the following disclaimer in
|
* notice, this list of conditions and the following disclaimer in
|
||||||
* the documentation and/or other materials provided with the
|
* the documentation and/or other materials provided with the
|
||||||
* distribution.
|
* distribution.
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||||
* used to endorse or promote products derived from this software
|
* used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
@@ -32,7 +29,13 @@
|
|||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file px4fmu_adc.c
|
||||||
|
*
|
||||||
|
* Board-specific ADC functions.
|
||||||
|
*/
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
@@ -50,35 +53,8 @@
|
|||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
#include "up_arch.h"
|
#include "up_arch.h"
|
||||||
|
|
||||||
//#include "stm32_pwm.h"
|
|
||||||
#include "stm32_adc.h"
|
#include "stm32_adc.h"
|
||||||
#include "px4fmu-internal.h"
|
#include "px4fmu_internal.h"
|
||||||
|
|
||||||
#ifdef CONFIG_ADC
|
|
||||||
|
|
||||||
/************************************************************************************
|
|
||||||
* Definitions
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
/* Configuration ************************************************************/
|
|
||||||
/* Up to 3 ADC interfaces are supported */
|
|
||||||
|
|
||||||
#if STM32_NADC < 3
|
|
||||||
# undef CONFIG_STM32_ADC3
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if STM32_NADC < 2
|
|
||||||
# undef CONFIG_STM32_ADC2
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if STM32_NADC < 1
|
|
||||||
# undef CONFIG_STM32_ADC3
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(CONFIG_STM32_ADC1) || defined(CONFIG_STM32_ADC2) || defined(CONFIG_STM32_ADC3)
|
|
||||||
#ifndef CONFIG_STM32_ADC3
|
|
||||||
# warning "Channel information only available for ADC3"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define ADC3_NCHANNELS 4
|
#define ADC3_NCHANNELS 4
|
||||||
|
|
||||||
@@ -116,7 +92,6 @@ static const uint32_t g_pinlist[ADC3_NCHANNELS] = {GPIO_ADC3_IN10, GPIO_ADC3_IN
|
|||||||
|
|
||||||
int adc_devinit(void)
|
int adc_devinit(void)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_STM32_ADC3
|
|
||||||
static bool initialized = false;
|
static bool initialized = false;
|
||||||
struct adc_dev_s *adc[ADC3_NCHANNELS];
|
struct adc_dev_s *adc[ADC3_NCHANNELS];
|
||||||
int ret;
|
int ret;
|
||||||
@@ -164,10 +139,4 @@ int adc_devinit(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
#else
|
|
||||||
return -ENOSYS;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_STM32_ADC || CONFIG_STM32_ADC2 || CONFIG_STM32_ADC3 */
|
|
||||||
#endif /* CONFIG_ADC */
|
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
/************************************************************************************
|
/****************************************************************************
|
||||||
* configs/px4fmu/src/up_can.c
|
|
||||||
* arch/arm/src/board/up_can.c
|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2012 PX4 Development Team. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
@@ -15,7 +12,7 @@
|
|||||||
* notice, this list of conditions and the following disclaimer in
|
* notice, this list of conditions and the following disclaimer in
|
||||||
* the documentation and/or other materials provided with the
|
* the documentation and/or other materials provided with the
|
||||||
* distribution.
|
* distribution.
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
* 3. Neither the name PX4 nor the names of its contributors may be
|
||||||
* used to endorse or promote products derived from this software
|
* used to endorse or promote products derived from this software
|
||||||
* without specific prior written permission.
|
* without specific prior written permission.
|
||||||
*
|
*
|
||||||
@@ -32,7 +29,14 @@
|
|||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
************************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file px4fmu_can.c
|
||||||
|
*
|
||||||
|
* Board-specific CAN functions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
@@ -51,9 +55,7 @@
|
|||||||
|
|
||||||
#include "stm32.h"
|
#include "stm32.h"
|
||||||
#include "stm32_can.h"
|
#include "stm32_can.h"
|
||||||
#include "px4fmu-internal.h"
|
#include "px4fmu_internal.h"
|
||||||
|
|
||||||
#if defined(CONFIG_CAN) && (defined(CONFIG_STM32_CAN1) || defined(CONFIG_STM32_CAN2))
|
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
@@ -138,5 +140,3 @@ int can_devinit(void)
|
|||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_STM32_CAN || CONFIG_STM32_CAN2 || CONFIG_STM32_CAN3 */
|
|
||||||
@@ -63,7 +63,6 @@
|
|||||||
#include "px4fmu_internal.h"
|
#include "px4fmu_internal.h"
|
||||||
#include "stm32_uart.h"
|
#include "stm32_uart.h"
|
||||||
|
|
||||||
#include <arch/board/up_adc.h>
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
#include <arch/board/drv_led.h>
|
#include <arch/board/drv_led.h>
|
||||||
#include <arch/board/drv_eeprom.h>
|
#include <arch/board/drv_eeprom.h>
|
||||||
@@ -98,6 +97,8 @@
|
|||||||
* Protected Functions
|
* Protected Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
extern int adc_devinit(void);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Functions
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|||||||
@@ -59,8 +59,6 @@
|
|||||||
#include <drivers/drv_mag.h>
|
#include <drivers/drv_mag.h>
|
||||||
#include <drivers/drv_baro.h>
|
#include <drivers/drv_baro.h>
|
||||||
|
|
||||||
#include <arch/board/up_adc.h>
|
|
||||||
|
|
||||||
#include <systemlib/systemlib.h>
|
#include <systemlib/systemlib.h>
|
||||||
#include <systemlib/param/param.h>
|
#include <systemlib/param/param.h>
|
||||||
#include <systemlib/err.h>
|
#include <systemlib/err.h>
|
||||||
|
|||||||
@@ -1,60 +0,0 @@
|
|||||||
/************************************************************************************
|
|
||||||
* configs/stm3240g-eval/src/up_adc.c
|
|
||||||
* arch/arm/src/board/up_adc.c
|
|
||||||
*
|
|
||||||
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
|
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
|
||||||
* used to endorse or promote products derived from this software
|
|
||||||
* without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
||||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
||||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
||||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
||||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
|
||||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
|
||||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
||||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
||||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
/************************************************************************************
|
|
||||||
* Included Files
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#ifdef CONFIG_ADC
|
|
||||||
|
|
||||||
/************************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
/************************************************************************************
|
|
||||||
* Name: adc_devinit
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* All STM32 architectures must provide the following interface to work with
|
|
||||||
* examples/adc.
|
|
||||||
*
|
|
||||||
************************************************************************************/
|
|
||||||
|
|
||||||
int adc_devinit(void);
|
|
||||||
|
|
||||||
#endif /* CONFIG_ADC */
|
|
||||||
@@ -44,14 +44,6 @@ CSRCS = up_leds.c \
|
|||||||
drv_gpio.c \
|
drv_gpio.c \
|
||||||
drv_led.c drv_eeprom.c
|
drv_led.c drv_eeprom.c
|
||||||
|
|
||||||
ifeq ($(CONFIG_ADC),y)
|
|
||||||
CSRCS += up_adc.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(CONFIG_CAN),y)
|
|
||||||
CSRCS += up_can.c
|
|
||||||
endif
|
|
||||||
|
|
||||||
COBJS = $(CSRCS:.c=$(OBJEXT))
|
COBJS = $(CSRCS:.c=$(OBJEXT))
|
||||||
|
|
||||||
SRCS = $(ASRCS) $(CSRCS)
|
SRCS = $(ASRCS) $(CSRCS)
|
||||||
|
|||||||
Reference in New Issue
Block a user