From ff0f4e66a9edce6cc3ec48f615be4bcce5ec094f Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Thu, 17 Apr 2014 11:56:03 +0100 Subject: [PATCH] Update altimeter drivers so they do not include "board.h". It is now clear what all altimeter drivers need to compile and what was unnecessarily included before. Moved some platform specific configuration from board.h into platform.h --- src/board.h | 79 +--------------------------------- src/drivers/altimeter_bmp085.c | 11 ++++- src/drivers/altimeter_common.h | 15 +++++++ src/drivers/altimeter_ms5611.c | 11 ++++- src/platform.h | 66 ++++++++++++++++++++++++++++ 5 files changed, 103 insertions(+), 79 deletions(-) create mode 100644 src/drivers/altimeter_common.h diff --git a/src/board.h b/src/board.h index 88ec985c9d..8468ac51df 100755 --- a/src/board.h +++ b/src/board.h @@ -19,6 +19,7 @@ #include "drivers/accgyro_common.h" #include "drivers/gpio_common.h" #include "drivers/system_common.h" +#include "drivers/altimeter_common.h" #include "sensors_common.h" typedef enum { @@ -113,86 +114,10 @@ typedef struct sensor_data_t int updated; } sensor_data_t; -typedef void (* baroOpFuncPtr)(void); // baro start operation -typedef void (* baroCalculateFuncPtr)(int32_t *pressure, int32_t *temperature); // baro calculation (filled params are pressure and temperature) typedef uint16_t (* rcReadRawDataPtr)(uint8_t chan); // used by receiver driver to return channel data typedef void (* pidControllerFuncPtr)(void); // pid controller function prototype -typedef struct baro_t -{ - uint16_t ut_delay; - uint16_t up_delay; - baroOpFuncPtr start_ut; - baroOpFuncPtr get_ut; - baroOpFuncPtr start_up; - baroOpFuncPtr get_up; - baroCalculateFuncPtr calculate; -} baro_t; - -// Hardware definitions and GPIO -#ifdef FY90Q - // FY90Q -#define LED0_GPIO GPIOC -#define LED0_PIN Pin_12 -#define LED1_GPIO GPIOA -#define LED1_PIN Pin_15 - -#define GYRO -#define ACC -#define LED0 -#define LED1 - -#define SENSORS_SET (SENSOR_ACC) - -#else - -#ifdef OLIMEXINO -// OLIMEXINO - -#ifdef OLIMEXINO_UNCUT_LED2_E_JUMPER -// LED2 is using one of the pwm pins (PWM2), so we must not use PWM2. @See pwmInit() -#define LED0_GPIO GPIOA -#define LED0_PIN Pin_1 // D3, PA1/USART2_RTS/ADC1/TIM2_CH3 - "LED2" on silkscreen, Yellow -#define LED0 -#endif - -#ifdef OLIMEXINO_UNCUT_LED1_E_JUMPER -#define LED1_GPIO GPIOA -#define LED1_PIN Pin_5 // D13, PA5/SPI1_SCK/ADC5 - "LED1" on silkscreen, Green -#define LED1 -#endif - -#define GYRO -#define ACC - -#define SENSORS_SET (SENSOR_ACC) - -#else -// Afroflight32 - -#define LED0_GPIO GPIOB -#define LED0_PIN Pin_3 // PB3 (LED) -#define LED1_GPIO GPIOB -#define LED1_PIN Pin_4 // PB4 (LED) -#define BEEP_GPIO GPIOA -#define BEEP_PIN Pin_12 // PA12 (Buzzer) -#define BARO_GPIO GPIOC -#define BARO_PIN Pin_13 - -#define GYRO -#define ACC -#define MAG -#define BARO -#define LEDRING -#define SONAR -#define BUZZER -#define LED0 -#define LED1 - -#define SENSORS_SET (SENSOR_ACC | SENSOR_BARO | SENSOR_MAG) - -#endif -#endif +#include "platform.h" // Helpful macros #ifdef LED0 diff --git a/src/drivers/altimeter_bmp085.c b/src/drivers/altimeter_bmp085.c index 2fd7a45a22..2493019965 100755 --- a/src/drivers/altimeter_bmp085.c +++ b/src/drivers/altimeter_bmp085.c @@ -1,4 +1,13 @@ -#include "board.h" +#include +#include + +#include + +#include "altimeter_common.h" + +#include "gpio_common.h" +#include "system_common.h" +#include "bus_i2c.h" // BMP085, Standard address 0x77 static bool convDone = false; diff --git a/src/drivers/altimeter_common.h b/src/drivers/altimeter_common.h new file mode 100644 index 0000000000..924f4194b8 --- /dev/null +++ b/src/drivers/altimeter_common.h @@ -0,0 +1,15 @@ +#pragma once + +typedef void (* baroOpFuncPtr)(void); // baro start operation +typedef void (* baroCalculateFuncPtr)(int32_t *pressure, int32_t *temperature); // baro calculation (filled params are pressure and temperature) + +typedef struct baro_t +{ + uint16_t ut_delay; + uint16_t up_delay; + baroOpFuncPtr start_ut; + baroOpFuncPtr get_ut; + baroOpFuncPtr start_up; + baroOpFuncPtr get_up; + baroCalculateFuncPtr calculate; +} baro_t; diff --git a/src/drivers/altimeter_ms5611.c b/src/drivers/altimeter_ms5611.c index 42cd3bb145..a0828df77a 100644 --- a/src/drivers/altimeter_ms5611.c +++ b/src/drivers/altimeter_ms5611.c @@ -1,4 +1,13 @@ -#include "board.h" +#include +#include + +#include + +#include "altimeter_common.h" + +#include "gpio_common.h" +#include "system_common.h" +#include "bus_i2c.h" // MS5611, Standard address 0x77 #define MS5611_ADDR 0x77 diff --git a/src/platform.h b/src/platform.h index f068ec6f53..6251520925 100644 --- a/src/platform.h +++ b/src/platform.h @@ -8,3 +8,69 @@ #define U_ID_0 (*(uint32_t*)0x1FFFF7E8) #define U_ID_1 (*(uint32_t*)0x1FFFF7EC) #define U_ID_2 (*(uint32_t*)0x1FFFF7F0) + + +// Hardware definitions and GPIO +#ifdef FY90Q + // FY90Q +#define LED0_GPIO GPIOC +#define LED0_PIN Pin_12 +#define LED1_GPIO GPIOA +#define LED1_PIN Pin_15 + +#define GYRO +#define ACC +#define LED0 +#define LED1 + +#define SENSORS_SET (SENSOR_ACC) + +#else + +#ifdef OLIMEXINO +// OLIMEXINO + +#ifdef OLIMEXINO_UNCUT_LED2_E_JUMPER +// LED2 is using one of the pwm pins (PWM2), so we must not use PWM2. @See pwmInit() +#define LED0_GPIO GPIOA +#define LED0_PIN Pin_1 // D3, PA1/USART2_RTS/ADC1/TIM2_CH3 - "LED2" on silkscreen, Yellow +#define LED0 +#endif + +#ifdef OLIMEXINO_UNCUT_LED1_E_JUMPER +#define LED1_GPIO GPIOA +#define LED1_PIN Pin_5 // D13, PA5/SPI1_SCK/ADC5 - "LED1" on silkscreen, Green +#define LED1 +#endif + +#define GYRO +#define ACC + +#define SENSORS_SET (SENSOR_ACC) + +#else +// Afroflight32 + +#define LED0_GPIO GPIOB +#define LED0_PIN Pin_3 // PB3 (LED) +#define LED1_GPIO GPIOB +#define LED1_PIN Pin_4 // PB4 (LED) +#define BEEP_GPIO GPIOA +#define BEEP_PIN Pin_12 // PA12 (Buzzer) +#define BARO_GPIO GPIOC +#define BARO_PIN Pin_13 + +#define GYRO +#define ACC +#define MAG +#define BARO +#define LEDRING +#define SONAR +#define BUZZER +#define LED0 +#define LED1 + +#define SENSORS_SET (SENSOR_ACC | SENSOR_BARO | SENSOR_MAG) + +#endif +#endif