diff options
| -rw-r--r-- | app/led.c | 28 | ||||
| -rw-r--r-- | app/led.h | 3 | ||||
| -rw-r--r-- | app/main.c | 23 | ||||
| -rw-r--r-- | app/project.h | 1 | ||||
| -rw-r--r-- | app/prototypes.h | 1 | 
5 files changed, 39 insertions, 17 deletions
| @@ -7,42 +7,42 @@ void  led_init (void)  {    gpio_set_mode (GPIOB, GPIO_MODE_OUTPUT_2_MHZ, -                 GPIO_CNF_OUTPUT_PUSHPULL, GPIO8); +                 GPIO_CNF_OUTPUT_PUSHPULL, LED0);    gpio_set_mode (GPIOB, GPIO_MODE_OUTPUT_2_MHZ, -                 GPIO_CNF_OUTPUT_PUSHPULL, GPIO9); +                 GPIO_CNF_OUTPUT_PUSHPULL, LED1);  }  void  led_clear (void)  { -  gpio_set (GPIOB, GPIO8); -  gpio_set (GPIOB, GPIO9); +  gpio_set (GPIOB, LED0); +  gpio_set (GPIOB, LED1);  }  void -led_set (uint32_t v) +led_flash (uint32_t v)  {    gpio_clear (GPIOB, v);    led = 200;  } +void led_set(uint32_t v) +{ +v&= LED_MASK; +gpio_clear(GPIOB,v); +v^=LED_MASK; +gpio_set(GPIOB,v); +} + +  void  led_tick (void)  { -  static int c; -    if (led)      {        led--;        if (!led)          led_clear ();      } -  else -    { -      led_set (c ? GPIO8 : GPIO9); -      c ^= 1; -    } - -  } diff --git a/app/led.h b/app/led.h new file mode 100644 index 0000000..7575958 --- /dev/null +++ b/app/led.h @@ -0,0 +1,3 @@ +#define LED0 GPIO8 +#define LED1 GPIO9 +#define LED_MASK (LED0|LED1) @@ -9,15 +9,15 @@ kbd_dispatch (void)    if (ring_read_byte (&rx1_ring, &c))      return; -  printf("KEY> %c\r\n",c); +  printf ("KEY> %c\r\n", c);  }  int  main (void)  { -//  rcc_clock_setup_in_hsi_out_48mhz (); -  //nvic_set_priority_grouping(NVIC_PriorityGroup_4); +  char buf[128]; +  int c;    /*set up pll */    rcc_clock_setup_in_hse_8mhz_out_72mhz (); @@ -49,9 +49,26 @@ main (void)    for (;;)      { +        if (!ring_empty (&rx1_ring))          kbd_dispatch (); +      delay_ms (1000); + +      printf ("Counter is %x\n", c); + +      sprintf (buf, "%8x", c++); +      lcd_write (buf, 0, 1); + +      led_set (c & 1 ? LED0 : LED1); + + + + + + + +      }    return 0; diff --git a/app/project.h b/app/project.h index 89184aa..b698423 100644 --- a/app/project.h +++ b/app/project.h @@ -14,6 +14,7 @@  #include <stdio.h>  #include <errno.h> +#include "led.h"  #include "i2c.h"  #include "ring.h" diff --git a/app/prototypes.h b/app/prototypes.h index 2e0163c..2b91b5d 100644 --- a/app/prototypes.h +++ b/app/prototypes.h @@ -32,6 +32,7 @@ extern void lcd_shutdown(void);  /* led.c */  extern void led_init(void);  extern void led_clear(void); +extern void led_flash(uint32_t v);  extern void led_set(uint32_t v);  extern void led_tick(void);  /* main.c */ | 
