File tree Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Expand file tree Collapse file tree 3 files changed +58
-0
lines changed Original file line number Diff line number Diff line change @@ -15,3 +15,4 @@ zephyr_library_sources_ifdef(CONFIG_UART_MCUMGR uart_mcumgr.c)
15
15
zephyr_library_sources_ifdef (CONFIG_XTENSA_SIM_CONSOLE xtensa_sim_console.c )
16
16
zephyr_library_sources_ifdef (CONFIG_EFI_CONSOLE efi_console.c )
17
17
zephyr_library_sources_ifdef (CONFIG_WINSTREAM_CONSOLE winstream_console.c )
18
+ zephyr_library_sources_ifdef (CONFIG_TCCVCP_CONSOLE tccvcp_console.c )
Original file line number Diff line number Diff line change @@ -304,4 +304,11 @@ config WINSTREAM_CONSOLE_STATIC_SIZE
304
304
305
305
endif # WINSTREAM_CONSOLE
306
306
307
+ config TCCVCP_CONSOLE
308
+ bool "Use TCCVCP console"
309
+ depends on SERIAL && SERIAL_HAS_DRIVER && UART_TCCVCP
310
+ select CONSOLE_HAS_DRIVER
311
+ help
312
+ Use tccvcp as a console.
313
+
307
314
endif # CONSOLE
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2024 Hounjoung Rim <[email protected] >
3
+ * SPDX-License-Identifier: Apache-2.0
4
+ */
5
+
6
+ #include <zephyr/kernel.h>
7
+ #include <zephyr/sys/printk.h>
8
+ #include <zephyr/sys/printk-hooks.h>
9
+ #include <zephyr/sys/libc-hooks.h>
10
+ #include <zephyr/device.h>
11
+ #include <zephyr/init.h>
12
+
13
+ static const struct device * const uart_console_dev = DEVICE_DT_GET (DT_CHOSEN (zephyr_console ));
14
+
15
+ void uart_tccvcp_poll_out (const struct device * dev , unsigned char c );
16
+
17
+ static int arch_printk_char_out (int c )
18
+ {
19
+ if (!device_is_ready (uart_console_dev )) {
20
+ return - ENODEV ;
21
+ }
22
+
23
+ if ('\n' == c ) {
24
+ uart_tccvcp_poll_out (uart_console_dev , '\r' );
25
+ }
26
+ uart_tccvcp_poll_out (uart_console_dev , c );
27
+
28
+ return c ;
29
+ }
30
+
31
+ static void tccvcp_console_hook_install (void )
32
+ {
33
+ #if defined(CONFIG_PRINTK )
34
+ __printk_hook_install (arch_printk_char_out );
35
+ #endif
36
+ __stdout_hook_install (arch_printk_char_out );
37
+ }
38
+
39
+ static int tccvcp_console_init (void )
40
+ {
41
+ if (!device_is_ready (uart_console_dev )) {
42
+ return - ENODEV ;
43
+ }
44
+
45
+ tccvcp_console_hook_install ();
46
+
47
+ return 0 ;
48
+ }
49
+
50
+ SYS_INIT (tccvcp_console_init , POST_KERNEL , CONFIG_CONSOLE_INIT_PRIORITY );
You can’t perform that action at this time.
0 commit comments