35 #if defined(PIOS_INCLUDE_SYS)
38 void NVIC_Configuration(
void);
39 void SysTick_Handler(
void);
42 #define MEM8(addr) (*((volatile uint8_t *)(addr)))
43 #define MEM16(addr) (*((volatile uint16_t *)(addr)))
44 #define MEM32(addr) (*((volatile uint32_t *)(addr)))
51 PWR_PVDLevelConfig(PWR_PVDLevel_7);
55 while (PWR_GetFlagStatus(PWR_FLAG_PVDO) == SET);
57 #if !defined(PIOS_INCLUDE_CHIBIOS)
73 SCB->SHCSR |= SCB_SHCSR_USGFAULTENA_Msk | SCB_SHCSR_BUSFAULTENA_Msk | SCB_SHCSR_MEMFAULTENA_Msk;
83 RCC_AHB1PeriphClockCmd(
84 RCC_AHB1Periph_GPIOA |
85 RCC_AHB1Periph_GPIOB |
86 RCC_AHB1Periph_GPIOC |
87 RCC_AHB1Periph_GPIOD |
88 RCC_AHB1Periph_GPIOE |
89 RCC_AHB1Periph_GPIOF |
90 RCC_AHB1Periph_GPIOG |
91 RCC_AHB1Periph_GPIOH |
92 RCC_AHB1Periph_GPIOI |
94 RCC_AHB1Periph_FLITF |
95 RCC_AHB1Periph_SRAM1 |
96 RCC_AHB1Periph_SRAM2 |
97 RCC_AHB1Periph_BKPSRAM |
107 RCC_AHB2PeriphClockCmd(
114 RCC_AHB3PeriphClockCmd(
117 RCC_APB1PeriphClockCmd(
118 RCC_APB1Periph_TIM2 |
119 RCC_APB1Periph_TIM3 |
120 RCC_APB1Periph_TIM4 |
121 RCC_APB1Periph_TIM5 |
122 RCC_APB1Periph_TIM6 |
123 RCC_APB1Periph_TIM7 |
124 RCC_APB1Periph_TIM12 |
125 RCC_APB1Periph_TIM13 |
126 RCC_APB1Periph_TIM14 |
127 RCC_APB1Periph_WWDG |
128 RCC_APB1Periph_SPI2 |
129 RCC_APB1Periph_SPI3 |
130 RCC_APB1Periph_USART2 |
131 RCC_APB1Periph_USART3 |
132 RCC_APB1Periph_UART4 |
133 RCC_APB1Periph_UART5 |
134 RCC_APB1Periph_I2C1 |
135 RCC_APB1Periph_I2C2 |
136 RCC_APB1Periph_I2C3 |
137 RCC_APB1Periph_CAN1 |
138 RCC_APB1Periph_CAN2 |
143 RCC_APB2PeriphClockCmd(
144 RCC_APB2Periph_TIM1 |
145 RCC_APB2Periph_TIM8 |
146 RCC_APB2Periph_USART1 |
147 RCC_APB2Periph_USART6 |
149 RCC_APB2Periph_ADC1 |
150 RCC_APB2Periph_ADC2 |
151 RCC_APB2Periph_ADC3 |
152 RCC_APB2Periph_SDIO |
153 RCC_APB2Periph_SPI1 |
154 RCC_APB2Periph_SYSCFG |
155 RCC_APB2Periph_TIM9 |
156 RCC_APB2Periph_TIM10 |
157 RCC_APB2Periph_TIM11 |
165 GPIO_InitTypeDef GPIO_InitStructure;
166 GPIO_StructInit(&GPIO_InitStructure);
167 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
169 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
170 #if (PIOS_USB_ENABLED)
171 GPIO_InitStructure.GPIO_Pin &= ~(GPIO_Pin_11 | GPIO_Pin_12);
173 GPIO_InitStructure.GPIO_Pin &= ~(GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15);
174 GPIO_Init(GPIOA, &GPIO_InitStructure);
176 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
177 GPIO_Init(GPIOB, &GPIO_InitStructure);
178 GPIO_Init(GPIOC, &GPIO_InitStructure);
179 GPIO_Init(GPIOD, &GPIO_InitStructure);
180 GPIO_Init(GPIOE, &GPIO_InitStructure);
181 GPIO_Init(GPIOF, &GPIO_InitStructure);
182 GPIO_Init(GPIOG, &GPIO_InitStructure);
183 #if !defined(STM32F446xx)
184 GPIO_Init(GPIOH, &GPIO_InitStructure);
185 GPIO_Init(GPIOI, &GPIO_InitStructure);
205 #ifdef PIOS_INCLUDE_ANNUNC
206 #if defined(PIOS_LED_HEARTBEAT)
209 #if defined(PIOS_LED_ALARM)
237 uint8_t b = MEM8(0x1fff7a10 + i);
258 uint8_t b = MEM8(0x1fff7a10 + (i / 2));
263 str[
i] = ((b > 9) ? (
'A' - 10) :
'0') + b;
271 static inline size_t unused_mem(uint32_t *top, uint32_t *bot, uint32_t pattern)
274 for (; p < top && *p == pattern; p++);
275 return (p - bot) *
sizeof(uint32_t);
278 #ifdef PIOS_INCLUDE_CHIBIOS
280 #if !defined(CRT0_STACKS_FILL_PATTERN)
281 #define CRT0_STACKS_FILL_PATTERN 0x55555555
284 extern uint32_t __main_stack_base__;
285 extern uint32_t __main_stack_end__;
286 extern uint32_t __process_stack_base__;
287 extern uint32_t __process_stack_end__;
291 return unused_mem(&__main_stack_end__, &__main_stack_base__,
292 CRT0_STACKS_FILL_PATTERN);
297 return unused_mem(&__process_stack_end__, &__process_stack_base__,
298 CRT0_STACKS_FILL_PATTERN);
304 extern uint32_t _irq_stack_end;
305 extern uint32_t _irq_stack_top;
309 return unused_mem(&_irq_stack_top, &_irq_stack_end, 0xa5a5a5a5);
322 void NVIC_Configuration(
void)
325 extern void *pios_isr_vector_table_base;
326 NVIC_SetVectorTable((uint32_t)&pios_isr_vector_table_base, 0x0);
329 NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
332 SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);
335 #ifdef USE_FULL_ASSERT
343 void assert_failed(uint8_t * file, uint32_t line)
349 #if defined(PIOS_LED_HEARTBEAT)
352 #if defined(PIOS_LED_ALARM)
358 #if defined(PIOS_LED_HEARTBEAT)
361 #if defined(PIOS_LED_ALARM)
364 for (
int i = 0; i < 1000000; i++) ;
Main PiOS header to include all the compiled in PiOS options.
void SystemCoreClockUpdate(void)
Update SystemCoreClock variable according to Clock Register Values. The SystemCoreClock variable cont...
#define PIOS_SYS_SERIAL_NUM_BINARY_LEN
int32_t PIOS_DELAY_Init(void)
void PIOS_ANNUNC_Off(uint32_t annunc_id)
void SystemInit(void)
Setup the microcontroller system Initialize the Embedded Flash Interface, the PLL and update the Syst...
#define PIOS_SYS_SERIAL_NUM_ASCII_LEN
void PIOS_ANNUNC_On(uint32_t annunc_id)
int32_t PIOS_SYS_Reset(void)
size_t PIOS_SYS_OsStackUnused(void)
int32_t PIOS_IRQ_Disable(void)
int32_t PIOS_SYS_SerialNumberGet(char str[PIOS_SYS_SERIAL_NUM_ASCII_LEN+1])
void PIOS_ANNUNC_Toggle(uint32_t annunc_id)
size_t PIOS_SYS_IrqStackUnused(void)
#define PIOS_LED_HEARTBEAT
int32_t PIOS_SYS_SerialNumberGetBinary(uint8_t array[PIOS_SYS_SERIAL_NUM_BINARY_LEN])