35 #if defined(PIOS_INCLUDE_SYS)
37 #define MEM8(addr) (*((volatile uint8_t *)(addr)))
40 static void NVIC_Configuration(
void);
47 #if !defined(PIOS_INCLUDE_CHIBIOS)
63 SCB->SHCSR |= SCB_SHCSR_USGFAULTENA_Msk | SCB_SHCSR_BUSFAULTENA_Msk | SCB_SHCSR_MEMFAULTENA_Msk;
73 RCC_AHBPeriphClockCmd(
90 RCC_APB1PeriphClockCmd(
99 RCC_APB1Periph_USART2 |
100 RCC_APB1Periph_USART3 |
101 RCC_APB1Periph_UART4 |
102 RCC_APB1Periph_UART5 |
103 RCC_APB1Periph_I2C1 |
104 RCC_APB1Periph_I2C2 |
106 RCC_APB1Periph_CAN1 |
111 RCC_APB2PeriphClockCmd(
112 RCC_APB2Periph_TIM1 |
113 RCC_APB2Periph_TIM8 |
114 RCC_APB2Periph_TIM15 |
115 RCC_APB2Periph_TIM16 |
116 RCC_APB2Periph_TIM17 |
117 RCC_APB2Periph_USART1 |
118 RCC_APB2Periph_SPI1 |
119 RCC_APB2Periph_SYSCFG |
127 GPIO_InitTypeDef GPIO_InitStructure;
128 GPIO_StructInit(&GPIO_InitStructure);
129 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
131 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
132 #if (PIOS_USB_ENABLED)
133 GPIO_InitStructure.GPIO_Pin &= ~(GPIO_Pin_11 | GPIO_Pin_12);
135 GPIO_InitStructure.GPIO_Pin &= ~(GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15);
136 GPIO_Init(GPIOA, &GPIO_InitStructure);
138 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
139 GPIO_Init(GPIOB, &GPIO_InitStructure);
140 GPIO_Init(GPIOC, &GPIO_InitStructure);
141 GPIO_Init(GPIOD, &GPIO_InitStructure);
142 GPIO_Init(GPIOE, &GPIO_InitStructure);
143 GPIO_Init(GPIOF, &GPIO_InitStructure);
162 #if defined(PIOS_INCLUDE_ANNUNC) && defined(PIOS_LED_HEARTBEAT)
165 #if defined(PIOS_INCLUDE_ANNUNC) && defined(PIOS_LED_ALARM)
192 uint8_t b = MEM8(0x1ffff7ac + i);
213 uint8_t b = MEM8(0x1ffff7ac + (i / 2));
218 str[
i] = ((b > 9) ? (
'A' - 10) :
'0') + b;
226 static inline size_t unused_mem(uint32_t *top, uint32_t *bot, uint32_t pattern)
229 for (; p < top && *p == pattern; p++);
230 return (p - bot) *
sizeof(uint32_t);
233 #ifdef PIOS_INCLUDE_CHIBIOS
235 #if !defined(CRT0_STACKS_FILL_PATTERN)
236 #define CRT0_STACKS_FILL_PATTERN 0x55555555
239 extern uint32_t __main_stack_base__;
240 extern uint32_t __main_stack_end__;
241 extern uint32_t __process_stack_base__;
242 extern uint32_t __process_stack_end__;
246 return unused_mem(&__main_stack_end__, &__main_stack_base__,
247 CRT0_STACKS_FILL_PATTERN);
252 return unused_mem(&__process_stack_end__, &__process_stack_base__,
253 CRT0_STACKS_FILL_PATTERN);
259 extern uint32_t _irq_stack_end;
260 extern uint32_t _irq_stack_top;
264 return unused_mem(&_irq_stack_top, &_irq_stack_end, 0xa5a5a5a5);
277 static void NVIC_Configuration(
void)
280 extern void *pios_isr_vector_table_base;
281 NVIC_SetVectorTable((uint32_t)&pios_isr_vector_table_base, 0x0);
284 NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
287 SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK);
290 #ifdef USE_FULL_ASSERT
298 void assert_failed(uint8_t * file, uint32_t line)
304 #if defined(PIOS_LED_HEARTBEAT)
307 #if defined(PIOS_LED_ALARM)
313 #if defined(PIOS_LED_HEARTBEAT)
316 #if defined(PIOS_LED_ALARM)
319 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])