Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
UARTTester.h
00001 /* 00002 * Copyright (c) 2019, Arm Limited and affiliates. 00003 * SPDX-License-Identifier: Apache-2.0 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 #ifndef UART_TESTER_H 00019 #define UART_TESTER_H 00020 00021 #include "MbedTester.h" 00022 00023 00024 class UARTTester: public MbedTester { 00025 public: 00026 00027 UARTTester(const PinList *form_factor, const PinList *exclude_pins) 00028 : MbedTester(form_factor, exclude_pins) 00029 { 00030 00031 } 00032 00033 /** 00034 * Set the baudrate for uart TX and RX 00035 * 00036 * @param baudrate Target baudrate in HZ 00037 */ 00038 void set_baud(uint32_t baudrate); 00039 00040 /** 00041 * Set the number of data bits 00042 * 00043 * Supported values for data bits is 1 to 16 00044 * 00045 * @param data_bits The number of data bits in this transfer 00046 */ 00047 void set_bits(uint8_t data_bits); 00048 00049 /** 00050 * Set the number of stop bits 00051 * 00052 * Supported values for stop bits is 1 to 16 00053 * 00054 * @param stop_bits The number of stop bits to end the transfer with 00055 */ 00056 void set_stops(uint8_t stop_bits); 00057 00058 /** 00059 * Enable or disable parity checking 00060 * 00061 * @param enable true to enable parity checking, false to disable it 00062 * @param odd_n_even true of odd parity, false for even 00063 */ 00064 void set_parity(bool enable, bool odd_n_even); 00065 00066 /** 00067 * Enable UART reception 00068 */ 00069 void rx_start(); 00070 00071 /** 00072 * Disable UART reception 00073 */ 00074 void rx_stop(); 00075 00076 /** 00077 * Get the sum of all bytes received 00078 * 00079 * @return the sum of all bytes received 00080 */ 00081 uint32_t rx_get_checksum(); 00082 00083 /** 00084 * Get the number of bytes received 00085 * 00086 * @return the number of bytes received 00087 */ 00088 uint32_t rx_get_count(); 00089 00090 /** 00091 * Get the previous data(s) sent 00092 * 00093 * @param prev index of data to get 1 for the previous 00094 * @return data 00095 */ 00096 uint16_t rx_get_data(int prev = 1); 00097 00098 /** 00099 * Get the number of parity errors that have occurred 00100 * 00101 * @return number of parity errors that have occurred 00102 */ 00103 uint32_t rx_get_parity_errors(); 00104 00105 /** 00106 * Get the number of stop errors that have occurred 00107 * 00108 * @return number of stop errors that have occurred 00109 */ 00110 uint32_t rx_get_stop_errors(); 00111 00112 /** 00113 * Get the number of framing errors that have occurred 00114 * 00115 * @return number of framing errors that have occurred 00116 */ 00117 uint32_t rx_get_framing_errors(); 00118 00119 /** 00120 * Start UART transmission 00121 */ 00122 void tx_start(bool cts_enabled = false); 00123 00124 /** 00125 * Stop UART transmission 00126 */ 00127 void tx_stop(); 00128 00129 /** 00130 * Set the delay after the tx_start() call and before the actual start 00131 * of UART transmission 00132 * 00133 * @param delay in nanoseconds 00134 */ 00135 void tx_set_delay(uint32_t delay_ns); 00136 00137 /** 00138 * Set the number of bytes to send 00139 * 00140 * @param count Number of bytes to send when started 00141 */ 00142 void tx_set_count(uint32_t count); 00143 00144 /** 00145 * Set next sequence value to send 00146 * 00147 * When TX is started 'count' bytes will be sent. Each value will 00148 * be one greater than the previous. 00149 * 00150 * @param value Next value to send 00151 */ 00152 void tx_set_next(uint16_t value); 00153 00154 /** 00155 * Set the delay seen when deasserting the CTS line 00156 * 00157 * When delay is set to 0 then transmission will be immediately 00158 * stopped when CTS goes to 1. 00159 * 00160 * @param delay in nanoseconds 00161 */ 00162 void cts_deassert_delay(uint32_t delay_ns); 00163 00164 }; 00165 00166 #endif
Generated on Tue Jul 12 2022 13:55:01 by
