diff options
author | fishsoupisgood <github@madingley.org> | 2020-06-18 13:26:56 +0100 |
---|---|---|
committer | fishsoupisgood <github@madingley.org> | 2020-06-18 13:26:56 +0100 |
commit | e41764fceeabb1cdb6a7a299e00f2166a6f6ac32 (patch) | |
tree | c58c73d742bf990ec692d61ca8d911dd43fab8c6 /stm32/app/main.c | |
parent | f7b7cf9e80200cade938d47527e39034c75b9b6d (diff) | |
download | robs_speedo-e41764fceeabb1cdb6a7a299e00f2166a6f6ac32.tar.gz robs_speedo-e41764fceeabb1cdb6a7a299e00f2166a6f6ac32.tar.bz2 robs_speedo-e41764fceeabb1cdb6a7a299e00f2166a6f6ac32.zip |
moved stm32 into directory added noddy pcb
Diffstat (limited to 'stm32/app/main.c')
-rw-r--r-- | stm32/app/main.c | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/stm32/app/main.c b/stm32/app/main.c new file mode 100644 index 0000000..d834802 --- /dev/null +++ b/stm32/app/main.c @@ -0,0 +1,85 @@ +#include "project.h" + +#define WIGGLE GPIO4 +#define WIGGLE_PORT GPIOB + +int +main (void) +{ + unsigned cnt = 0; + + //nvic_set_priority_grouping(NVIC_PriorityGroup_4); + + /*set up pll */ + rcc_clock_setup_in_hse_8mhz_out_72mhz(); + + /*turn on clocks which aren't done elsewhere */ + rcc_periph_clock_enable (RCC_GPIOA); + rcc_periph_clock_enable (RCC_GPIOB); + rcc_periph_clock_enable (RCC_GPIOC); + rcc_periph_clock_enable (RCC_AFIO); + + + /*Adjust interrupt priorities so that taco trumps uarts trumps timer trumps dma */ + nvic_set_priority (TACHO_IRQ, 0x20); + nvic_set_priority (NVIC_USART1_IRQ, 0x40); + nvic_set_priority (NVIC_SYSTICK_IRQ, 0x60); + nvic_set_priority (NVIC_DMA1_CHANNEL6_IRQ, 0x80); + + /* Claw some pins pack */ + gpio_primary_remap (AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_ON, 0); + + dwt_enable_cycle_counter(); + + ticker_init(); + + + led_init(); + usart_init(); + i2cp_init(); + + printf ("Hello world\n"); + + led_set(); + tacho_init(); + + delay_ms (100); + + + oled1_init(); + oled2_init(); + + gauge_init(); + + + + font8x8_put_str (vram_1, "ABC fish soup!", 0, 0); + + MAP_OUTPUT_PP (WIGGLE); + + + for (;;) { + char buf[20]; + + sprintf (buf, "%6u rpm", (unsigned) raw_tacho); + font8x16_put_str (vram_1, buf, 30, 8); + + sprintf (buf, "%8d", cnt++); + font8x8_put_str (vram_1, buf, 0, 24); + + sprintf (buf, "%6d", cnt >> 4); + font21x32_put_str (vram_2, buf, 0); + + + if (cnt & 1) + SET (WIGGLE); + else + CLEAR (WIGGLE); + + + gauge_test(); + + } + + return 0; +} |