Browse Source

Continuation of extracting peripheral configuration into drivers.

master
Dominic Clifton 11 years ago
parent
commit
32622da0ab
  1. 2
      Makefile
  2. 14
      src/main/config/config.c
  3. 25
      src/main/drivers/accgyro_mma845x.c
  4. 19
      src/main/drivers/adc_stm32f10x.c
  5. 22
      src/main/drivers/adc_stm32f30x.c
  6. 2
      src/main/drivers/barometer_bmp085.c
  7. 2
      src/main/drivers/barometer_ms5611.c
  8. 2
      src/main/drivers/bus_i2c_stm32f30x.c
  9. 2
      src/main/drivers/compass_hmc5883l.c
  10. 86
      src/main/drivers/system.c
  11. 1
      src/main/drivers/system.h
  12. 16
      src/main/drivers/system_stm32f10x.c
  13. 30
      src/main/drivers/system_stm32f30x.c
  14. 64
      src/main/drivers/timer.c
  15. 1
      src/main/platform.h
  16. 3
      src/main/sensors/initialisation.c
  17. 1
      src/main/target/NAZE32PRO/target.h

2
Makefile

@ -242,8 +242,6 @@ STM32F30x_COMMON_SRC = startup_stm32f30x_md_gcc.S \
vcp/usb_pwr.c
NAZE32PRO_SRC = $(STM32F30x_COMMON_SRC) \
drivers/accgyro_mpu6050.c \
drivers/compass_hmc5883l.c \
$(COMMON_SRC)
STM32F3DISCOVERY_COMMON_SRC = $(STM32F30x_COMMON_SRC) \

14
src/main/config/config.c

@ -376,13 +376,21 @@ void validateAndFixConfig(void)
featureSet(FEATURE_RX_PARALLEL_PWM); // Consider changing the default to PPM
}
if (feature(FEATURE_RX_PPM)) {
if (feature(FEATURE_RX_PARALLEL_PWM)) {
featureClear(FEATURE_RX_PARALLEL_PWM);
}
}
if (feature(FEATURE_RX_PARALLEL_PWM)) {
#if defined(NAZE) || defined(OLIMEXINO)
if (feature(FEATURE_RSSI_ADC)) {
featureClear(FEATURE_RSSI_ADC);
}
if (feature(FEATURE_CURRENT_METER)) {
featureClear(FEATURE_CURRENT_METER);
}
#endif
}
if (feature(FEATURE_RX_MSP)) {
@ -406,12 +414,6 @@ void validateAndFixConfig(void)
}
}
if (feature(FEATURE_RX_PPM)) {
if (feature(FEATURE_RX_PARALLEL_PWM)) {
featureClear(FEATURE_RX_PARALLEL_PWM);
}
}
#ifdef SONAR
if (feature(FEATURE_SONAR)) {
// sonar needs a free PWM port

25
src/main/drivers/accgyro_mma845x.c

@ -81,24 +81,37 @@ bool mma8452Detect(acc_t *acc)
return true;
}
static void mma8452Init(void)
static inline void mma8451ConfigureInterrupt(void)
{
#ifdef NAZE
// PA5 - ACC_INT2 output on NAZE rev3/4 hardware
// OLIMEXINO - The PA5 pin is wired up to LED1, if you need to use an mma8452 on an Olimexino use a different pin and provide support in code.
gpio_config_t gpio;
// PA5 - ACC_INT2 output on rev3/4 hardware
// OLIMEXINO - The PA5 pin is wired up to LED1, if you need to use an mma8452 on an Olimexino use a different pin and provide support in code.
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
gpio.pin = Pin_5;
gpio.speed = Speed_2MHz;
gpio.mode = Mode_IN_FLOATING;
gpioInit(GPIOA, &gpio);
#endif
i2cWrite(MMA8452_ADDRESS, MMA8452_CTRL_REG3, MMA8452_CTRL_REG3_IPOL); // Interrupt polarity (active HIGH)
i2cWrite(MMA8452_ADDRESS, MMA8452_CTRL_REG4, MMA8452_CTRL_REG4_INT_EN_DRDY); // Enable DRDY interrupt (unused by this driver)
i2cWrite(MMA8452_ADDRESS, MMA8452_CTRL_REG5, 0); // DRDY routed to INT2
}
static void mma8452Init(void)
{
i2cWrite(MMA8452_ADDRESS, MMA8452_CTRL_REG1, 0); // Put device in standby to configure stuff
i2cWrite(MMA8452_ADDRESS, MMA8452_XYZ_DATA_CFG, MMA8452_FS_RANGE_8G);
i2cWrite(MMA8452_ADDRESS, MMA8452_HP_FILTER_CUTOFF, MMA8452_HPF_CUTOFF_LV4);
i2cWrite(MMA8452_ADDRESS, MMA8452_CTRL_REG2, MMA8452_CTRL_REG2_MODS_HR | MMA8452_CTRL_REG2_MODS_HR << 3); // High resolution measurement in both sleep and active modes
i2cWrite(MMA8452_ADDRESS, MMA8452_CTRL_REG3, MMA8452_CTRL_REG3_IPOL); // Interrupt polarity (active HIGH)
i2cWrite(MMA8452_ADDRESS, MMA8452_CTRL_REG4, MMA8452_CTRL_REG4_INT_EN_DRDY); // Enable DRDY interrupt (unused by this driver)
i2cWrite(MMA8452_ADDRESS, MMA8452_CTRL_REG5, 0); // DRDY routed to INT2
mma8451ConfigureInterrupt();
i2cWrite(MMA8452_ADDRESS, MMA8452_CTRL_REG1, MMA8452_CTRL_REG1_LNOISE | MMA8452_CTRL_REG1_ACTIVE); // Turn on measurements, low noise at max scale mode, Data Rate 800Hz. LNoise mode makes range +-4G.
acc_1G = 256;

19
src/main/drivers/adc_stm32f10x.c

@ -26,11 +26,17 @@ void adcInit(drv_adc_config_t *init)
{
ADC_InitTypeDef adc;
DMA_InitTypeDef dma;
uint8_t i;
GPIO_InitTypeDef GPIO_InitStructure;
uint8_t i;
uint8_t configuredAdcChannels = 0;
memset(&adcConfig, 0, sizeof(adcConfig));
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;
// configure always-present battery index (ADC4)
adcConfig[ADC_BATTERY].adcChannel = ADC_Channel_4;
adcConfig[ADC_BATTERY].dmaIndex = configuredAdcChannels++;
@ -38,6 +44,8 @@ void adcInit(drv_adc_config_t *init)
adcConfig[ADC_BATTERY].sampleTime = ADC_SampleTime_239Cycles5;
if (init->enableRSSI) {
GPIO_InitStructure.GPIO_Pin |= GPIO_Pin_1;
adcConfig[ADC_RSSI].adcChannel = ADC_Channel_1;
adcConfig[ADC_RSSI].dmaIndex = configuredAdcChannels++;
adcConfig[ADC_RSSI].enabled = true;
@ -45,6 +53,8 @@ void adcInit(drv_adc_config_t *init)
}
#ifdef OLIMEXINO
GPIO_InitStructure.GPIO_Pin |= GPIO_Pin_5;
adcConfig[ADC_EXTERNAL1].adcChannel = ADC_Channel_5;
adcConfig[ADC_EXTERNAL1].dmaIndex = configuredAdcChannels++;
adcConfig[ADC_EXTERNAL1].enabled = true;
@ -54,6 +64,8 @@ void adcInit(drv_adc_config_t *init)
#ifdef NAZE
// optional ADC5 input on rev.5 hardware
if (hse_value == 12000000) {
GPIO_InitStructure.GPIO_Pin |= GPIO_Pin_5;
adcConfig[ADC_EXTERNAL1].adcChannel = ADC_Channel_5;
adcConfig[ADC_EXTERNAL1].dmaIndex = configuredAdcChannels++;
adcConfig[ADC_EXTERNAL1].enabled = true;
@ -61,7 +73,12 @@ void adcInit(drv_adc_config_t *init)
}
#endif
GPIO_Init(GPIOA, &GPIO_InitStructure);
if (init->enableCurrentMeter) {
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
GPIO_Init(GPIOB, &GPIO_InitStructure);
adcConfig[ADC_CURRENT].adcChannel = ADC_Channel_9;
adcConfig[ADC_CURRENT].dmaIndex = configuredAdcChannels++;
adcConfig[ADC_CURRENT].enabled = true;

22
src/main/drivers/adc_stm32f30x.c

@ -1,5 +1,6 @@
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include "platform.h"
#include "system.h"
@ -14,7 +15,6 @@
extern adc_config_t adcConfig[ADC_CHANNEL_COUNT];
extern volatile uint16_t adcValues[ADC_CHANNEL_COUNT];
uint8_t adcChannelCount;
void adcInit(drv_adc_config_t *init)
{
@ -23,6 +23,14 @@ void adcInit(drv_adc_config_t *init)
GPIO_InitTypeDef GPIO_InitStructure;
uint8_t i;
uint8_t adcChannelCount = 0;
memset(&adcConfig, 0, sizeof(adcConfig));
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_3;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
adcConfig[ADC_BATTERY].adcChannel = ADC_Channel_6;
adcConfig[ADC_BATTERY].dmaIndex = adcChannelCount;
@ -31,14 +39,19 @@ void adcInit(drv_adc_config_t *init)
adcChannelCount++;
if (init->enableCurrentMeter) {
GPIO_InitStructure.GPIO_Pin |= GPIO_Pin_1;
adcConfig[ADC_CURRENT].adcChannel = ADC_Channel_7;
adcConfig[ADC_CURRENT].dmaIndex = adcChannelCount;
adcConfig[ADC_CURRENT].sampleTime = ADC_SampleTime_601Cycles5;
adcConfig[ADC_CURRENT].enabled = true;
adcChannelCount++;
}
if (init->enableRSSI) {
GPIO_InitStructure.GPIO_Pin |= GPIO_Pin_2;
adcConfig[ADC_RSSI].adcChannel = ADC_Channel_8;
adcConfig[ADC_RSSI].dmaIndex = adcChannelCount;
adcConfig[ADC_RSSI].sampleTime = ADC_SampleTime_601Cycles5;
@ -55,8 +68,6 @@ void adcInit(drv_adc_config_t *init)
RCC_ADCCLKConfig(RCC_ADC12PLLCLK_Div256); // 72 MHz divided by 256 = 281.25 kHz
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1 | RCC_AHBPeriph_ADC12, ENABLE);
// FIXME ADC driver assumes all the GPIO was already placed in 'AIN' mode
DMA_DeInit(DMA1_Channel1);
DMA_StructInit(&DMA_InitStructure);
@ -76,11 +87,6 @@ void adcInit(drv_adc_config_t *init)
DMA_Cmd(DMA1_Channel1, ENABLE);
GPIO_StructInit(&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AN;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
GPIO_Init(GPIOC, &GPIO_InitStructure);
// calibrate

2
src/main/drivers/barometer_bmp085.c

@ -106,6 +106,8 @@ bool bmp085Detect(baro_t *baro)
if (bmp085InitDone)
return true;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
// PC13, PC14 (Barometer XCLR reset output, EOC input)
gpio.pin = Pin_13;
gpio.speed = Speed_2MHz;

2
src/main/drivers/barometer_ms5611.c

@ -50,6 +50,8 @@ bool ms5611Detect(baro_t *baro)
int i;
if (hse_value != 12000000) {
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
// PC13 (BMP085's XCLR reset input, which we use to disable it). Only needed when running at 8MHz
gpio_config_t gpio;
gpio.pin = Pin_13;

2
src/main/drivers/bus_i2c_stm32f30x.c

@ -145,7 +145,7 @@ void i2cInitPort(I2C_TypeDef *I2Cx)
void i2cInit(I2C_TypeDef *I2C)
{
i2cInitPort(I2C1);
i2cInitPort(I2C1); // hard coded to use I2C1 for now
}
uint16_t i2cGetErrorCounter(void)

2
src/main/drivers/compass_hmc5883l.c

@ -115,12 +115,14 @@ void hmc5883lInit(void)
bool bret = true; // Error indicator
if (hse_value == 8000000) {
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);
// PB12 - MAG_DRDY output on rev4 hardware
gpio.pin = Pin_12;
gpio.speed = Speed_2MHz;
gpio.mode = Mode_IN_FLOATING;
gpioInit(GPIOB, &gpio);
} else if (hse_value == 12000000) {
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);
// PC14 - MAG_DRDY output on rev5 hardware
gpio.pin = Pin_14;
gpioInit(GPIOC, &gpio);

86
src/main/drivers/system.c

@ -65,8 +65,6 @@ void systemInit(bool overclock)
SCB->CPACR = (0x3 << (10*2)) | (0x3 << (11*2));
#endif
gpio_config_t gpio;
#ifdef STM32F303xC
SetSysClock();
#endif
@ -79,59 +77,16 @@ void systemInit(bool overclock)
// Configure NVIC preempt/priority groups
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
// Turn on clocks for stuff we use
#ifdef STM32F10X_MD
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2 | RCC_APB1Periph_TIM3 | RCC_APB1Periph_TIM4, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_TIM1, ENABLE);
// Turn on clocks for stuff we use
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE);
#endif
#ifdef STM32F303xC
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2 | RCC_APB1Periph_TIM3 | RCC_APB1Periph_TIM4, ENABLE);
RCC_ClearFlag();
RCC_APB2PeriphClockCmd(
RCC_APB2Periph_TIM1 |
RCC_APB2Periph_TIM8 |
#ifdef CHEBUZZF3
RCC_APB2Periph_TIM15 |
#endif
RCC_APB2Periph_TIM16 |
RCC_APB2Periph_TIM17,
ENABLE
);
RCC_AHBPeriphClockCmd(
RCC_AHBPeriph_GPIOA |
RCC_AHBPeriph_GPIOB |
RCC_AHBPeriph_GPIOC |
RCC_AHBPeriph_GPIOD |
#ifdef CHEBUZZF3
RCC_AHBPeriph_GPIOF |
#endif
RCC_AHBPeriph_GPIOE,
ENABLE
);
#endif
RCC_ClearFlag();
enableGPIOPowerUsageAndNoiseReductions();
// Make all GPIO in by default to save power and reduce noise
gpio.mode = Mode_AIN;
gpio.pin = Pin_All;
#ifdef STM32F303xC
gpio.pin = Pin_All & ~(Pin_13|Pin_14|Pin_15); // Leave JTAG pins alone
gpioInit(GPIOA, &gpio);
gpio.pin = Pin_All;
#else
gpioInit(GPIOA, &gpio);
#endif
gpioInit(GPIOB, &gpio);
gpioInit(GPIOC, &gpio);
#ifdef STM32F303xC
gpioInit(GPIOD, &gpio);
gpioInit(GPIOE, &gpio);
#ifdef CHEBUZZF3
gpioInit(GPIOF, &gpio);
#endif
#endif
#ifdef STM32F10X_MD
// Turn off JTAG port 'cause we're using the GPIO for leds
@ -139,39 +94,6 @@ void systemInit(bool overclock)
AFIO->MAPR |= AFIO_MAPR_SWJ_CFG_NO_JTAG_SW;
#endif
#ifdef STM32F303xC
GPIO_PinAFConfig(GPIOA, GPIO_PinSource8, GPIO_AF_6);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource8, GPIO_AF_1);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource9, GPIO_AF_1);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_4);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_4);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource8, GPIO_AF_4);
#ifdef CHEBUZZF3
GPIO_PinAFConfig(GPIOF, GPIO_PinSource9, GPIO_AF_3);
GPIO_PinAFConfig(GPIOF, GPIO_PinSource10, GPIO_AF_3);
#endif
GPIO_PinAFConfig(GPIOD, GPIO_PinSource12, GPIO_AF_2);
GPIO_PinAFConfig(GPIOD, GPIO_PinSource13, GPIO_AF_2);
GPIO_PinAFConfig(GPIOD, GPIO_PinSource14, GPIO_AF_2);
GPIO_PinAFConfig(GPIOD, GPIO_PinSource15, GPIO_AF_2);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource1, GPIO_AF_1);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_1);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource0, GPIO_AF_2);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource1, GPIO_AF_2);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource4, GPIO_AF_2);
#endif
#ifdef NAZE32PRO
GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_6);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_6);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource4, GPIO_AF_2);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_2);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_2);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource8, GPIO_AF_2);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource9, GPIO_AF_2);
#endif
ledInit();
beeperInit();

1
src/main/drivers/system.h

@ -13,5 +13,6 @@ void failureMode(uint8_t mode);
// bootloader/IAP
void systemReset(bool toBootloader);
void enableGPIOPowerUsageAndNoiseReductions(void);
// current crystal frequency - 8 or 12MHz
extern uint32_t hse_value;

16
src/main/drivers/system_stm32f10x.c

@ -4,6 +4,8 @@
#include "platform.h"
#include "gpio.h"
#define AIRCR_VECTKEY_MASK ((uint32_t)0x05FA0000)
void systemReset(bool toBootloader)
@ -18,3 +20,17 @@ void systemReset(bool toBootloader)
// Generate system reset
SCB->AIRCR = AIRCR_VECTKEY_MASK | (uint32_t)0x04;
}
void enableGPIOPowerUsageAndNoiseReductions(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC, ENABLE);
gpio_config_t gpio;
gpio.mode = Mode_AIN;
gpio.pin = Pin_All;
gpioInit(GPIOA, &gpio);
gpioInit(GPIOB, &gpio);
gpioInit(GPIOC, &gpio);
}

30
src/main/drivers/system_stm32f30x.c

@ -5,6 +5,8 @@
#include "platform.h"
#include "gpio.h"
#define AIRCR_VECTKEY_MASK ((uint32_t)0x05FA0000)
void systemReset(bool toBootloader)
@ -19,3 +21,31 @@ void systemReset(bool toBootloader)
// Generate system reset
SCB->AIRCR = AIRCR_VECTKEY_MASK | (uint32_t)0x04;
}
void enableGPIOPowerUsageAndNoiseReductions(void)
{
RCC_AHBPeriphClockCmd(
RCC_AHBPeriph_GPIOA |
RCC_AHBPeriph_GPIOB |
RCC_AHBPeriph_GPIOC |
RCC_AHBPeriph_GPIOD |
RCC_AHBPeriph_GPIOE |
RCC_AHBPeriph_GPIOF,
ENABLE
);
gpio_config_t gpio;
gpio.mode = Mode_AIN;
gpio.pin = Pin_All & ~(Pin_13|Pin_14|Pin_15); // Leave JTAG pins alone
gpioInit(GPIOA, &gpio);
gpio.pin = Pin_All;
gpioInit(GPIOB, &gpio);
gpioInit(GPIOC, &gpio);
gpioInit(GPIOD, &gpio);
gpioInit(GPIOE, &gpio);
gpioInit(GPIOF, &gpio);
}

64
src/main/drivers/timer.c

@ -75,6 +75,8 @@ static const TIM_TypeDef *timers[MAX_TIMERS] = {
TIM1, TIM2, TIM3, TIM4
};
#define TIMER_APB1_PERIPHERALS (RCC_APB1Periph_TIM2 | RCC_APB1Periph_TIM3 | RCC_APB1Periph_TIM4)
#define TIMER_APB2_PERIPHERALS (RCC_APB2Periph_TIM1 | RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB)
#endif
#if (defined(STM32F303xC) || defined(STM32F3DISCOVERY)) && !(defined(CHEBUZZF3) || defined(NAZE32PRO))
@ -100,6 +102,11 @@ const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = {
static const TIM_TypeDef *timers[MAX_TIMERS] = {
TIM1, TIM2, TIM3, TIM4, TIM8, TIM16, TIM17
};
#define TIMER_APB1_PERIPHERALS (RCC_APB1Periph_TIM2 | RCC_APB1Periph_TIM3 | RCC_APB1Periph_TIM4)
#define TIMER_APB2_PERIPHERALS (RCC_APB2Periph_TIM1 | RCC_APB2Periph_TIM8 | RCC_APB2Periph_TIM16 | RCC_APB2Periph_TIM17)
#define TIMER_AHB_PERIPHERALS (RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB | RCC_AHBPeriph_GPIOC | RCC_AHBPeriph_GPIOD)
#endif
#if defined(CHEBUZZF3)
@ -132,6 +139,11 @@ const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = {
static const TIM_TypeDef *timers[MAX_TIMERS] = {
TIM1, TIM2, TIM3, TIM4, TIM8, TIM15, TIM16, TIM17
};
#define TIMER_APB1_PERIPHERALS (RCC_APB1Periph_TIM2 | RCC_APB1Periph_TIM3 | RCC_APB1Periph_TIM4)
#define TIMER_APB2_PERIPHERALS (RCC_APB2Periph_TIM1 | RCC_APB2Periph_TIM8 | RCC_APB2Periph_TIM15 | RCC_APB2Periph_TIM16 | RCC_APB2Periph_TIM17)
#define TIMER_AHB_PERIPHERALS (RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB | RCC_AHBPeriph_GPIOC | RCC_AHBPeriph_GPIOD | RCC_AHBPeriph_GPIOF)
#endif
#ifdef NAZE32PRO
@ -158,6 +170,11 @@ const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = {
static const TIM_TypeDef *timers[MAX_TIMERS] = {
TIM1, TIM2, TIM3, TIM4, TIM15, TIM16, TIM17
};
#define TIMER_APB1_PERIPHERALS (RCC_APB1Periph_TIM2 | RCC_APB1Periph_TIM3 | RCC_APB1Periph_TIM4)
#define TIMER_APB2_PERIPHERALS (RCC_APB2Periph_TIM1 | RCC_APB2Periph_TIM15 | RCC_APB2Periph_TIM16 | RCC_APB2Periph_TIM17)
#define TIMER_AHB_PERIPHERALS (RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOB)
#endif
@ -363,4 +380,51 @@ void TIM1_TRG_COM_TIM17_IRQHandler(void)
void timerInit(void)
{
memset(timerConfig, 0, sizeof (timerConfig));
#ifdef TIMER_APB1_PERIPHERALS
RCC_APB1PeriphClockCmd(TIMER_APB1_PERIPHERALS, ENABLE);
#endif
#ifdef TIMER_APB2_PERIPHERALS
RCC_APB2PeriphClockCmd(TIMER_APB2_PERIPHERALS, ENABLE);
#endif
#ifdef TIMER_AHB_PERIPHERALS
RCC_AHBPeriphClockCmd(TIMER_AHB_PERIPHERALS, ENABLE);
#endif
#ifdef STM32F303xC
GPIO_PinAFConfig(GPIOA, GPIO_PinSource8, GPIO_AF_6);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource8, GPIO_AF_1);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource9, GPIO_AF_1);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource6, GPIO_AF_4);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource7, GPIO_AF_4);
GPIO_PinAFConfig(GPIOC, GPIO_PinSource8, GPIO_AF_4);
#ifdef CHEBUZZF3
GPIO_PinAFConfig(GPIOF, GPIO_PinSource9, GPIO_AF_3);
GPIO_PinAFConfig(GPIOF, GPIO_PinSource10, GPIO_AF_3);
#endif
GPIO_PinAFConfig(GPIOD, GPIO_PinSource12, GPIO_AF_2);
GPIO_PinAFConfig(GPIOD, GPIO_PinSource13, GPIO_AF_2);
GPIO_PinAFConfig(GPIOD, GPIO_PinSource14, GPIO_AF_2);
GPIO_PinAFConfig(GPIOD, GPIO_PinSource15, GPIO_AF_2);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource1, GPIO_AF_1);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_1);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource0, GPIO_AF_2);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource1, GPIO_AF_2);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource4, GPIO_AF_2);
#endif
#ifdef NAZE32PRO
GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_6);
GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_6);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource4, GPIO_AF_2);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource6, GPIO_AF_2);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource7, GPIO_AF_2);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource8, GPIO_AF_2);
GPIO_PinAFConfig(GPIOB, GPIO_PinSource9, GPIO_AF_2);
#endif
}

1
src/main/platform.h

@ -17,6 +17,7 @@
#ifdef STM32F10X_MD
#include "stm32f10x_conf.h"
#include "stm32f10x_gpio.h"
#include "core_cm3.h"
// Chip Unique ID on F103

3
src/main/sensors/initialisation.c

@ -61,9 +61,11 @@
#undef USE_ACC_BMA280
#undef USE_ACC_MMA8452
#undef USE_ACC_LSM303DLHC
#undef USE_ACC_MPU6050
#undef USE_GYRO_L3G4200D
#undef USE_GYRO_L3GD20
#undef USE_GYRO_MPU3050
#undef USE_GYRO_MPU6050
#endif
#if defined(OLIMEXINO)
@ -244,6 +246,7 @@ retry:
break;
}
#endif
;
}
// Found anything? Check if user fucked up or ACC is really missing.

1
src/main/target/NAZE32PRO/target.h

@ -10,6 +10,5 @@
#define GYRO
#define ACC
#define MAG
#define SENSORS_SET (SENSOR_ACC)
Loading…
Cancel
Save