diff --git a/src/drivers/boards/aerocore/CMakeLists.txt b/src/drivers/boards/aerocore/CMakeLists.txt index f1fb63a255..23be262b75 100644 --- a/src/drivers/boards/aerocore/CMakeLists.txt +++ b/src/drivers/boards/aerocore/CMakeLists.txt @@ -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 diff --git a/src/drivers/boards/aerocore/board_config.h b/src/drivers/boards/aerocore/board_config.h index d89b383c62..3046839fb5 100644 --- a/src/drivers/boards/aerocore/board_config.h +++ b/src/drivers/boards/aerocore/board_config.h @@ -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 diff --git a/src/drivers/boards/common/board_name.c b/src/drivers/boards/common/board_name.c new file mode 100644 index 0000000000..8108cec4aa --- /dev/null +++ b/src/drivers/boards/common/board_name.c @@ -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 +#include "board_config.h" +#include + +/************************************************************************************ + * 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; +} diff --git a/src/drivers/boards/mindpx-v2/CMakeLists.txt b/src/drivers/boards/mindpx-v2/CMakeLists.txt index 306c3ab0b0..e64b05469e 100644 --- a/src/drivers/boards/mindpx-v2/CMakeLists.txt +++ b/src/drivers/boards/mindpx-v2/CMakeLists.txt @@ -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 diff --git a/src/drivers/boards/mindpx-v2/board_config.h b/src/drivers/boards/mindpx-v2/board_config.h index b07949e1a6..069b449d60 100644 --- a/src/drivers/boards/mindpx-v2/board_config.h +++ b/src/drivers/boards/mindpx-v2/board_config.h @@ -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 ****************************************************************************************************/ diff --git a/src/drivers/boards/px4-stm32f4discovery/CMakeLists.txt b/src/drivers/boards/px4-stm32f4discovery/CMakeLists.txt index e4af694e5d..ee75158403 100644 --- a/src/drivers/boards/px4-stm32f4discovery/CMakeLists.txt +++ b/src/drivers/boards/px4-stm32f4discovery/CMakeLists.txt @@ -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 diff --git a/src/drivers/boards/px4-stm32f4discovery/board_config.h b/src/drivers/boards/px4-stm32f4discovery/board_config.h index d06a3a317b..5673ecf6b0 100644 --- a/src/drivers/boards/px4-stm32f4discovery/board_config.h +++ b/src/drivers/boards/px4-stm32f4discovery/board_config.h @@ -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 ****************************************************************************************************/ diff --git a/src/drivers/boards/px4fmu-v1/CMakeLists.txt b/src/drivers/boards/px4fmu-v1/CMakeLists.txt index 3402556f4b..c10b3e2b29 100644 --- a/src/drivers/boards/px4fmu-v1/CMakeLists.txt +++ b/src/drivers/boards/px4fmu-v1/CMakeLists.txt @@ -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 diff --git a/src/drivers/boards/px4fmu-v1/board_config.h b/src/drivers/boards/px4fmu-v1/board_config.h index d1e42a8c6f..5ebdb57506 100644 --- a/src/drivers/boards/px4fmu-v1/board_config.h +++ b/src/drivers/boards/px4fmu-v1/board_config.h @@ -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 ****************************************************************************************************/ diff --git a/src/drivers/boards/px4fmu-v2/CMakeLists.txt b/src/drivers/boards/px4fmu-v2/CMakeLists.txt index 7e20979100..fe43efae75 100644 --- a/src/drivers/boards/px4fmu-v2/CMakeLists.txt +++ b/src/drivers/boards/px4fmu-v2/CMakeLists.txt @@ -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 diff --git a/src/drivers/boards/px4fmu-v2/board_config.h b/src/drivers/boards/px4fmu-v2/board_config.h index d0962f13a4..daad230434 100644 --- a/src/drivers/boards/px4fmu-v2/board_config.h +++ b/src/drivers/boards/px4fmu-v2/board_config.h @@ -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 ****************************************************************************************************/ diff --git a/src/drivers/boards/px4fmu-v4/CMakeLists.txt b/src/drivers/boards/px4fmu-v4/CMakeLists.txt index 00b2b41c41..2afe449392 100644 --- a/src/drivers/boards/px4fmu-v4/CMakeLists.txt +++ b/src/drivers/boards/px4fmu-v4/CMakeLists.txt @@ -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 diff --git a/src/drivers/boards/px4fmu-v4/board_config.h b/src/drivers/boards/px4fmu-v4/board_config.h index a375609318..e1871185a1 100644 --- a/src/drivers/boards/px4fmu-v4/board_config.h +++ b/src/drivers/boards/px4fmu-v4/board_config.h @@ -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 ****************************************************************************************************/ diff --git a/src/lib/version/version.h b/src/lib/version/version.h index e20bbc5c3a..6767f1b453 100644 --- a/src/lib/version/version.h +++ b/src/lib/version/version.h @@ -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_ */