mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-04 12:24:11 +01:00
Merge remote-tracking branch 'revo/amorale/revolution' into revolution
This commit is contained in:
commit
c8464848b5
@ -135,9 +135,38 @@ extern uint32_t pios_com_telem_usb_id;
|
|||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
// System Settings
|
// System Settings
|
||||||
|
//
|
||||||
|
// See also System_stm32f4xx.c
|
||||||
//-------------------------
|
//-------------------------
|
||||||
#define PIOS_MASTER_CLOCK 168000000
|
//These macros are deprecated
|
||||||
#define PIOS_PERIPHERAL_CLOCK (PIOS_MASTER_CLOCK / 2)
|
//please use PIOS_PERIPHERAL_APBx_CLOCK According to the table below
|
||||||
|
//#define PIOS_MASTER_CLOCK
|
||||||
|
//#define PIOS_PERIPHERAL_CLOCK
|
||||||
|
//#define PIOS_PERIPHERAL_CLOCK
|
||||||
|
|
||||||
|
#define PIOS_SYSCLK 168000000
|
||||||
|
// Peripherals that belongs to APB1 are:
|
||||||
|
// DAC |PWR |CAN1,2
|
||||||
|
// I2C1,2,3 |UART4,5 |USART3,2
|
||||||
|
// I2S3Ext |SPI3/I2S3 |SPI2/I2S2
|
||||||
|
// I2S2Ext |IWDG |WWDG
|
||||||
|
// RTC/BKP reg
|
||||||
|
// TIM2,3,4,5,6,7,12,13,14
|
||||||
|
|
||||||
|
// Calculated as SYSCLK / APBPresc * (APBPre == 1 ? 1 : 2)
|
||||||
|
// Default APB1 Prescaler = 4
|
||||||
|
#define PIOS_PERIPHERAL_APB1_CLOCK (PIOS_SYSCLK / 2)
|
||||||
|
|
||||||
|
// Peripherals belonging to APB2
|
||||||
|
// SDIO |EXTI |SYSCFG |SPI1
|
||||||
|
// ADC1,2,3
|
||||||
|
// USART1,6
|
||||||
|
// TIM1,8,9,10,11
|
||||||
|
//
|
||||||
|
// Default APB2 Prescaler = 2
|
||||||
|
//
|
||||||
|
#define PIOS_PERIPHERAL_APB2_CLOCK PIOS_SYSCLK
|
||||||
|
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
// Interrupt Priorities
|
// Interrupt Priorities
|
||||||
|
@ -96,7 +96,7 @@ void PIOS_Servo_SetHz(uint16_t * speeds, uint8_t banks)
|
|||||||
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure = servo_cfg->tim_base_init;
|
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure = servo_cfg->tim_base_init;
|
||||||
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
|
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
|
||||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
||||||
TIM_TimeBaseStructure.TIM_Prescaler = (PIOS_MASTER_CLOCK / 1000000) - 1;
|
//
|
||||||
|
|
||||||
uint8_t set = 0;
|
uint8_t set = 0;
|
||||||
|
|
||||||
@ -109,6 +109,14 @@ void PIOS_Servo_SetHz(uint16_t * speeds, uint8_t banks)
|
|||||||
new &= chan->timer != servo_cfg->channels[j].timer;
|
new &= chan->timer != servo_cfg->channels[j].timer;
|
||||||
|
|
||||||
if(new) {
|
if(new) {
|
||||||
|
// Choose the correct prescaler value for the APB the timer is attached
|
||||||
|
if (chan->timer==TIM1 || chan->timer==TIM8 || chan->timer==TIM9 || chan->timer==TIM10 || chan->timer==TIM11 ){
|
||||||
|
TIM_TimeBaseStructure.TIM_Prescaler = (PIOS_PERIPHERAL_APB2_CLOCK / 1000000) - 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
TIM_TimeBaseStructure.TIM_Prescaler = (PIOS_PERIPHERAL_APB1_CLOCK / 1000000) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
TIM_TimeBaseStructure.TIM_Period = ((1000000 / speeds[set]) - 1);
|
TIM_TimeBaseStructure.TIM_Period = ((1000000 / speeds[set]) - 1);
|
||||||
TIM_TimeBaseInit(chan->timer, &TIM_TimeBaseStructure);
|
TIM_TimeBaseInit(chan->timer, &TIM_TimeBaseStructure);
|
||||||
set++;
|
set++;
|
||||||
|
@ -974,8 +974,15 @@ void PIOS_RTC_IRQ_Handler (void)
|
|||||||
|
|
||||||
#include "pios_tim_priv.h"
|
#include "pios_tim_priv.h"
|
||||||
|
|
||||||
static const TIM_TimeBaseInitTypeDef tim_3_5_9_10_11_time_base = {
|
static const TIM_TimeBaseInitTypeDef tim_3_5_time_base = {
|
||||||
.TIM_Prescaler = (PIOS_MASTER_CLOCK / 1000000) - 1,
|
.TIM_Prescaler = (PIOS_PERIPHERAL_APB1_CLOCK / 1000000) - 1,
|
||||||
|
.TIM_ClockDivision = TIM_CKD_DIV1,
|
||||||
|
.TIM_CounterMode = TIM_CounterMode_Up,
|
||||||
|
.TIM_Period = ((1000000 / PIOS_SERVO_UPDATE_HZ) - 1),
|
||||||
|
.TIM_RepetitionCounter = 0x0000,
|
||||||
|
};
|
||||||
|
static const TIM_TimeBaseInitTypeDef tim_9_10_11_time_base = {
|
||||||
|
.TIM_Prescaler = (PIOS_PERIPHERAL_APB2_CLOCK / 1000000) - 1,
|
||||||
.TIM_ClockDivision = TIM_CKD_DIV1,
|
.TIM_ClockDivision = TIM_CKD_DIV1,
|
||||||
.TIM_CounterMode = TIM_CounterMode_Up,
|
.TIM_CounterMode = TIM_CounterMode_Up,
|
||||||
.TIM_Period = ((1000000 / PIOS_SERVO_UPDATE_HZ) - 1),
|
.TIM_Period = ((1000000 / PIOS_SERVO_UPDATE_HZ) - 1),
|
||||||
@ -984,7 +991,7 @@ static const TIM_TimeBaseInitTypeDef tim_3_5_9_10_11_time_base = {
|
|||||||
|
|
||||||
static const struct pios_tim_clock_cfg tim_3_cfg = {
|
static const struct pios_tim_clock_cfg tim_3_cfg = {
|
||||||
.timer = TIM3,
|
.timer = TIM3,
|
||||||
.time_base_init = &tim_3_5_9_10_11_time_base,
|
.time_base_init = &tim_3_5_time_base,
|
||||||
.irq = {
|
.irq = {
|
||||||
.init = {
|
.init = {
|
||||||
.NVIC_IRQChannel = TIM3_IRQn,
|
.NVIC_IRQChannel = TIM3_IRQn,
|
||||||
@ -997,7 +1004,7 @@ static const struct pios_tim_clock_cfg tim_3_cfg = {
|
|||||||
|
|
||||||
static const struct pios_tim_clock_cfg tim_5_cfg = {
|
static const struct pios_tim_clock_cfg tim_5_cfg = {
|
||||||
.timer = TIM5,
|
.timer = TIM5,
|
||||||
.time_base_init = &tim_3_5_9_10_11_time_base,
|
.time_base_init = &tim_3_5_time_base,
|
||||||
.irq = {
|
.irq = {
|
||||||
.init = {
|
.init = {
|
||||||
.NVIC_IRQChannel = TIM5_IRQn,
|
.NVIC_IRQChannel = TIM5_IRQn,
|
||||||
@ -1010,7 +1017,7 @@ static const struct pios_tim_clock_cfg tim_5_cfg = {
|
|||||||
|
|
||||||
static const struct pios_tim_clock_cfg tim_9_cfg = {
|
static const struct pios_tim_clock_cfg tim_9_cfg = {
|
||||||
.timer = TIM9,
|
.timer = TIM9,
|
||||||
.time_base_init = &tim_3_5_9_10_11_time_base,
|
.time_base_init = &tim_9_10_11_time_base,
|
||||||
.irq = {
|
.irq = {
|
||||||
.init = {
|
.init = {
|
||||||
.NVIC_IRQChannel = TIM1_BRK_TIM9_IRQn,
|
.NVIC_IRQChannel = TIM1_BRK_TIM9_IRQn,
|
||||||
@ -1023,7 +1030,7 @@ static const struct pios_tim_clock_cfg tim_9_cfg = {
|
|||||||
|
|
||||||
static const struct pios_tim_clock_cfg tim_10_cfg = {
|
static const struct pios_tim_clock_cfg tim_10_cfg = {
|
||||||
.timer = TIM10,
|
.timer = TIM10,
|
||||||
.time_base_init = &tim_3_5_9_10_11_time_base,
|
.time_base_init = &tim_9_10_11_time_base,
|
||||||
.irq = {
|
.irq = {
|
||||||
.init = {
|
.init = {
|
||||||
.NVIC_IRQChannel = TIM1_UP_TIM10_IRQn,
|
.NVIC_IRQChannel = TIM1_UP_TIM10_IRQn,
|
||||||
@ -1036,7 +1043,7 @@ static const struct pios_tim_clock_cfg tim_10_cfg = {
|
|||||||
|
|
||||||
static const struct pios_tim_clock_cfg tim_11_cfg = {
|
static const struct pios_tim_clock_cfg tim_11_cfg = {
|
||||||
.timer = TIM11,
|
.timer = TIM11,
|
||||||
.time_base_init = &tim_3_5_9_10_11_time_base,
|
.time_base_init = &tim_9_10_11_time_base,
|
||||||
.irq = {
|
.irq = {
|
||||||
.init = {
|
.init = {
|
||||||
.NVIC_IRQChannel = TIM1_TRG_COM_TIM11_IRQn,
|
.NVIC_IRQChannel = TIM1_TRG_COM_TIM11_IRQn,
|
||||||
@ -1047,9 +1054,17 @@ static const struct pios_tim_clock_cfg tim_11_cfg = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// Set up timers that only have inputs
|
// Set up timers that only have inputs on APB2
|
||||||
static const TIM_TimeBaseInitTypeDef tim_1_4_time_base = {
|
static const TIM_TimeBaseInitTypeDef tim_1_time_base = {
|
||||||
.TIM_Prescaler = (PIOS_MASTER_CLOCK / 1000000) - 1,
|
.TIM_Prescaler = (PIOS_PERIPHERAL_APB2_CLOCK / 1000000) - 1,
|
||||||
|
.TIM_ClockDivision = TIM_CKD_DIV1,
|
||||||
|
.TIM_CounterMode = TIM_CounterMode_Up,
|
||||||
|
.TIM_Period = 0xFFFF,
|
||||||
|
.TIM_RepetitionCounter = 0x0000,
|
||||||
|
};
|
||||||
|
// Set up timers that only have inputs on APB2
|
||||||
|
static const TIM_TimeBaseInitTypeDef tim_4_time_base = {
|
||||||
|
.TIM_Prescaler = (PIOS_PERIPHERAL_APB1_CLOCK / 1000000) - 1,
|
||||||
.TIM_ClockDivision = TIM_CKD_DIV1,
|
.TIM_ClockDivision = TIM_CKD_DIV1,
|
||||||
.TIM_CounterMode = TIM_CounterMode_Up,
|
.TIM_CounterMode = TIM_CounterMode_Up,
|
||||||
.TIM_Period = 0xFFFF,
|
.TIM_Period = 0xFFFF,
|
||||||
@ -1058,7 +1073,7 @@ static const TIM_TimeBaseInitTypeDef tim_1_4_time_base = {
|
|||||||
|
|
||||||
static const struct pios_tim_clock_cfg tim_1_cfg = {
|
static const struct pios_tim_clock_cfg tim_1_cfg = {
|
||||||
.timer = TIM1,
|
.timer = TIM1,
|
||||||
.time_base_init = &tim_1_4_time_base,
|
.time_base_init = &tim_1_time_base,
|
||||||
.irq = {
|
.irq = {
|
||||||
.init = {
|
.init = {
|
||||||
.NVIC_IRQChannel = TIM1_CC_IRQn,
|
.NVIC_IRQChannel = TIM1_CC_IRQn,
|
||||||
@ -1071,7 +1086,7 @@ static const struct pios_tim_clock_cfg tim_1_cfg = {
|
|||||||
|
|
||||||
static const struct pios_tim_clock_cfg tim_4_cfg = {
|
static const struct pios_tim_clock_cfg tim_4_cfg = {
|
||||||
.timer = TIM4,
|
.timer = TIM4,
|
||||||
.time_base_init = &tim_1_4_time_base,
|
.time_base_init = &tim_4_time_base,
|
||||||
.irq = {
|
.irq = {
|
||||||
.init = {
|
.init = {
|
||||||
.NVIC_IRQChannel = TIM4_IRQn,
|
.NVIC_IRQChannel = TIM4_IRQn,
|
||||||
@ -1201,7 +1216,7 @@ static const struct pios_tim_channel pios_tim_servoport_all_pins[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
.timer = TIM3,
|
.timer = TIM3,
|
||||||
.timer_chan = TIM_Channel_3,
|
.timer_chan = TIM_Channel_4,
|
||||||
.pin = {
|
.pin = {
|
||||||
.gpio = GPIOB,
|
.gpio = GPIOB,
|
||||||
.init = {
|
.init = {
|
||||||
@ -1363,7 +1378,7 @@ static const struct pios_tim_channel pios_tim_rcvrport_all_channels[] = {
|
|||||||
.GPIO_OType = GPIO_OType_PP,
|
.GPIO_OType = GPIO_OType_PP,
|
||||||
.GPIO_PuPd = GPIO_PuPd_UP
|
.GPIO_PuPd = GPIO_PuPd_UP
|
||||||
},
|
},
|
||||||
.pin_source = GPIO_PinSource1,
|
.pin_source = GPIO_PinSource9,
|
||||||
},
|
},
|
||||||
.remap = GPIO_AF_TIM1,
|
.remap = GPIO_AF_TIM1,
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user