/* * My first project * * It blinks LEDs like counting in binary, when the button is pressed, it reverses the order * * Build on top of libopenocm3, blackbox parts of code (setup()) copied from * libopencm3-examples/examples/stm32/f1/stm32vl-discovery/button project * * Open source licence, let's say Artistic Licence, although it doesn't matter, as it is local only */ #include #include #include #define DELAY 8000000 // Should be a second, or maybe not (second iff 8MHz clk, 1/3second if 24MHz clk) #define STM32F1 1 // Needed for libopencm3 void setup (void) { // All the blackbox code rcc_clock_setup_in_hse_8mhz_out_24mhz(); rcc_periph_clock_enable(RCC_GPIOC); rcc_periph_clock_enable(RCC_GPIOA); gpio_set_mode(GPIOC, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO8 | GPIO9); gpio_set_mode(GPIOA, GPIO_MODE_INPUT, GPIO_CNF_INPUT_FLOAT, GPIO0); } inline void wait (int ticks) { // This works in libopenocm3 examples int i; for (i=0;i