1 /*
2  * Copyright 2017 NXP
3  * All rights reserved.
4  *
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 #ifndef _FSL_DEBUG_CONSOLE_CONF_H_
9 #define _FSL_DEBUG_CONSOLE_CONF_H_
10 
11 /****************Debug console configuration********************/
12 
13 /*! @brief If Non-blocking mode is needed, please define it at project setting,
14 * otherwise blocking mode is the default transfer mode.
15 * Warning: If you want to use non-blocking transfer,please make sure the corresponding
16 * IO interrupt is enable, otherwise there is no output.
17 * And non-blocking is combine with buffer, no matter bare-metal or rtos.
18 */
19 #ifdef DEBUG_CONSOLE_TRANSFER_NON_BLOCKING
20 /*! @brief define the transmit buffer length which is used to store the multi task log, buffer is enabled automatically
21 * when
22 * non-blocking transfer is using,
23 * This value will affect the RAM's ultilization, should be set per paltform's capability and software requirement.
24 * If it is configured too small, log maybe missed , because the log will not be
25 * buffered if the buffer is full, and the print will return immediately with -1.
26 * And this value should be multiple of 4 to meet memory alignment.
27 *
28 */
29 #ifndef DEBUG_CONSOLE_TRANSMIT_BUFFER_LEN
30 #define DEBUG_CONSOLE_TRANSMIT_BUFFER_LEN (512U)
31 #endif /* DEBUG_CONSOLE_TRANSMIT_BUFFER_LEN */
32 
33 /*! @brief define the receive buffer length which is used to store the user input, buffer is enabled automatically when
34 * non-blocking transfer is using,
35 * This value will affect the RAM's ultilization, should be set per paltform's capability and software requirement.
36 * If it is configured too small, log maybe missed, because buffer will be overwrited if buffer is too small.
37 * And this value should be multiple of 4 to meet memory alignment.
38 *
39 */
40 #ifndef DEBUG_CONSOLE_RECEIVE_BUFFER_LEN
41 #define DEBUG_CONSOLE_RECEIVE_BUFFER_LEN (512U)
42 #endif /* DEBUG_CONSOLE_RECEIVE_BUFFER_LEN */
43 
44 #else
45 #define DEBUG_CONSOLE_TRANSFER_BLOCKING
46 #endif /* DEBUG_CONSOLE_TRANSFER_NON_BLOCKING */
47 
48 /*!@ brief define the MAX log length debug console support , that is when you call printf("log", x);, the log
49 * length can not bigger than this value.
50 * This macro decide the local log buffer length, the buffer locate at stack, the stack maybe overflow if
51 * the buffer is too big and current task stack size not big enough.
52 */
53 #ifndef DEBUG_CONSOLE_PRINTF_MAX_LOG_LEN
54 #define DEBUG_CONSOLE_PRINTF_MAX_LOG_LEN (128U)
55 #endif /* DEBUG_CONSOLE_PRINTF_MAX_LOG_LEN */
56 
57 /*!@ brief define the buffer support buffer scanf log length, that is when you call scanf("log", &x);, the log
58 * length can not bigger than this value.
59 * As same as the DEBUG_CONSOLE_BUFFER_PRINTF_MAX_LOG_LEN.
60 */
61 #ifndef DEBUG_CONSOLE_SCANF_MAX_LOG_LEN
62 #define DEBUG_CONSOLE_SCANF_MAX_LOG_LEN (20U)
63 #endif /* DEBUG_CONSOLE_SCANF_MAX_LOG_LEN */
64 
65 /*! @brief Debug console synchronization
66 * User should not change these macro for synchronization mode, but add the
67 * corresponding synchronization mechanism per different software environment.
68 * Such as, if another RTOS is used,
69 * add:
70 *  #define DEBUG_CONSOLE_SYNCHRONIZATION_XXXX 3
71 * in this configuration file and implement the synchronization in fsl.log.c.
72 */
73 /*! @brief synchronization for baremetal software */
74 #define DEBUG_CONSOLE_SYNCHRONIZATION_BM 0
75 /*! @brief synchronization for freertos software */
76 #define DEBUG_CONSOLE_SYNCHRONIZATION_FREERTOS 1
77 
78 /*! @brief RTOS synchronization mechanism disable
79 * If not defined, default is enable, to avoid multitask log print mess.
80 * If other RTOS is used, you can implement the RTOS's specific synchronization mechanism in fsl.log.c
81 * If synchronization is disabled, log maybe messed on terminal.
82 */
83 #ifndef DEBUG_CONSOLE_DISABLE_RTOS_SYNCHRONIZATION
84 #ifdef DEBUG_CONSOLE_TRANSFER_NON_BLOCKING
85 #ifdef FSL_RTOS_FREE_RTOS
86 #define DEBUG_CONSOLE_SYNCHRONIZATION_MODE DEBUG_CONSOLE_SYNCHRONIZATION_FREERTOS
87 #else
88 #define DEBUG_CONSOLE_SYNCHRONIZATION_MODE DEBUG_CONSOLE_SYNCHRONIZATION_BM
89 #endif /* FSL_RTOS_FREE_RTOS */
90 #endif /* DEBUG_CONSOLE_TRANSFER_NON_BLOCKING */
91 #endif /* DEBUG_CONSOLE_DISABLE_RTOS_SYNCHRONIZATION */
92 
93 /*! @brief echo function support
94 * If you want to use the echo function,please define DEBUG_CONSOLE_ENABLE_ECHO
95 * at your project setting.
96 */
97 #ifndef DEBUG_CONSOLE_ENABLE_ECHO
98 #define DEBUG_CONSOLE_ENABLE_ECHO_FUNCTION 0
99 #else
100 #define DEBUG_CONSOLE_ENABLE_ECHO_FUNCTION 1
101 #endif /* DEBUG_CONSOLE_ENABLE_ECHO */
102 
103 /*********************************************************************/
104 
105 /***************Debug console other configuration*********************/
106 /*! @brief Definition to printf the float number. */
107 #ifndef PRINTF_FLOAT_ENABLE
108 #define PRINTF_FLOAT_ENABLE 0U
109 #endif /* PRINTF_FLOAT_ENABLE */
110 
111 /*! @brief Definition to scanf the float number. */
112 #ifndef SCANF_FLOAT_ENABLE
113 #define SCANF_FLOAT_ENABLE 0U
114 #endif /* SCANF_FLOAT_ENABLE */
115 
116 /*! @brief Definition to support advanced format specifier for printf. */
117 #ifndef PRINTF_ADVANCED_ENABLE
118 #define PRINTF_ADVANCED_ENABLE 0U
119 #endif /* PRINTF_ADVANCED_ENABLE */
120 
121 /*! @brief Definition to support advanced format specifier for scanf. */
122 #ifndef SCANF_ADVANCED_ENABLE
123 #define SCANF_ADVANCED_ENABLE 0U
124 #endif /* SCANF_ADVANCED_ENABLE */
125 
126 /*******************************************************************/
127 
128 #endif /* _FSL_DEBUG_CONSOLE_CONF_H_ */
129