25
25
/* MBED */
26
26
/***************************/
27
27
#if TARGET_LIKE_MBED
28
+
29
+ #define CONSOLE_OUTPUT_UART 1
30
+ #define CONSOLE_OUTPUT_SWO 2
31
+ #define mbed_console_concat_ (x ) CONSOLE_OUTPUT_##x
32
+ #define mbed_console_concat (x ) mbed_console_concat_(x)
33
+ #define CONSOLE_OUTPUT mbed_console_concat(MBED_CONF_MINIMAL_PRINTF_CONSOLE_OUTPUT)
34
+
35
+ #if MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES
36
+ static char mbed_stdio_out_prev = 0 ;
37
+ #endif
38
+
39
+ #if CONSOLE_OUTPUT == CONSOLE_OUTPUT_UART
40
+ #if DEVICE_SERIAL
28
41
/*
29
42
Serial initialization and new line replacement is a direct copy from mbed_retarget.cpp
30
43
If the static modifier were to be removed, this part of the code would not be necessary.
31
44
*/
32
45
#include "hal/serial_api.h"
33
46
34
- #if DEVICE_SERIAL
35
47
static serial_t stdio_uart = { 0 };
36
- #if MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES
37
- static char mbed_stdio_out_prev = 0 ;
38
- #endif
39
- #endif
40
48
41
49
/* module variable for keeping track of initialization */
42
50
static bool not_initialized = true;
@@ -47,18 +55,32 @@ static void init_serial()
47
55
{
48
56
not_initialized = false;
49
57
50
- #if DEVICE_SERIAL
51
58
serial_init (& stdio_uart , STDIO_UART_TX , STDIO_UART_RX );
52
59
#if MBED_CONF_PLATFORM_STDIO_BAUD_RATE
53
60
serial_baud (& stdio_uart , MBED_CONF_PLATFORM_STDIO_BAUD_RATE );
54
- #endif
55
61
#endif
56
62
}
57
63
}
58
64
59
65
#define MBED_INITIALIZE_PRINT (x ) { init_serial(); }
60
66
#define MBED_PRINT_CHARACTER (x ) { serial_putc(&stdio_uart, x); }
61
67
68
+ #else
69
+
70
+ #define MBED_INITIALIZE_PRINT (x )
71
+ #define MBED_PRINT_CHARACTER (x )
72
+
73
+ #endif // if DEVICE_SERIAL
74
+
75
+ #elif CONSOLE_OUTPUT == CONSOLE_OUTPUT_SWO
76
+
77
+ #include "hal/itm_api.h"
78
+
79
+ #define MBED_INITIALIZE_PRINT (x ) { mbed_itm_init(); }
80
+ #define MBED_PRINT_CHARACTER (x ) { mbed_itm_send(ITM_PORT_SWO, x); }
81
+
82
+ #endif // if CONSOLE_OUTPUT
83
+
62
84
/***************************/
63
85
/* Linux */
64
86
/***************************/
0 commit comments