1 /* 2 * Copyright (c) 2016 Brian Swetland 3 * 4 * Use of this source code is governed by a MIT-style 5 * license that can be found in the LICENSE file or at 6 * https://opensource.org/licenses/MIT 7 */ 8 9 #include <kernel/thread.h> 10 #include <platform/debug.h> 11 12 #include <driverlib/uart.h> 13 14 #define UART0_BASE 0x40001000 15 platform_dputc(char c)16void platform_dputc(char c) { 17 UARTCharPut(UART0_BASE, c); 18 } 19 platform_dgetc(char * c,bool wait)20int platform_dgetc(char *c, bool wait) { 21 int n; 22 for (;;) { 23 if ((n = UARTCharGetNonBlocking(UART0_BASE)) < 0) { 24 if (wait) { 25 thread_yield(); 26 } else { 27 return -1; 28 } 29 } else { 30 *c = n; 31 return 0; 32 } 33 } 34 } 35