mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +01:00
PIOS_SYS now non-application specific.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@208 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
792cfef50b
commit
9953188fe2
@ -93,7 +93,7 @@
|
||||
#define PIOS_USART1_IRQ_CHANNEL USART2_IRQn
|
||||
#define PIOS_USART1_IRQHANDLER_FUNC void USART2_IRQHandler(void)
|
||||
#define PIOS_USART1_CLK_FUNC RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE)
|
||||
#define PIOS_USART1_NVIC_PRIO IRQ_PRIO_HIGHEST
|
||||
#define PIOS_USART1_NVIC_PRIO PIOS_IRQ_PRIO_HIGHEST
|
||||
#define PIOS_USART1_BAUDRATE 57600
|
||||
|
||||
//-------------------------
|
||||
@ -108,7 +108,7 @@
|
||||
#define PIOS_USART2_IRQ_CHANNEL USART3_IRQn
|
||||
#define PIOS_USART2_IRQHANDLER_FUNC void USART3_IRQHandler(void)
|
||||
#define PIOS_USART2_CLK_FUNC RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE)
|
||||
#define PIOS_USART2_NVIC_PRIO IRQ_PRIO_HIGHEST
|
||||
#define PIOS_USART2_NVIC_PRIO PIOS_IRQ_PRIO_HIGHEST
|
||||
#define PIOS_USART2_BAUDRATE 57600
|
||||
|
||||
//-------------------------
|
||||
@ -123,7 +123,7 @@
|
||||
#define PIOS_USART3_IRQ_CHANNEL USART1_IRQn
|
||||
#define PIOS_USART3_IRQHANDLER_FUNC void USART1_IRQHandler(void)
|
||||
#define PIOS_USART3_CLK_FUNC RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE)
|
||||
#define PIOS_USART3_NVIC_PRIO IRQ_PRIO_HIGH
|
||||
#define PIOS_USART3_NVIC_PRIO PIOS_IRQ_PRIO_HIGH
|
||||
#define PIOS_USART3_BAUDRATE 57600
|
||||
|
||||
//-------------------------
|
||||
@ -137,7 +137,7 @@
|
||||
//-------------------------
|
||||
// SPI
|
||||
//-------------------------
|
||||
#define PIOS_SPI_IRQ_DMA_PRIORITY IRQ_PRIO_HIGH
|
||||
#define PIOS_SPI_IRQ_DMA_PRIORITY PIOS_IRQ_PRIO_HIGH
|
||||
#define PIOS_SPI_NUM 2
|
||||
#define PIOS_SPI0_ENABLED 1
|
||||
#define PIOS_SPI0_PTR SPI1
|
||||
@ -175,6 +175,26 @@
|
||||
//-------------------------
|
||||
#define PIOS_SDCARD_SPI 0
|
||||
|
||||
//-------------------------
|
||||
// Delay Timer
|
||||
//-------------------------
|
||||
#define PIOS_DELAY_TIMER TIM2
|
||||
#define PIOS_DELAY_TIMER_RCC RCC_APB1Periph_TIM2
|
||||
|
||||
//-------------------------
|
||||
// Master Clock
|
||||
//-------------------------
|
||||
#define PIOS_MASTER_CLOCK 72000000
|
||||
#define PIOS_PERIPHERAL_CLOCK (PIOS_MASTER_CLOCK / 2)
|
||||
|
||||
//-------------------------
|
||||
// Interrupt Priorities
|
||||
//-------------------------
|
||||
#define PIOS_IRQ_PRIO_LOW 12 // lower than RTOS
|
||||
#define PIOS_IRQ_PRIO_MID 8 // higher than RTOS
|
||||
#define PIOS_IRQ_PRIO_HIGH 5 // for SPI, ADC, I2C etc...
|
||||
#define PIOS_IRQ_PRIO_HIGHEST 4 // for USART etc...
|
||||
|
||||
//-------------------------
|
||||
// Receiver PWM inputs
|
||||
//-------------------------
|
||||
@ -210,7 +230,6 @@
|
||||
#define RECEIVER8_PIN GPIO_Pin_5 // PB5
|
||||
#define RECEIVER8_TIM_PORT TIM3
|
||||
#define RECEIVER8_CH TIM_Channel_2 // TIM3_CH2
|
||||
|
||||
#define NUM_RECEIVER_INPUTS 6
|
||||
|
||||
//-------------------------
|
||||
@ -239,33 +258,14 @@
|
||||
#define ADC_A_CHANNEL ADC_Channel_11
|
||||
#define ADC_B_CHANNEL ADC_Channel_12
|
||||
#define NUM_ADC_PINS 4 // 3 but actually 4 because of temp sensor
|
||||
#define ADC_IRQ_PRIO IRQ_PRIO_HIGH
|
||||
#define ADC_IRQ_PRIO PIOS_IRQ_PRIO_HIGH
|
||||
|
||||
//-------------------------
|
||||
// USB
|
||||
//-------------------------
|
||||
#define USB_ACC_GPIO_PORT GPIOC
|
||||
#define USB_DETECT_PIN GPIO_Pin_4
|
||||
#define PIOS_IRQ_USB_PRIORITY IRQ_PRIO_MID
|
||||
|
||||
//-------------------------
|
||||
// Delay Timer
|
||||
//-------------------------
|
||||
#define PIOS_DELAY_TIMER TIM2
|
||||
#define PIOS_DELAY_TIMER_RCC RCC_APB1Periph_TIM2
|
||||
|
||||
//-------------------------
|
||||
// Master Clock
|
||||
//-------------------------
|
||||
#define MASTER_CLOCK 72000000
|
||||
#define PERIPHERAL_CLOCK (MASTER_CLOCK/2)
|
||||
|
||||
//-------------------------
|
||||
// Interrupt Priorities
|
||||
//-------------------------
|
||||
#define IRQ_PRIO_LOW 12 // lower than RTOS
|
||||
#define IRQ_PRIO_MID 8 // higher than RTOS
|
||||
#define IRQ_PRIO_HIGH 5 // for SPI, ADC, I2C etc...
|
||||
#define IRQ_PRIO_HIGHEST 4 // for USART etc...
|
||||
#define PIOS_USB_ENABLED 1
|
||||
#define PIOS_USB_DETECT_GPIO_PORT GPIOC
|
||||
#define PIOS_USB_DETECT_GPIO_PIN GPIO_Pin_4
|
||||
#define PIOS_IRQ_USB_PRIORITY PIOS_IRQ_PRIO_MID
|
||||
|
||||
#endif /* PIOS_BOARD_H */
|
||||
|
@ -62,7 +62,7 @@ void PIOS_Servo_Init(void)
|
||||
/* With a resolution of 1uS, period of 20mS (50Hz) */
|
||||
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
|
||||
TIM_TimeBaseStructInit(&TIM_TimeBaseStructure);
|
||||
TIM_TimeBaseStructure.TIM_Prescaler = (MASTER_CLOCK / 1000000) - 1;
|
||||
TIM_TimeBaseStructure.TIM_Prescaler = (PIOS_MASTER_CLOCK / 1000000) - 1;
|
||||
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
|
||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
||||
|
||||
|
@ -41,7 +41,7 @@ void SysTick_Handler(void);
|
||||
#define MEM8(addr) (*((volatile uint8_t *)(addr)))
|
||||
|
||||
/**
|
||||
* Initializes all system peripherals
|
||||
* Initialises all system peripherals
|
||||
*/
|
||||
void PIOS_SYS_Init(void)
|
||||
{
|
||||
@ -49,29 +49,31 @@ void PIOS_SYS_Init(void)
|
||||
SystemInit();
|
||||
|
||||
/* Enable GPIOA, GPIOB, GPIOC, GPIOD, GPIOE and AFIO clocks */
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC
|
||||
| RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_AFIO, ENABLE);
|
||||
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_AFIO, ENABLE);
|
||||
|
||||
/* Activate pull-ups on all pins by default */
|
||||
GPIO_InitTypeDef GPIO_InitStructure;
|
||||
GPIO_StructInit(&GPIO_InitStructure);
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
|
||||
GPIO_InitStructure.GPIO_Pin = 0xffff & ~GPIO_Pin_11 & ~GPIO_Pin_12; /* Exclude USB pins */
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
|
||||
GPIO_InitStructure.GPIO_Pin = 0xffff;
|
||||
GPIO_Init(GPIOB, &GPIO_InitStructure);
|
||||
GPIO_Init(GPIOD, &GPIO_InitStructure);
|
||||
#if (PIOS_USB_ENABLED)
|
||||
GPIO_InitStructure.GPIO_Pin = 0xffff & ~GPIO_Pin_11 & ~GPIO_Pin_12; /* Exclude USB pins */
|
||||
#endif
|
||||
GPIO_Init(GPIOA, &GPIO_InitStructure);
|
||||
|
||||
#if (PIOS_USB_ENABLED)
|
||||
/* Ensure that pull-up is active on detect pin */
|
||||
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
|
||||
GPIO_InitStructure.GPIO_Pin = USB_DETECT_PIN;
|
||||
GPIO_Init(USB_ACC_GPIO_PORT, &GPIO_InitStructure);
|
||||
GPIO_InitStructure.GPIO_Pin = PIOS_USB_DETECT_GPIO_PIN;
|
||||
GPIO_Init(PIOS_USB_DETECT_GPIO_PORT, &GPIO_InitStructure);
|
||||
#endif
|
||||
|
||||
/* Initialize Basic NVIC */
|
||||
/* Initialise Basic NVIC */
|
||||
NVIC_Configuration();
|
||||
|
||||
/* Initialize LEDs */
|
||||
/* Initialise LEDs */
|
||||
PIOS_LED_Init();
|
||||
}
|
||||
|
||||
@ -108,14 +110,14 @@ void NVIC_Configuration(void)
|
||||
/* Set the Vector Table base address as specified in .ld file */
|
||||
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
|
||||
|
||||
/* 4 bits for Interupt priorities so no sub priorities */
|
||||
/* 4 bits for Interrupt priorities so no sub priorities */
|
||||
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
|
||||
|
||||
/* Configure HCLK clock as SysTick clock source. */
|
||||
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);
|
||||
}
|
||||
|
||||
#ifdef USE_FULL_ASSERT
|
||||
#ifdef USE_FULL_ASSERT
|
||||
/**
|
||||
* Reports the name of the source file and the source line number
|
||||
* where the assert_param error has occurred.
|
||||
|
@ -374,7 +374,7 @@ int32_t PIOS_USB_IsInitialized(void)
|
||||
*/
|
||||
int32_t PIOS_USB_CableConnected(void)
|
||||
{
|
||||
return GPIO_ReadInputDataBit(USB_ACC_GPIO_PORT, USB_DETECT_PIN);
|
||||
return GPIO_ReadInputDataBit(PIOS_USB_DETECT_GPIO_PORT, PIOS_USB_DETECT_GPIO_PIN);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user