1 /* 2 * Copyright 2017 - 2020 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 #include "fsl_common.h" 12 13 /****************Debug console configuration********************/ 14 15 /*! @brief If Non-blocking mode is needed, please define it at project setting, 16 * otherwise blocking mode is the default transfer mode. 17 * Warning: If you want to use non-blocking transfer,please make sure the corresponding 18 * IO interrupt is enable, otherwise there is no output. 19 * And non-blocking is combine with buffer, no matter bare-metal or rtos. 20 * Below shows how to configure in your project if you want to use non-blocking mode. 21 * For IAR, right click project and select "Options", define it in "C/C++ Compiler->Preprocessor->Defined symbols". 22 * For KEIL, click "Options for Target…", define it in "C/C++->Preprocessor Symbols->Define". 23 * For ARMGCC, open CmakeLists.txt and add the following lines, 24 * "SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG_CONSOLE_TRANSFER_NON_BLOCKING")" for debug target. 25 * "SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DDEBUG_CONSOLE_TRANSFER_NON_BLOCKING")" for release target. 26 * For MCUxpresso, right click project and select "Properties", define it in "C/C++ Build->Settings->MCU C 27 * Complier->Preprocessor". 28 * 29 */ 30 #ifdef DEBUG_CONSOLE_TRANSFER_NON_BLOCKING 31 /*! @brief define the transmit buffer length which is used to store the multi task log, buffer is enabled automatically 32 * when 33 * non-blocking transfer is using, 34 * This value will affect the RAM's ultilization, should be set per paltform's capability and software requirement. 35 * If it is configured too small, log maybe missed , because the log will not be 36 * buffered if the buffer is full, and the print will return immediately with -1. 37 * And this value should be multiple of 4 to meet memory alignment. 38 * 39 */ 40 #ifndef DEBUG_CONSOLE_TRANSMIT_BUFFER_LEN 41 #define DEBUG_CONSOLE_TRANSMIT_BUFFER_LEN (512U) 42 #endif /* DEBUG_CONSOLE_TRANSMIT_BUFFER_LEN */ 43 44 /*! @brief define the receive buffer length which is used to store the user input, buffer is enabled automatically when 45 * non-blocking transfer is using, 46 * This value will affect the RAM's ultilization, should be set per paltform's capability and software requirement. 47 * If it is configured too small, log maybe missed, because buffer will be overwrited if buffer is too small. 48 * And this value should be multiple of 4 to meet memory alignment. 49 * 50 */ 51 #ifndef DEBUG_CONSOLE_RECEIVE_BUFFER_LEN 52 #define DEBUG_CONSOLE_RECEIVE_BUFFER_LEN (1024U) 53 #endif /* DEBUG_CONSOLE_RECEIVE_BUFFER_LEN */ 54 55 /*!@ brief Whether enable the reliable TX function 56 * If the macro is zero, the reliable TX function of the debug console is disabled. 57 * When the macro is zero, the string of PRINTF will be thrown away after the transmit buffer is full. 58 */ 59 #ifndef DEBUG_CONSOLE_TX_RELIABLE_ENABLE 60 #define DEBUG_CONSOLE_TX_RELIABLE_ENABLE (1U) 61 #endif /* DEBUG_CONSOLE_TX_RELIABLE_ENABLE */ 62 63 #else 64 #define DEBUG_CONSOLE_TRANSFER_BLOCKING 65 #endif /* DEBUG_CONSOLE_TRANSFER_NON_BLOCKING */ 66 67 /*!@ brief Whether enable the RX function 68 * If the macro is zero, the receive function of the debug console is disabled. 69 */ 70 #ifndef DEBUG_CONSOLE_RX_ENABLE 71 #define DEBUG_CONSOLE_RX_ENABLE (1U) 72 #endif /* DEBUG_CONSOLE_RX_ENABLE */ 73 74 /*!@ brief define the MAX log length debug console support , that is when you call printf("log", x);, the log 75 * length can not bigger than this value. 76 * This macro decide the local log buffer length, the buffer locate at stack, the stack maybe overflow if 77 * the buffer is too big and current task stack size not big enough. 78 */ 79 #ifndef DEBUG_CONSOLE_PRINTF_MAX_LOG_LEN 80 #define DEBUG_CONSOLE_PRINTF_MAX_LOG_LEN (128U) 81 #endif /* DEBUG_CONSOLE_PRINTF_MAX_LOG_LEN */ 82 83 /*!@ brief define the buffer support buffer scanf log length, that is when you call scanf("log", &x);, the log 84 * length can not bigger than this value. 85 * As same as the DEBUG_CONSOLE_BUFFER_PRINTF_MAX_LOG_LEN. 86 */ 87 #ifndef DEBUG_CONSOLE_SCANF_MAX_LOG_LEN 88 #define DEBUG_CONSOLE_SCANF_MAX_LOG_LEN (20U) 89 #endif /* DEBUG_CONSOLE_SCANF_MAX_LOG_LEN */ 90 91 /*! @brief Debug console synchronization 92 * User should not change these macro for synchronization mode, but add the 93 * corresponding synchronization mechanism per different software environment. 94 * Such as, if another RTOS is used, 95 * add: 96 * \#define DEBUG_CONSOLE_SYNCHRONIZATION_XXXX 3 97 * in this configuration file and implement the synchronization in fsl.log.c. 98 */ 99 /*! @brief synchronization for baremetal software */ 100 #define DEBUG_CONSOLE_SYNCHRONIZATION_BM 0 101 /*! @brief synchronization for freertos software */ 102 #define DEBUG_CONSOLE_SYNCHRONIZATION_FREERTOS 1 103 104 /*! @brief RTOS synchronization mechanism disable 105 * If not defined, default is enable, to avoid multitask log print mess. 106 * If other RTOS is used, you can implement the RTOS's specific synchronization mechanism in fsl.log.c 107 * If synchronization is disabled, log maybe messed on terminal. 108 */ 109 #ifndef DEBUG_CONSOLE_DISABLE_RTOS_SYNCHRONIZATION 110 #ifdef DEBUG_CONSOLE_TRANSFER_NON_BLOCKING 111 #ifdef SDK_OS_FREE_RTOS 112 #define DEBUG_CONSOLE_SYNCHRONIZATION_MODE DEBUG_CONSOLE_SYNCHRONIZATION_FREERTOS 113 #else 114 #define DEBUG_CONSOLE_SYNCHRONIZATION_MODE DEBUG_CONSOLE_SYNCHRONIZATION_BM 115 #endif /* SDK_OS_FREE_RTOS */ 116 #else 117 #define DEBUG_CONSOLE_SYNCHRONIZATION_MODE DEBUG_CONSOLE_SYNCHRONIZATION_BM 118 #endif /* DEBUG_CONSOLE_TRANSFER_NON_BLOCKING */ 119 #endif /* DEBUG_CONSOLE_DISABLE_RTOS_SYNCHRONIZATION */ 120 121 /*! @brief echo function support 122 * If you want to use the echo function,please define DEBUG_CONSOLE_ENABLE_ECHO 123 * at your project setting. 124 */ 125 #ifndef DEBUG_CONSOLE_ENABLE_ECHO 126 #define DEBUG_CONSOLE_ENABLE_ECHO_FUNCTION 0 127 #else 128 #define DEBUG_CONSOLE_ENABLE_ECHO_FUNCTION 1 129 #endif /* DEBUG_CONSOLE_ENABLE_ECHO */ 130 131 /*********************************************************************/ 132 133 /***************Debug console other configuration*********************/ 134 /*! @brief Definition to printf the float number. */ 135 #ifndef PRINTF_FLOAT_ENABLE 136 #define PRINTF_FLOAT_ENABLE 0U 137 #endif /* PRINTF_FLOAT_ENABLE */ 138 139 /*! @brief Definition to scanf the float number. */ 140 #ifndef SCANF_FLOAT_ENABLE 141 #define SCANF_FLOAT_ENABLE 0U 142 #endif /* SCANF_FLOAT_ENABLE */ 143 144 /*! @brief Definition to support advanced format specifier for printf. */ 145 #ifndef PRINTF_ADVANCED_ENABLE 146 #define PRINTF_ADVANCED_ENABLE 0U 147 #endif /* PRINTF_ADVANCED_ENABLE */ 148 149 /*! @brief Definition to support advanced format specifier for scanf. */ 150 #ifndef SCANF_ADVANCED_ENABLE 151 #define SCANF_ADVANCED_ENABLE 0U 152 #endif /* SCANF_ADVANCED_ENABLE */ 153 154 /*! @brief Definition to select virtual com(USB CDC) as the debug console. */ 155 #ifndef BOARD_USE_VIRTUALCOM 156 #define BOARD_USE_VIRTUALCOM 0U 157 #endif 158 /*******************************************************************/ 159 160 #endif /* _FSL_DEBUG_CONSOLE_CONF_H_ */ 161