fsl_debug_console.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 - 2015, Freescale Semiconductor, Inc.
3  * Copyright 2016-2018 NXP
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  *
8  * Debug console shall provide input and output functions to scan and print formatted data.
9  * o Support a format specifier for PRINTF follows this prototype "%[flags][width][.precision][length]specifier"
10  * - [flags] :'-', '+', '#', ' ', '0'
11  * - [width]: number (0,1...)
12  * - [.precision]: number (0,1...)
13  * - [length]: do not support
14  * - [specifier]: 'd', 'i', 'f', 'F', 'x', 'X', 'o', 'p', 'u', 'c', 's', 'n'
15  * o Support a format specifier for SCANF follows this prototype " %[*][width][length]specifier"
16  * - [*]: is supported.
17  * - [width]: number (0,1...)
18  * - [length]: 'h', 'hh', 'l','ll','L'. ignore ('j','z','t')
19  * - [specifier]: 'd', 'i', 'u', 'f', 'F', 'e', 'E', 'g', 'G', 'a', 'A', 'o', 'c', 's'
20  */
21 
22 #ifndef _FSL_DEBUGCONSOLE_H_
23 #define _FSL_DEBUGCONSOLE_H_
24 
25 #include "fsl_common.h"
26 #include "serial_manager.h"
27 
33 /*******************************************************************************
34  * Definitions
35  ******************************************************************************/
36 
40 #define DEBUGCONSOLE_REDIRECT_TO_TOOLCHAIN 0U
41 #define DEBUGCONSOLE_REDIRECT_TO_SDK 1U
42 #define DEBUGCONSOLE_DISABLE 2U
47 #ifndef SDK_DEBUGCONSOLE
48 #define SDK_DEBUGCONSOLE 1U
49 #endif
50 
51 #if defined(SDK_DEBUGCONSOLE) && !(SDK_DEBUGCONSOLE)
52 #include <stdio.h>
53 #endif
54 
61 #if SDK_DEBUGCONSOLE == DEBUGCONSOLE_DISABLE /* Disable debug console */
62 #define PRINTF(...) \
63  do \
64  { \
65  } while (0)
66 #define SCANF(...) \
67  do \
68  { \
69  } while (0)
70 #define PUTCHAR(...) \
71  do \
72  { \
73  } while (0)
74 #define GETCHAR() -1
75 #elif SDK_DEBUGCONSOLE == DEBUGCONSOLE_REDIRECT_TO_SDK /* Select printf, scanf, putchar, getchar of SDK version. */
76 #define PRINTF DbgConsole_Printf
77 #define SCANF DbgConsole_Scanf
78 #define PUTCHAR DbgConsole_Putchar
79 #define GETCHAR DbgConsole_Getchar
80 #elif SDK_DEBUGCONSOLE == DEBUGCONSOLE_REDIRECT_TO_TOOLCHAIN /* Select printf, scanf, putchar, getchar of toolchain. \ \
81  */
82 #define PRINTF printf
83 #define SCANF scanf
84 #define PUTCHAR putchar
85 #define GETCHAR getchar
86 #endif /* SDK_DEBUGCONSOLE */
87 
88 /*******************************************************************************
89  * Prototypes
90  ******************************************************************************/
91 
92 #if defined(__cplusplus)
93 extern "C" {
94 #endif /* __cplusplus */
95 
97 /* @{ */
98 
99 #if ((SDK_DEBUGCONSOLE == DEBUGCONSOLE_REDIRECT_TO_SDK) || defined(SDK_DEBUGCONSOLE_UART))
100 
118 status_t DbgConsole_Init(uint8_t instance, uint32_t baudRate, serial_port_type_t device, uint32_t clkSrcFreq);
119 
129 #else
130 
134 static inline status_t DbgConsole_Init(uint8_t instance,
135  uint32_t baudRate,
137  uint32_t clkSrcFreq)
138 {
139  (void)instance;
140  (void)baudRate;
141  (void)device;
142  (void)clkSrcFreq;
143  return (status_t)kStatus_Fail;
144 }
149 static inline status_t DbgConsole_Deinit(void)
150 {
151  return (status_t)kStatus_Fail;
152 }
153 #endif /* ((SDK_DEBUGCONSOLE == DEBUGCONSOLE_REDIRECT_TO_SDK) || defined(SDK_DEBUGCONSOLE_UART)) */
154 
155 #if SDK_DEBUGCONSOLE
156 
164 int DbgConsole_Printf(const char *formatString, ...);
165 
174 int DbgConsole_Putchar(int ch);
175 
190 int DbgConsole_Scanf(char *formatString, ...);
191 
205 int DbgConsole_Getchar(void);
206 
218 int DbgConsole_BlockingPrintf(const char *formatString, ...);
219 
231 
232 #ifdef DEBUG_CONSOLE_TRANSFER_NON_BLOCKING
233 
240 status_t DbgConsole_TryGetchar(char *ch);
241 #endif
242 
243 #endif /* SDK_DEBUGCONSOLE */
244 
247 #if defined(__cplusplus)
248 }
249 #endif /* __cplusplus */
250 
253 #endif /* _FSL_DEBUGCONSOLE_H_ */
fsl_common.h
DbgConsole_Flush
status_t DbgConsole_Flush(void)
Debug console flush.
Definition: fsl_debug_console.c:838
serial_port_type_t
enum _serial_port_type serial_port_type_t
serial port type
serial_handle_t
void * serial_handle_t
The handle of the serial manager module.
Definition: serial_manager.h:206
DbgConsole_Getchar
int DbgConsole_Getchar(void)
Reads a character from standard input.
Definition: fsl_debug_console.c:990
DbgConsole_Printf
int DbgConsole_Printf(const char *formatString,...)
Writes formatted output to the standard output stream.
Definition: fsl_debug_console.c:877
DbgConsole_Deinit
status_t DbgConsole_Deinit(void)
De-initializes the peripheral used for debug messages.
Definition: fsl_debug_console.c:801
g_serialHandle
serial_handle_t g_serialHandle
Definition: fsl_debug_console.c:229
device
ma_device device
Definition: porcupine/demo/c/dr_libs/tests/external/miniaudio/tests/test_deviceio/ma_test_deviceio.c:57
serial_manager.h
DbgConsole_Putchar
int DbgConsole_Putchar(int ch)
Writes a character to stdout.
Definition: fsl_debug_console.c:897
DbgConsole_Init
status_t DbgConsole_Init(uint8_t instance, uint32_t baudRate, serial_port_type_t device, uint32_t clkSrcFreq)
Initializes the peripheral used for debug messages.
Definition: fsl_debug_console.c:670
kStatus_Fail
@ kStatus_Fail
Definition: fsl_common.h:180
DbgConsole_BlockingPrintf
int DbgConsole_BlockingPrintf(const char *formatString,...)
Writes formatted output to the standard output stream with the blocking mode.
Definition: fsl_debug_console.c:922
DbgConsole_Scanf
int DbgConsole_Scanf(char *formatString,...)
Reads formatted data from the standard input stream.
Definition: fsl_debug_console.c:904
status_t
int32_t status_t
Type used for all status and error return values.
Definition: fsl_common.h:189


picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:13:56