SmartSnippets DA1459x SDK
console.h
Go to the documentation of this file.
1 
41 #ifndef CONSOLE_H_
42 #define CONSOLE_H_
43 
44 #if dg_configUSE_CONSOLE
45 
46 #include "ad_uart.h"
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
52 #if !dg_configUSE_CONSOLE_STUBS
53 
54 /*
55  * The console utilities service provides support for serial input and output (even from
56  * an interrupt context) by employing the UART adapter for reading and writing, and through
57  * one of the UART peripheral HW instances.
58  *
59  * When attempting to capture serial input or print a string from within an application task
60  * or interrupt, the libC standard _read()/_write() are redirected to console_read()/write().
61  * To allow these reads/writes, console uses it's own task (console_task_func()) that does
62  * the actual UART hardware access through the UART adapter (ad_uart_read/write_async()).
63  * Synchronization between the console task and the main execution domain is achieved via an
64  * OS-based set of events and notifications.
65  *
66  * Notes:
67  * - Console does not use additional RAM for printing. RAM that is used is allocated during
68  * initialization only.
69  * - If data flow is too fast for UART, calls from task will wait, while calls from interrupt
70  * may lose some data.
71  * - When the console service and CONFIG_RETARGET are both enabled, the serial input and output
72  * activity will be automatically handled by console instead of standard retarget implementation.
73  * - In case of printing, it must be assured that the HW UART CTS line/pin of the USB/UART IC
74  * converter is properly connected to the relevant M33 GPIO pin. Additionally, that an IRQ handler
75  * is defined to be triggered upon a CTS event. See the console_wkup_handler() description for more.
76  */
77 
81 #ifndef CONSOLE_TASK_PRIORITY
82 #define CONSOLE_TASK_PRIORITY (OS_TASK_PRIORITY_NORMAL)
83 #endif
84 
94 void console_init(const ad_uart_controller_conf_t *ad_uart_ctrl_conf);
95 
109 int console_write(const char *buf, int len);
110 
120 int console_read(char *buf, int len);
121 
136 void console_wkup_handler(void);
137 
138 #else /* !dg_configUSE_CONSOLE_STUBS */
139 
140 __STATIC_INLINE void console_init(void)
141 {
142 
143 }
144 
145 __STATIC_INLINE int console_write(const char *buf, int len)
146 {
147  return len;
148 }
149 
150 __STATIC_INLINE int console_read(char *buf, int len)
151 {
152  return 0;
153 }
154 
155 #endif /* !dg_configUSE_CONSOLE_STUBS */
156 
157 #ifdef __cplusplus
158 }
159 #endif
160 
161 #endif /* dg_configUSE_CONSOLE */
162 
163 #endif /* CONSOLE_H_ */
164 
ad_uart_controller_conf_t
UART controller configuration.
Definition: ad_uart.h:158
console_wkup_handler
void console_wkup_handler(void)
Wake up handler for serial console.
console_write
int console_write(const char *buf, int len)
Write to serial console.
console_read
int console_read(char *buf, int len)
Read from serial console.
ad_uart.h
UART adapter API.
console_init
void console_init(const ad_uart_controller_conf_t *ad_uart_ctrl_conf)
Initialize console to use with specified serial device.