#include <stdarg.h>
#include <string.h>
+#ifdef DEBUG_SEMIHOSTING
+
void semi_put_char(char c)
{
-#ifdef DEBUG_SEMIHOSTING
// This is tricky, we need to work around GCC bugs
volatile char cc = c;
asm volatile (
: [msg] "r" (&cc)
: "r0", "r1"
);
-#endif
}
void semi_write_string(char *c)
{
-#ifdef DEBUG_SEMIHOSTING
asm volatile (
"mov r0, #0x04\n" /* SYS_WRITE0 */
"mov r1, %[msg]\n"
: [msg] "r" (c)
: "r0", "r1"
);
-#endif
}
+#endif
+
void debug_putc(int c)
{
+#ifdef DEBUG_SEMIHOSTING
static char debug_buf[128];
static int debug_i;
debug_buf[debug_i++] = c;
semi_write_string(debug_buf);
debug_i = 0;
}
+#endif
+#ifdef DEBUG_USART
+ if (c == '\n')
+ debug_putc('\r');
+ while (!LL_USART_IsActiveFlag_TXE(DEBUG_USART))
+ ;
+ LL_USART_TransmitData8(DEBUG_USART, c);
+#endif
}
void debug_puts(const char *s)