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