Mistake on this page?
Report an issue in GitHub or email us
UARTTester.h
1 /*
2  * Copyright (c) 2019, Arm Limited and affiliates.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef UART_TESTER_H
19 #define UART_TESTER_H
20 
21 #include "MbedTester.h"
22 
23 
24 class UARTTester: public MbedTester {
25 public:
26 
27  UARTTester(const PinList *form_factor, const PinList *exclude_pins)
28  : MbedTester(form_factor, exclude_pins)
29  {
30 
31  }
32 
33  /**
34  * Set the baudrate for uart TX and RX
35  *
36  * @param baudrate Target baudrate in HZ
37  */
38  void set_baud(uint32_t baudrate);
39 
40  /**
41  * Set the number of data bits
42  *
43  * Supported values for data bits is 1 to 16
44  *
45  * @param data_bits The number of data bits in this transfer
46  */
47  void set_bits(uint8_t data_bits);
48 
49  /**
50  * Set the number of stop bits
51  *
52  * Supported values for stop bits is 1 to 16
53  *
54  * @param stop_bits The number of stop bits to end the transfer with
55  */
56  void set_stops(uint8_t stop_bits);
57 
58  /**
59  * Enable or disable parity checking
60  *
61  * @param enable true to enable parity checking, false to disable it
62  * @param odd_n_even true of odd parity, false for even
63  */
64  void set_parity(bool enable, bool odd_n_even);
65 
66  /**
67  * Enable UART reception
68  */
69  void rx_start();
70 
71  /**
72  * Disable UART reception
73  */
74  void rx_stop();
75 
76  /**
77  * Get the sum of all bytes received
78  *
79  * @return the sum of all bytes received
80  */
81  uint32_t rx_get_checksum();
82 
83  /**
84  * Get the number of bytes received
85  *
86  * @return the number of bytes received
87  */
88  uint32_t rx_get_count();
89 
90  /**
91  * Get the previous data(s) sent
92  *
93  * @param prev index of data to get 1 for the previous
94  * @return data
95  */
96  uint16_t rx_get_data(int prev = 1);
97 
98  /**
99  * Get the number of parity errors that have occurred
100  *
101  * @return number of parity errors that have occurred
102  */
103  uint32_t rx_get_parity_errors();
104 
105  /**
106  * Get the number of stop errors that have occurred
107  *
108  * @return number of stop errors that have occurred
109  */
110  uint32_t rx_get_stop_errors();
111 
112  /**
113  * Get the number of framing errors that have occurred
114  *
115  * @return number of framing errors that have occurred
116  */
117  uint32_t rx_get_framing_errors();
118 
119  /**
120  * Start UART transmission
121  */
122  void tx_start(bool cts_enabled = false);
123 
124  /**
125  * Stop UART transmission
126  */
127  void tx_stop();
128 
129  /**
130  * Set the delay after the tx_start() call and before the actual start
131  * of UART transmission
132  *
133  * @param delay in nanoseconds
134  */
135  void tx_set_delay(uint32_t delay_ns);
136 
137  /**
138  * Set the number of bytes to send
139  *
140  * @param count Number of bytes to send when started
141  */
142  void tx_set_count(uint32_t count);
143 
144  /**
145  * Set next sequence value to send
146  *
147  * When TX is started 'count' bytes will be sent. Each value will
148  * be one greater than the previous.
149  *
150  * @param value Next value to send
151  */
152  void tx_set_next(uint16_t value);
153 
154  /**
155  * Set the delay seen when deasserting the CTS line
156  *
157  * When delay is set to 0 then transmission will be immediately
158  * stopped when CTS goes to 1.
159  *
160  * @param delay in nanoseconds
161  */
162  void cts_deassert_delay(uint32_t delay_ns);
163 
164 };
165 
166 #endif
void set_stops(uint8_t stop_bits)
Set the number of stop bits.
void set_parity(bool enable, bool odd_n_even)
Enable or disable parity checking.
void tx_set_next(uint16_t value)
Set next sequence value to send.
Definition: pinmap.h:37
void cts_deassert_delay(uint32_t delay_ns)
Set the delay seen when deasserting the CTS line.
uint32_t rx_get_stop_errors()
Get the number of stop errors that have occurred.
void tx_stop()
Stop UART transmission.
MbedTester(const PinList *form_factor, const PinList *exclude_pins)
Construct a new MbedTester object.
void set_bits(uint8_t data_bits)
Set the number of data bits.
uint32_t rx_get_framing_errors()
Get the number of framing errors that have occurred.
uint32_t rx_get_parity_errors()
Get the number of parity errors that have occurred.
uint16_t rx_get_data(int prev=1)
Get the previous data(s) sent.
void set_baud(uint32_t baudrate)
Set the baudrate for uart TX and RX.
void rx_start()
Enable UART reception.
void tx_set_delay(uint32_t delay_ns)
Set the delay after the tx_start() call and before the actual start of UART transmission.
uint32_t rx_get_checksum()
Get the sum of all bytes received.
uint32_t rx_get_count()
Get the number of bytes received.
void rx_stop()
Disable UART reception.
void tx_start(bool cts_enabled=false)
Start UART transmission.
void tx_set_count(uint32_t count)
Set the number of bytes to send.
The base class for controlling the FPGA CI Test Shield.
Definition: MbedTester.h:68
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.