diff options
author | fishsoupisgood <github@madingley.org> | 2020-06-14 10:55:07 +0100 |
---|---|---|
committer | fishsoupisgood <github@madingley.org> | 2020-06-14 10:55:07 +0100 |
commit | 0060468326b7ab0cd07d0d80a84118e7c5bcf348 (patch) | |
tree | 8be8ad7b1cb23be4765b9d94a7b8fcefa4d67e27 /app/main.c | |
parent | dbc21c1e5dfd95248fe2cd7da6d96c92bdbb97a4 (diff) | |
download | robs_speedo-0060468326b7ab0cd07d0d80a84118e7c5bcf348.tar.gz robs_speedo-0060468326b7ab0cd07d0d80a84118e7c5bcf348.tar.bz2 robs_speedo-0060468326b7ab0cd07d0d80a84118e7c5bcf348.zip |
add tacho
Diffstat (limited to 'app/main.c')
-rw-r--r-- | app/main.c | 34 |
1 files changed, 22 insertions, 12 deletions
@@ -1,5 +1,7 @@ #include "project.h" +#define WIGGLE GPIO4 +#define WIGGLE_PORT GPIOB int main (void) @@ -18,12 +20,16 @@ main (void) rcc_periph_clock_enable (RCC_AFIO); - /*Adjust interrupt priorities so that uarts trump timer */ + /*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_USART2_IRQ, 0x40); - nvic_set_priority (NVIC_USART3_IRQ, 0x40); - nvic_set_priority (NVIC_SYSTICK_IRQ, 0xff); + 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 (); @@ -31,32 +37,36 @@ main (void) led_init (); usart_init (); i2cp_init (); - //i2cb_init(); -#if 0 - //lcd_init (); - // -#endif printf ("Hello world\n"); led_set (); - //i2cb_scan(); - oled_init (); + tacho_init(); font8x8_put_str ("ABC fish soup!", 0, 0); + MAP_OUTPUT_PP(WIGGLE); + + for (;;) { char buf[20]; - sprintf(buf,"%8d",cnt++); + sprintf(buf,"%6u rpm",(unsigned) raw_tacho); font8x16_put_str (buf, 30, 8); + sprintf(buf,"%8d",cnt++); font8x8_put_str (buf, 0, 24); + + if (cnt&1) + SET(WIGGLE); + else + CLEAR(WIGGLE); + } return 0; |