X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=inline;f=lib%2Futil-debug.c;h=b61ace51e670b7ada29e342dead9a226f38cccb8;hb=71d8e81533dc24d06cae545edac06c0fe393b374;hp=ed1076d922f25b7463436dec7a05f49eaa647f7c;hpb=d910e34d0deecc4af18cf98377479cdfb78eac31;p=home-hw.git diff --git a/lib/util-debug.c b/lib/util-debug.c index ed1076d..b61ace5 100644 --- a/lib/util-debug.c +++ b/lib/util-debug.c @@ -6,6 +6,7 @@ #include "util.h" +#include #include #include @@ -21,6 +22,13 @@ // Use this USART for debugging messages // #define DEBUG_USART USART1 +// Use this LED for debugging +#ifdef DEBUG_LED_BLUEPILL +#define DEBUG_LED_GPIO GPIOC +#define DEBUG_LED_PIN GPIO13 +#define DEBUG_LED_INVERSE +#endif + /*** Implementation ***/ #ifdef DEBUG_SEMIHOSTING @@ -67,8 +75,8 @@ void debug_putc(int c) #endif #ifdef DEBUG_USART if (c == '\n') - usart_send_blocking(USART2, '\r'); - usart_send_blocking(USART2, c); + usart_send_blocking(DEBUG_USART, '\r'); + usart_send_blocking(DEBUG_USART, c); #endif } @@ -182,3 +190,23 @@ void debug_printf(const char *fmt, ...) va_end(args); } + +void debug_led(bool light) +{ +#ifdef DEBUG_LED_GPIO +#ifdef DEBUG_LED_INVERSE + light = !light; +#endif + if (light) + gpio_set(DEBUG_LED_GPIO, DEBUG_LED_PIN); + else + gpio_clear(DEBUG_LED_GPIO, DEBUG_LED_PIN); +#endif +} + +void debug_led_toggle(void) +{ +#ifdef DEBUG_LED_GPIO + gpio_toggle(DEBUG_LED_GPIO, DEBUG_LED_PIN); +#endif +}