1 /* 2 * Copyright (c) 2023, The OpenThread Authors. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 3. Neither the name of the copyright holder nor the 13 * names of its contributors may be used to endorse or promote products 14 * derived from this software without specific prior written permission. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26 * POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29 /** 30 * @file 31 * This file defines the RTT implementation of the uart API and default constants used by uart_rtt.c. 32 * 33 */ 34 35 #ifndef UTILS_UART_RTT_H 36 #define UTILS_UART_RTT_H 37 38 #include "openthread-core-config.h" 39 #include <openthread/config.h> 40 41 #include "logging_rtt.h" 42 43 #ifdef __cplusplus 44 extern "C" { 45 #endif 46 47 /** 48 * @def UART_RTT_BUFFER_INDEX 49 * 50 * RTT buffer index used for the uart. 51 * 52 */ 53 #ifndef UART_RTT_BUFFER_INDEX 54 #define UART_RTT_BUFFER_INDEX 1 55 #endif 56 57 #if OPENTHREAD_UART_RTT_ENABLE && (OPENTHREAD_CONFIG_LOG_OUTPUT == OPENTHREAD_CONFIG_LOG_OUTPUT_PLATFORM_DEFINED) && \ 58 (LOG_RTT_BUFFER_INDEX == UART_RTT_BUFFER_INDEX) 59 #error "Log buffer index matches uart buffer index" 60 #endif 61 62 /** 63 * @def UART_RTT_BUFFER_NAME 64 * 65 * RTT name used for the uart. Only used if UART_RTT_BUFFER_INDEX is not 0. 66 * Otherwise, the buffer name is fixed to "Terminal". 67 * 68 */ 69 #ifndef UART_RTT_BUFFER_NAME 70 #define UART_RTT_BUFFER_NAME "Terminal" 71 #endif 72 73 /** 74 * @def UART_RTT_UP_BUFFER_SIZE 75 * 76 * RTT up buffer size used for the uart. Only used if UART_RTT_BUFFER_INDEX 77 * is not 0. To configure buffer #0 size, check the BUFFER_SIZE_UP definition 78 * in SEGGER_RTT_Conf.h 79 * 80 */ 81 #ifndef UART_RTT_UP_BUFFER_SIZE 82 #define UART_RTT_UP_BUFFER_SIZE 256 83 #endif 84 85 /** 86 * @def UART_RTT_DOWN_BUFFER_SIZE 87 * 88 * RTT down buffer size used for the uart. Only used if UART_RTT_BUFFER_INDEX 89 * is not 0. To configure buffer #0 size, check the BUFFER_SIZE_DOWN definition 90 * in SEGGER_RTT_Conf.h 91 * 92 */ 93 #ifndef UART_RTT_DOWN_BUFFER_SIZE 94 #define UART_RTT_DOWN_BUFFER_SIZE 16 95 #endif 96 97 /** 98 * @def UART_RTT_READ_BUFFER_SIZE 99 * 100 * Size of the temporary buffer used when reading from the RTT channel. It will be 101 * locally allocated on the stack. 102 * 103 */ 104 #ifndef UART_RTT_READ_BUFFER_SIZE 105 #define UART_RTT_READ_BUFFER_SIZE 16 106 #endif 107 108 /** 109 * Updates the rtt uart. Must be called frequently to process receive and send done. 110 * 111 */ 112 void utilsUartRttProcess(void); 113 114 #ifdef __cplusplus 115 } // extern "C" 116 #endif 117 118 #endif // UTILS_UART_RTT_H 119