X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Futil-debug.c;h=72a566eae40f49226514c9edf53cb5b7fba8dc93;hb=5286b9d20dd896a010e0d1db9f0813f5c489951e;hp=59ee644709c81bee1806d9ae7bb952db8bd74d51;hpb=7f5c145f630595504988109c09a22ed807705398;p=home-hw.git diff --git a/lib/util-debug.c b/lib/util-debug.c index 59ee644..72a566e 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 @@ -159,6 +167,9 @@ void debug_printf(const char *fmt, ...) c = *fmt++; switch (c) { + case 'c': + debug_putc(va_arg(args, int)); + break; case 'd': printf_number(va_arg(args, int), width, flags | PF_SIGNED, 10); break; @@ -182,3 +193,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 +}