@@ -95,9 +95,11 @@ public:
95
95
96
96
/* Utility global variables */
97
97
98
- [[maybe_unused]] static const int NEW_RX1 = 9 ;
99
- [[maybe_unused]] static const int NEW_TX1 = 10 ;
100
- std::vector<UARTTestConfig*> uart_test_configs;
98
+ [[maybe_unused]]
99
+ static const int NEW_RX1 = 9 ;
100
+ [[maybe_unused]]
101
+ static const int NEW_TX1 = 10 ;
102
+ std::vector<UARTTestConfig *> uart_test_configs;
101
103
102
104
/* Utility functions */
103
105
@@ -119,8 +121,8 @@ void task_delayed_msg(void *pvParameters) {
119
121
120
122
// This function is automatically called by unity before each test is run
121
123
void setUp (void ) {
122
- for (auto * ref : uart_test_configs) {
123
- UARTTestConfig& config = *ref;
124
+ for (auto * ref : uart_test_configs) {
125
+ UARTTestConfig & config = *ref;
124
126
// log_d("Setup internal loop-back from and back to UART%d TX >> UART%d RX", config.uart_num, config.uart_num);
125
127
config.begin (115200 );
126
128
config.serial .onReceive ([&config]() {
@@ -132,8 +134,8 @@ void setUp(void) {
132
134
133
135
// This function is automatically called by unity after each test is run
134
136
void tearDown (void ) {
135
- for (auto * ref : uart_test_configs) {
136
- UARTTestConfig& config = *ref;
137
+ for (auto * ref : uart_test_configs) {
138
+ UARTTestConfig & config = *ref;
137
139
config.end ();
138
140
}
139
141
}
@@ -144,8 +146,8 @@ void tearDown(void) {
144
146
void basic_transmission_test (void ) {
145
147
log_d (" Performing basic transmission test" );
146
148
147
- for (auto * ref : uart_test_configs) {
148
- UARTTestConfig& config = *ref;
149
+ for (auto * ref : uart_test_configs) {
150
+ UARTTestConfig & config = *ref;
149
151
config.transmit_and_check_msg (" " );
150
152
}
151
153
@@ -154,8 +156,8 @@ void basic_transmission_test(void) {
154
156
155
157
// This test checks if the baudrate can be changed and if the message can be transmitted and received correctly after the change
156
158
void change_baudrate_test (void ) {
157
- for (auto * ref : uart_test_configs) {
158
- UARTTestConfig& config = *ref;
159
+ for (auto * ref : uart_test_configs) {
160
+ UARTTestConfig & config = *ref;
159
161
log_d (" Changing baudrate of UART%d to 9600" , config.uart_num );
160
162
161
163
// Baudrate error should be within 2% of the target baudrate
@@ -203,8 +205,8 @@ void resize_buffers_test(void) {
203
205
// This test checks if the begin function can be called when the UART is already running
204
206
void begin_when_running_test (void ) {
205
207
log_d (" Trying to set up serial twice" );
206
- for (auto * ref : uart_test_configs) {
207
- UARTTestConfig& config = *ref;
208
+ for (auto * ref : uart_test_configs) {
209
+ UARTTestConfig & config = *ref;
208
210
// Calling twice should not crash
209
211
config.begin (115200 );
210
212
config.begin (115200 );
@@ -216,8 +218,8 @@ void begin_when_running_test(void) {
216
218
void end_when_stopped_test (void ) {
217
219
log_d (" Trying to end serial twice" );
218
220
219
- for (auto * ref : uart_test_configs) {
220
- UARTTestConfig& config = *ref;
221
+ for (auto * ref : uart_test_configs) {
222
+ UARTTestConfig & config = *ref;
221
223
// Calling twice should not crash
222
224
config.end ();
223
225
config.end ();
@@ -281,8 +283,8 @@ void disabled_uart_calls_test(void) {
281
283
int integer_ret;
282
284
uint8_t test_buf[1 ];
283
285
284
- for (auto * ref : uart_test_configs) {
285
- UARTTestConfig& config = *ref;
286
+ for (auto * ref : uart_test_configs) {
287
+ UARTTestConfig & config = *ref;
286
288
config.end ();
287
289
}
288
290
@@ -354,15 +356,15 @@ void disabled_uart_calls_test(void) {
354
356
void change_pins_test (void ) {
355
357
log_d (" Disabling UART loopback" );
356
358
357
- for (auto * ref : uart_test_configs) {
358
- UARTTestConfig& config = *ref;
359
+ for (auto * ref : uart_test_configs) {
360
+ UARTTestConfig & config = *ref;
359
361
esp_rom_gpio_connect_out_signal (config.default_rx_pin , SIG_GPIO_OUT_IDX, false , false );
360
362
}
361
363
362
364
log_d (" Swapping UART pins and testing transmission" );
363
365
364
366
if (TEST_UART_NUM == 1 ) {
365
- UARTTestConfig& config = *uart_test_configs[0 ];
367
+ UARTTestConfig & config = *uart_test_configs[0 ];
366
368
config.serial .setPins (NEW_RX1, NEW_TX1);
367
369
TEST_ASSERT_EQUAL (NEW_RX1, uart_get_RxPin (config.uart_num ));
368
370
TEST_ASSERT_EQUAL (NEW_TX1, uart_get_TxPin (config.uart_num ));
@@ -371,8 +373,8 @@ void change_pins_test(void) {
371
373
config.transmit_and_check_msg (" using new pins" );
372
374
} else {
373
375
for (int i = 0 ; i < TEST_UART_NUM; i++) {
374
- UARTTestConfig& config = *uart_test_configs[i];
375
- UARTTestConfig& next_uart = *uart_test_configs[(i + 1 ) % TEST_UART_NUM];
376
+ UARTTestConfig & config = *uart_test_configs[i];
377
+ UARTTestConfig & next_uart = *uart_test_configs[(i + 1 ) % TEST_UART_NUM];
376
378
config.serial .setPins (next_uart.default_rx_pin , next_uart.default_tx_pin );
377
379
TEST_ASSERT_EQUAL (uart_get_RxPin (config.uart_num ), next_uart.default_rx_pin );
378
380
TEST_ASSERT_EQUAL (uart_get_TxPin (config.uart_num ), next_uart.default_tx_pin );
@@ -433,8 +435,8 @@ void periman_test(void) {
433
435
434
436
log_d (" Setting up I2C on the same pins as UART" );
435
437
436
- for (auto * ref : uart_test_configs) {
437
- UARTTestConfig& config = *ref;
438
+ for (auto * ref : uart_test_configs) {
439
+ UARTTestConfig & config = *ref;
438
440
Wire.begin (config.default_rx_pin , config.default_tx_pin );
439
441
config.recv_msg = " " ;
440
442
@@ -465,8 +467,8 @@ void change_cpu_frequency_test(void) {
465
467
466
468
Serial.updateBaudRate (115200 );
467
469
468
- for (auto * ref : uart_test_configs) {
469
- UARTTestConfig& config = *ref;
470
+ for (auto * ref : uart_test_configs) {
471
+ UARTTestConfig & config = *ref;
470
472
log_d (" Trying to send message with the new CPU frequency on UART%d" , config.uart_num );
471
473
config.transmit_and_check_msg (" with new CPU frequency" );
472
474
}
@@ -477,8 +479,8 @@ void change_cpu_frequency_test(void) {
477
479
478
480
Serial.updateBaudRate (115200 );
479
481
480
- for (auto * ref : uart_test_configs) {
481
- UARTTestConfig& config = *ref;
482
+ for (auto * ref : uart_test_configs) {
483
+ UARTTestConfig & config = *ref;
482
484
log_d (" Trying to send message with the original CPU frequency on UART%d" , config.uart_num );
483
485
config.transmit_and_check_msg (" with the original CPU frequency" );
484
486
}
@@ -496,7 +498,7 @@ void setup() {
496
498
497
499
uart_test_configs = {
498
500
#if SOC_UART_HP_NUM >= 2 && defined(RX1) && defined(TX1)
499
- // inverting RX1<->TX1 because ESP32-P4 has a problem with loopback on RX1 :: GPIO11 <-- UART_TX SGINAL
501
+ // inverting RX1<->TX1 because ESP32-P4 has a problem with loopback on RX1 :: GPIO11 <-- UART_TX SGINAL
500
502
new UARTTestConfig (1 , Serial1, TX1, RX1),
501
503
#endif
502
504
#if SOC_UART_HP_NUM >= 3 && defined(RX2) && defined(TX2)
@@ -517,8 +519,8 @@ void setup() {
517
519
518
520
log_d (" TEST_UART_NUM = %d" , TEST_UART_NUM);
519
521
520
- for (auto * ref : uart_test_configs) {
521
- UARTTestConfig& config = *ref;
522
+ for (auto * ref : uart_test_configs) {
523
+ UARTTestConfig & config = *ref;
522
524
config.begin (115200 );
523
525
log_d (" Setup internal loop-back from and back to UART%d TX >> UART%d RX" , config.uart_num , config.uart_num );
524
526
config.serial .onReceive ([&config]() {
0 commit comments