1 // Copyright (c) 2020 Brian Swetland
2 //
3 // Use of this source code is governed by a MIT-style
4 // license that can be found in the LICENSE file or at
5 // https://opensource.org/licenses/MIT
6 
7 #include <platform/debug.h>
8 
9 #include <target/debugconfig.h>
10 
11 #include <hardware/uart.h>
12 
13 #include <stdio.h>
14 
platform_dputc(char c)15 void platform_dputc(char c) {
16     if (c == '\n')
17         uart_putc(DEBUG_UART, '\r');
18     uart_putc(DEBUG_UART, c);
19 }
20 
platform_dgetc(char * c,bool wait)21 int platform_dgetc(char *c, bool wait) {
22     if (!wait && !uart_is_readable(DEBUG_UART))
23         return -1;
24     *c = uart_getc(DEBUG_UART);
25     return 0;
26 }
27 
28