// vim: shiftwidth=4 tabstop=4 noexpandtab #include #include /* SYSCLK should be at 72.000.000 Hz --> 18.000.000 __asm__("nop") per second (one instruction --> 4 clock cycles) --> 18.000 __asm__("nop") per millisecond */ #define DELAY_MS 18000 // FIXME seems to be too slow by factor of 4 static void clock_init(void); static void gpio_init(void); static void delay(uint32_t delay); void main(void) { clock_init(); gpio_init(); while(1){ gpio_toggle(GPIOC, GPIO13); delay(250 * DELAY_MS); } } static void clock_init(void) { rcc_clock_setup_pll(&rcc_hse_configs[RCC_CLOCK_HSE8_72MHZ]); rcc_periph_clock_enable(RCC_GPIOC); // for PC13 blinking } static void gpio_init(void) { gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO13); gpio_set(GPIOC, GPIO13); } static void delay(uint32_t delay) { for (uint32_t i = 0; i < delay; i++) { __asm__("nop"); } }