#include "util.h"
+#include <libopencm3/stm32/gpio.h>
#include <libopencm3/stm32/usart.h>
#include <stdarg.h>
// 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
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
+}
p[0] = x & 0xff;
}
-// debug.c
+// util-debug.c
void debug_printf(const char *fmt, ...);
void debug_puts(const char *s);
void debug_putc(int c);
+
+void debug_led(bool light);
+void debug_led_toggle(void);