From bc9e93ad20f936c67d6acddb02d426783c32398e Mon Sep 17 00:00:00 2001 From: root Date: Sat, 13 Jun 2015 12:18:52 +0100 Subject: add usb resume support --- app/led.c | 51 ++++++++++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 19 deletions(-) (limited to 'app/led.c') diff --git a/app/led.c b/app/led.c index fbe3d11..92469f4 100644 --- a/app/led.c +++ b/app/led.c @@ -1,35 +1,48 @@ #include "project.h" -static int led=0; +static int led_8 = 0; +static int led_9 = 0; -void led_init(void ) +void +led_init (void) { -gpio_set_mode (GPIOB, GPIO_MODE_OUTPUT_2_MHZ, + gpio_set_mode (GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO8); gpio_set_mode (GPIOB, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO9); -} - -void led_clear(void) -{ - gpio_set(GPIOB,GPIO8); - gpio_set(GPIOB,GPIO9); + gpio_set (GPIOB, GPIO8); + gpio_set (GPIOB, GPIO9); } -void led_set(uint32_t v) + +void +led_set (uint32_t v) { - gpio_clear(GPIOB,v); - led=50; + gpio_clear (GPIOB, v); + if (v & GPIO8) + led_8 = 50; + if (v & GPIO9) + led_9 = 50; } -void led_tick(void) +void +led_tick (void) { -if (led) { - led--; - if (!led) led_clear(); -} + if (led_8) + { + led_8--; + if (!led_8) + gpio_set (GPIOB, GPIO8); + } + if (led_9) + { + led_9--; + if (!led_9) + gpio_set (GPIOB, GPIO9); + } + + if (usb_is_suspended) + gpio_clear (GPIOB, GPIO8 | GPIO9); } - - -- cgit v1.2.3