1 /*
2  * Copyright (c) 2012 Travis Geiselbrecht
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 #include <stdarg.h>
9 #include <lk/reg.h>
10 #include <lk/debug.h>
11 #include <stdio.h>
12 #include <kernel/thread.h>
13 #include <platform/debug.h>
14 #include <arch/ops.h>
15 #include <dev/uart.h>
16 #include <target/debugconfig.h>
17 #include <arch/arm/cm.h>
18 
stm32_debug_early_init(void)19 void stm32_debug_early_init(void) {
20     uart_init_early();
21 }
22 
23 /* later in the init process */
stm32_debug_init(void)24 void stm32_debug_init(void) {
25     uart_init();
26 }
27 
platform_dputc(char c)28 void platform_dputc(char c) {
29     if (c == '\n')
30         uart_putc(DEBUG_UART, '\r');
31     uart_putc(DEBUG_UART, c);
32 }
33 
platform_dgetc(char * c,bool wait)34 int platform_dgetc(char *c, bool wait) {
35     int ret = uart_getc(DEBUG_UART, wait);
36     if (ret == -1)
37         return -1;
38     *c = ret;
39     return 0;
40 }
41 
42