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 <stm32f10x_rcc.h>
18 #include <stm32f10x_usart.h>
19 #include <arch/arm/cm.h>
20 #include <platform/stm32.h>
21 
stm32_debug_early_init(void)22 void stm32_debug_early_init(void) {
23     uart_init_early();
24 }
25 
26 /* later in the init process */
stm32_debug_init(void)27 void stm32_debug_init(void) {
28     uart_init();
29 }
30 
platform_dputc(char c)31 void platform_dputc(char c) {
32     if (c == '\n')
33         uart_putc(DEBUG_UART, '\r');
34     uart_putc(DEBUG_UART, c);
35 }
36 
platform_dgetc(char * c,bool wait)37 int platform_dgetc(char *c, bool wait) {
38     int ret = uart_getc(DEBUG_UART, wait);
39     if (ret == -1)
40         return -1;
41     *c = ret;
42     return 0;
43 }
44 
45