]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M0+_LPC51U68_LPCXpresso/utilities/fsl_debug_console.h
Remove build files accidentally checked in.
[freertos] / FreeRTOS / Demo / CORTEX_M0+_LPC51U68_LPCXpresso / utilities / fsl_debug_console.h
1 /*\r
2  * Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc.\r
3  * Copyright 2016-2018 NXP\r
4  * All rights reserved.\r
5  *\r
6  * SPDX-License-Identifier: BSD-3-Clause\r
7  *\r
8  * Debug console shall provide input and output functions to scan and print formatted data.\r
9  * o Support a format specifier for PRINTF follows this prototype "%[flags][width][.precision][length]specifier"\r
10  *   - [flags] :'-', '+', '#', ' ', '0'\r
11  *   - [width]:  number (0,1...)\r
12  *   - [.precision]: number (0,1...)\r
13  *   - [length]: do not support\r
14  *   - [specifier]: 'd', 'i', 'f', 'F', 'x', 'X', 'o', 'p', 'u', 'c', 's', 'n'\r
15  * o Support a format specifier for SCANF follows this prototype " %[*][width][length]specifier"\r
16  *   - [*]: is supported.\r
17  *   - [width]: number (0,1...)\r
18  *   - [length]: 'h', 'hh', 'l','ll','L'. ignore ('j','z','t')\r
19  *   - [specifier]: 'd', 'i', 'u', 'f', 'F', 'e', 'E', 'g', 'G', 'a', 'A', 'o', 'c', 's'\r
20  */\r
21 \r
22 #ifndef _FSL_DEBUGCONSOLE_H_\r
23 #define _FSL_DEBUGCONSOLE_H_\r
24 \r
25 #include "fsl_common.h"\r
26 #include "serial_manager.h"\r
27 \r
28 /*!\r
29  * @addtogroup debugconsole\r
30  * @{\r
31  */\r
32 \r
33 /*******************************************************************************\r
34  * Definitions\r
35  ******************************************************************************/\r
36 \r
37 extern serial_handle_t g_serialHandle; /*!< serial manager handle */\r
38 \r
39 /*! @brief Definition select redirect toolchain printf, scanf to uart or not. */\r
40 #define DEBUGCONSOLE_REDIRECT_TO_TOOLCHAIN 0U /*!< Select toolchain printf and scanf. */\r
41 #define DEBUGCONSOLE_REDIRECT_TO_SDK 1U       /*!< Select SDK version printf, scanf. */\r
42 #define DEBUGCONSOLE_DISABLE 2U               /*!< Disable debugconsole function. */\r
43 \r
44 /*! @brief Definition to select sdk or toolchain printf, scanf. The macro only support\r
45  * to be redefined in project setting.\r
46  */\r
47 #ifndef SDK_DEBUGCONSOLE\r
48 #define SDK_DEBUGCONSOLE 1U\r
49 #endif\r
50 \r
51 /*! @brief Definition to select redirect toolchain printf, scanf to uart or not. */\r
52 #ifndef SDK_DEBUGCONSOLE_UART\r
53 /* mcux will handle this macro, not define it here */\r
54 #if (!defined(__MCUXPRESSO))\r
55 #define SDK_DEBUGCONSOLE_UART\r
56 #endif\r
57 #endif\r
58 \r
59 #if defined(SDK_DEBUGCONSOLE) && !(SDK_DEBUGCONSOLE)\r
60 #include <stdio.h>\r
61 #endif\r
62 \r
63 /*! @brief Definition to select redirect toolchain printf, scanf to uart or not.\r
64  *\r
65  *  if SDK_DEBUGCONSOLE defined to 0,it represents select toolchain printf, scanf.\r
66  *  if SDK_DEBUGCONSOLE defined to 1,it represents select SDK version printf, scanf.\r
67  *  if SDK_DEBUGCONSOLE defined to 2,it represents disable debugconsole function.\r
68  */\r
69 #if SDK_DEBUGCONSOLE == DEBUGCONSOLE_DISABLE /* Disable debug console */\r
70 #define PRINTF\r
71 #define SCANF\r
72 #define PUTCHAR\r
73 #define GETCHAR\r
74 #elif SDK_DEBUGCONSOLE == DEBUGCONSOLE_REDIRECT_TO_SDK /* Select printf, scanf, putchar, getchar of SDK version. */\r
75 #define PRINTF DbgConsole_Printf\r
76 #define SCANF DbgConsole_Scanf\r
77 #define PUTCHAR DbgConsole_Putchar\r
78 #define GETCHAR DbgConsole_Getchar\r
79 #elif SDK_DEBUGCONSOLE == DEBUGCONSOLE_REDIRECT_TO_TOOLCHAIN /* Select printf, scanf, putchar, getchar of toolchain. \ \\r
80                                                               */\r
81 #define PRINTF printf\r
82 #define SCANF scanf\r
83 #define PUTCHAR putchar\r
84 #define GETCHAR getchar\r
85 #endif /* SDK_DEBUGCONSOLE */\r
86 \r
87 /*******************************************************************************\r
88  * Prototypes\r
89  ******************************************************************************/\r
90 \r
91 #if defined(__cplusplus)\r
92 extern "C" {\r
93 #endif /* __cplusplus */\r
94 \r
95 /*! @name Initialization*/\r
96 /* @{ */\r
97 \r
98 /*!\r
99  * @brief Initializes the peripheral used for debug messages.\r
100  *\r
101  * Call this function to enable debug log messages to be output via the specified peripheral\r
102  * initialized by the serial manager module.\r
103  * After this function has returned, stdout and stdin are connected to the selected peripheral.\r
104  *\r
105  * @param instance      The instance of the module.\r
106  * @param baudRate      The desired baud rate in bits per second.\r
107  * @param device        Low level device type for the debug console, can be one of the following.\r
108  *                      @arg kSerialPort_Uart,\r
109  *                      @arg kSerialPort_UsbCdc\r
110  *                      @arg kSerialPort_UsbCdcVirtual.\r
111  * @param clkSrcFreq    Frequency of peripheral source clock.\r
112  *\r
113  * @return              Indicates whether initialization was successful or not.\r
114  * @retval kStatus_Success          Execution successfully\r
115  */\r
116 status_t DbgConsole_Init(uint8_t instance, uint32_t baudRate, serial_port_type_t device, uint32_t clkSrcFreq);\r
117 \r
118 /*!\r
119  * @brief De-initializes the peripheral used for debug messages.\r
120  *\r
121  * Call this function to disable debug log messages to be output via the specified peripheral\r
122  * initialized by the serial manager module.\r
123  *\r
124  * @return Indicates whether de-initialization was successful or not.\r
125  */\r
126 status_t DbgConsole_Deinit(void);\r
127 \r
128 #if SDK_DEBUGCONSOLE\r
129 /*!\r
130  * @brief Writes formatted output to the standard output stream.\r
131  *\r
132  * Call this function to write a formatted output to the standard output stream.\r
133  *\r
134  * @param   formatString Format control string.\r
135  * @return  Returns the number of characters printed or a negative value if an error occurs.\r
136  */\r
137 int DbgConsole_Printf(const char *formatString, ...);\r
138 \r
139 /*!\r
140  * @brief Writes a character to stdout.\r
141  *\r
142  * Call this function to write a character to stdout.\r
143  *\r
144  * @param   ch Character to be written.\r
145  * @return  Returns the character written.\r
146  */\r
147 int DbgConsole_Putchar(int ch);\r
148 \r
149 /*!\r
150  * @brief Reads formatted data from the standard input stream.\r
151  *\r
152  * Call this function to read formatted data from the standard input stream.\r
153  *\r
154  * @note Due the limitation in the BM OSA environment (CPU is blocked in the function,\r
155  * other tasks will not be scheduled), the function cannot be used when the\r
156  * DEBUG_CONSOLE_TRANSFER_NON_BLOCKING is set in the BM OSA environment.\r
157  * And an error is returned when the function called in this case. The suggestion\r
158  * is that polling the non-blocking function DbgConsole_TryGetchar to get the input char.\r
159  *\r
160  * @param   formatString Format control string.\r
161  * @return  Returns the number of fields successfully converted and assigned.\r
162  */\r
163 int DbgConsole_Scanf(char *formatString, ...);\r
164 \r
165 /*!\r
166  * @brief Reads a character from standard input.\r
167  *\r
168  * Call this function to read a character from standard input.\r
169  *\r
170  * @note Due the limitation in the BM OSA environment (CPU is blocked in the function,\r
171  * other tasks will not be scheduled), the function cannot be used when the\r
172  * DEBUG_CONSOLE_TRANSFER_NON_BLOCKING is set in the BM OSA environment.\r
173  * And an error is returned when the function called in this case. The suggestion\r
174  * is that polling the non-blocking function DbgConsole_TryGetchar to get the input char.\r
175  *\r
176  * @return Returns the character read.\r
177  */\r
178 int DbgConsole_Getchar(void);\r
179 \r
180 /*!\r
181  * @brief Debug console flush.\r
182  *\r
183  * Call this function to wait the tx buffer empty.\r
184  * If interrupt transfer is using, make sure the global IRQ is enable before call this function\r
185  * This function should be called when\r
186  * 1, before enter power down mode\r
187  * 2, log is required to print to terminal immediately\r
188  * @return Indicates whether wait idle was successful or not.\r
189  */\r
190 status_t DbgConsole_Flush(void);\r
191 \r
192 #ifdef DEBUG_CONSOLE_TRANSFER_NON_BLOCKING\r
193 /*!\r
194  * @brief Debug console try to get char\r
195  * This function provides a API which will not block current task, if character is\r
196  * available return it, otherwise return fail.\r
197  * @param ch the address of char to receive\r
198  * @return Indicates get char was successful or not.\r
199  */\r
200 status_t DbgConsole_TryGetchar(char *ch);\r
201 #endif\r
202 \r
203 #endif /* SDK_DEBUGCONSOLE */\r
204 \r
205 /*! @} */\r
206 \r
207 #if defined(__cplusplus)\r
208 }\r
209 #endif /* __cplusplus */\r
210 \r
211 /*! @} */\r
212 \r
213 #endif /* _FSL_DEBUGCONSOLE_H_ */\r