diff options
Diffstat (limited to 'stm32/app/main.c')
-rw-r--r-- | stm32/app/main.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/stm32/app/main.c b/stm32/app/main.c new file mode 100644 index 0000000..4722479 --- /dev/null +++ b/stm32/app/main.c @@ -0,0 +1,50 @@ +#include "project.h" + + + + + +int main (void) +{ + /*set up pll */ + rcc_clock_setup_pll (&rcc_hse_configs[RCC_HSE_CONFIG]); + + /*turn on clocks to periferals */ + rcc_periph_clock_enable (RCC_GPIOA); + rcc_periph_clock_enable (RCC_GPIOB); + rcc_periph_clock_enable (RCC_GPIOC); + rcc_periph_clock_enable (RCC_USART1); + rcc_periph_clock_enable (RCC_AFIO); + rcc_periph_clock_enable (RCC_PWR); + rcc_periph_clock_enable (RCC_BKP); + pwr_disable_backup_domain_write_protect(); + DWT_CTRL |= DWT_CTRL_CYCCNTENA; + + + nvic_set_priority (NVIC_SYSTICK_IRQ, 0x80); + nvic_set_priority (NVIC_USART1_IRQ, 0x40); + nvic_set_priority (NVIC_USB_HP_CAN_TX_IRQ, 0x40); + nvic_set_priority (NVIC_USB_LP_CAN_RX0_IRQ, 0x40); + nvic_set_priority (NVIC_RTC_IRQ, 0x10); + + MAP_OUTPUT_OD (LED1); + MAP_OUTPUT_OD (LED2); + + + usart_init(); + cdcacm_rings_init(); + rtc_init(); + + printf ("Startup:\r\n"); + + motor_init(); + ticker_init(); + usb_init(); + + + for (;;); + + + return 0; +} + |