Decouple board name

This commit is contained in:
David Sidrane
2016-05-21 10:48:15 +02:00
committed by Lorenz Meier
parent 7badf645b3
commit 1b77ec7f82
14 changed files with 110 additions and 38 deletions
@@ -35,6 +35,7 @@ px4_add_module(
COMPILE_FLAGS
-Os
SRCS
../common/board_name.c
aerocore_init.c
aerocore_pwm_servo.c
aerocore_spi.c
@@ -172,6 +172,7 @@ __BEGIN_DECLS
#define GPIO_TONE_ALARM_IDLE (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTA|GPIO_PIN0)
#define GPIO_TONE_ALARM (GPIO_ALT|GPIO_AF1|GPIO_SPEED_2MHz|GPIO_PUSHPULL|GPIO_PORTA|GPIO_PIN0)
#define BOARD_NAME "AEROCORE"
/****************************************************************************************************
* Public Types
+71
View File
@@ -0,0 +1,71 @@
/****************************************************************************
*
* Copyright (C) 2016 PX4 Development Team. All rights reserved.
*
* 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 PX4 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.
*
****************************************************************************/
/**
* @file board_name.c
*
* Provide the board_name interface.
*/
/************************************************************************************
* Included Files
************************************************************************************/
#include <px4_config.h>
#include "board_config.h"
#include <lib/version/version.h>
/************************************************************************************
* Definitions
************************************************************************************/
/************************************************************************************
* Private Functions
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
/************************************************************************************
* Name: board_name
*
* Description:
* All boards must provide this API to return the board name.
*
************************************************************************************/
__EXPORT const char *board_name()
{
return BOARD_NAME;
}
@@ -35,6 +35,7 @@ px4_add_module(
COMPILE_FLAGS
-Os
SRCS
../common/board_name.c
mindpx_can.c
mindpx2_init.c
mindpx_timer_config.c
@@ -290,6 +290,8 @@ __BEGIN_DECLS
#define PWMIN_TIMER_CHANNEL 1
#define GPIO_PWM_IN GPIO_TIM3_CH1IN_3
#define BOARD_NAME "MINDPX_V2"
/****************************************************************************************************
* Public Types
****************************************************************************************************/
@@ -33,6 +33,7 @@
px4_add_module(
MODULE drivers__boards__px4-stm32f4discovery
SRCS
../common/board_name.c
px4discovery_init.c
px4discovery_usb.c
px4discovery_led.c
@@ -87,6 +87,8 @@ __BEGIN_DECLS
#define HRT_TIMER 8 /* use timer8 for the HRT */
#define HRT_TIMER_CHANNEL 1 /* use capture/compare channel */
#define BOARD_NAME "PX4_STM32F4DISCOVERY"
/****************************************************************************************************
* Public Types
****************************************************************************************************/
@@ -35,6 +35,7 @@ px4_add_module(
COMPILE_FLAGS
-Os
SRCS
../common/board_name.c
px4fmu_can.c
px4fmu_init.c
px4fmu_timer_config.c
@@ -203,6 +203,9 @@ __BEGIN_DECLS
#define HRT_PPM_CHANNEL 3 /* use capture/compare channel 3 */
#define GPIO_PPM_IN (GPIO_ALT|GPIO_AF1|GPIO_PULLUP|GPIO_PORTA|GPIO_PIN10)
#define BOARD_NAME "PX4FMU_V1"
/****************************************************************************************************
* Public Types
****************************************************************************************************/
@@ -35,6 +35,7 @@ px4_add_module(
COMPILE_FLAGS
-Os
SRCS
../common/board_name.c
px4fmu_can.c
px4fmu2_init.c
px4fmu_timer_config.c
@@ -242,6 +242,8 @@ __BEGIN_DECLS
#define PWMIN_TIMER_CHANNEL 2
#define GPIO_PWM_IN GPIO_TIM4_CH2IN_2
#define BOARD_NAME "PX4FMU_V2"
/****************************************************************************************************
* Public Types
****************************************************************************************************/
@@ -35,6 +35,7 @@ px4_add_module(
COMPILE_FLAGS
-Os
SRCS
../common/board_name.c
px4fmu_can.c
px4fmu_init.c
px4fmu_timer_config.c
@@ -272,6 +272,9 @@ __BEGIN_DECLS
#define SPEKTRUM_RX_AS_GPIO() stm32_configgpio(GPIO_RC_OUT)
#define SPEKTRUM_RX_HIGH(_s) stm32_gpiowrite(GPIO_RC_OUT, (_s))
#define BOARD_NAME "PX4FMU_V4"
/****************************************************************************************************
* Public Types
****************************************************************************************************/
+20 -38
View File
@@ -43,44 +43,26 @@
#ifndef VERSION_H_
#define VERSION_H_
#ifdef CONFIG_ARCH_BOARD_PX4FMU_V1
#define HW_ARCH "PX4FMU_V1"
/* The preferred method for publishing a board name up is to
* provide board_name()
*
*/
__BEGIN_DECLS
__EXPORT const char *board_name(void);
__END_DECLS
#if defined(CONFIG_ARCH_BOARD_SITL)
# define HW_ARCH "LINUXTEST"
#elif defined(CONFIG_ARCH_BOARD_EAGLE)
# define HW_ARCH "LINUXTEST"
#elif defined(CONFIG_ARCH_BOARD_EXCELSIOR)
# define HW_ARCH "LINUXTEST"
#elif defined(CONFIG_ARCH_BOARD_RPI2)
# define HW_ARCH "LINUXTEST"
#else
#define HW_ARCH (board_name())
#endif
#ifdef CONFIG_ARCH_BOARD_PX4FMU_V2
#define HW_ARCH "PX4FMU_V2"
#endif
#ifdef CONFIG_ARCH_BOARD_PX4FMU_V4
#define HW_ARCH "PX4FMU_V4"
#endif
#ifdef CONFIG_ARCH_BOARD_AEROCORE
#define HW_ARCH "AEROCORE"
#endif
#ifdef CONFIG_ARCH_BOARD_MINDPX_V2
#define HW_ARCH "MINDPX_V2"
#endif
#ifdef CONFIG_ARCH_BOARD_PX4_STM32F4DISCOVERY
#define HW_ARCH "PX4_STM32F4DISCOVERY"
#endif
#ifdef CONFIG_ARCH_BOARD_SITL
#define HW_ARCH "LINUXTEST"
#endif
#ifdef CONFIG_ARCH_BOARD_EAGLE
#define HW_ARCH "LINUXTEST"
#endif
#ifdef CONFIG_ARCH_BOARD_EXCELSIOR
#define HW_ARCH "LINUXTEST"
#endif
#ifdef CONFIG_ARCH_BOARD_RPI2
#define HW_ARCH "LINUXTEST"
#endif
#endif /* VERSION_H_ */