@@ -95,9 +95,11 @@ public:
9595
9696/* Utility global variables */
9797
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;
101103
102104/* Utility functions */
103105
@@ -119,8 +121,8 @@ void task_delayed_msg(void *pvParameters) {
119121
120122// This function is automatically called by unity before each test is run
121123void setUp (void ) {
122- for (auto * ref : uart_test_configs) {
123- UARTTestConfig& config = *ref;
124+ for (auto * ref : uart_test_configs) {
125+ UARTTestConfig & config = *ref;
124126 // log_d("Setup internal loop-back from and back to UART%d TX >> UART%d RX", config.uart_num, config.uart_num);
125127 config.begin (115200 );
126128 config.serial .onReceive ([&config]() {
@@ -132,8 +134,8 @@ void setUp(void) {
132134
133135// This function is automatically called by unity after each test is run
134136void tearDown (void ) {
135- for (auto * ref : uart_test_configs) {
136- UARTTestConfig& config = *ref;
137+ for (auto * ref : uart_test_configs) {
138+ UARTTestConfig & config = *ref;
137139 config.end ();
138140 }
139141}
@@ -144,8 +146,8 @@ void tearDown(void) {
144146void basic_transmission_test (void ) {
145147 log_d (" Performing basic transmission test" );
146148
147- for (auto * ref : uart_test_configs) {
148- UARTTestConfig& config = *ref;
149+ for (auto * ref : uart_test_configs) {
150+ UARTTestConfig & config = *ref;
149151 config.transmit_and_check_msg (" " );
150152 }
151153
@@ -154,8 +156,8 @@ void basic_transmission_test(void) {
154156
155157// This test checks if the baudrate can be changed and if the message can be transmitted and received correctly after the change
156158void 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;
159161 log_d (" Changing baudrate of UART%d to 9600" , config.uart_num );
160162
161163 // Baudrate error should be within 2% of the target baudrate
@@ -203,8 +205,8 @@ void resize_buffers_test(void) {
203205// This test checks if the begin function can be called when the UART is already running
204206void begin_when_running_test (void ) {
205207 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;
208210 // Calling twice should not crash
209211 config.begin (115200 );
210212 config.begin (115200 );
@@ -216,8 +218,8 @@ void begin_when_running_test(void) {
216218void end_when_stopped_test (void ) {
217219 log_d (" Trying to end serial twice" );
218220
219- for (auto * ref : uart_test_configs) {
220- UARTTestConfig& config = *ref;
221+ for (auto * ref : uart_test_configs) {
222+ UARTTestConfig & config = *ref;
221223 // Calling twice should not crash
222224 config.end ();
223225 config.end ();
@@ -281,8 +283,8 @@ void disabled_uart_calls_test(void) {
281283 int integer_ret;
282284 uint8_t test_buf[1 ];
283285
284- for (auto * ref : uart_test_configs) {
285- UARTTestConfig& config = *ref;
286+ for (auto * ref : uart_test_configs) {
287+ UARTTestConfig & config = *ref;
286288 config.end ();
287289 }
288290
@@ -354,15 +356,15 @@ void disabled_uart_calls_test(void) {
354356void change_pins_test (void ) {
355357 log_d (" Disabling UART loopback" );
356358
357- for (auto * ref : uart_test_configs) {
358- UARTTestConfig& config = *ref;
359+ for (auto * ref : uart_test_configs) {
360+ UARTTestConfig & config = *ref;
359361 esp_rom_gpio_connect_out_signal (config.default_rx_pin , SIG_GPIO_OUT_IDX, false , false );
360362 }
361363
362364 log_d (" Swapping UART pins and testing transmission" );
363365
364366 if (TEST_UART_NUM == 1 ) {
365- UARTTestConfig& config = *uart_test_configs[0 ];
367+ UARTTestConfig & config = *uart_test_configs[0 ];
366368 config.serial .setPins (NEW_RX1, NEW_TX1);
367369 TEST_ASSERT_EQUAL (NEW_RX1, uart_get_RxPin (config.uart_num ));
368370 TEST_ASSERT_EQUAL (NEW_TX1, uart_get_TxPin (config.uart_num ));
@@ -371,8 +373,8 @@ void change_pins_test(void) {
371373 config.transmit_and_check_msg (" using new pins" );
372374 } else {
373375 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];
376378 config.serial .setPins (next_uart.default_rx_pin , next_uart.default_tx_pin );
377379 TEST_ASSERT_EQUAL (uart_get_RxPin (config.uart_num ), next_uart.default_rx_pin );
378380 TEST_ASSERT_EQUAL (uart_get_TxPin (config.uart_num ), next_uart.default_tx_pin );
@@ -433,8 +435,8 @@ void periman_test(void) {
433435
434436 log_d (" Setting up I2C on the same pins as UART" );
435437
436- for (auto * ref : uart_test_configs) {
437- UARTTestConfig& config = *ref;
438+ for (auto * ref : uart_test_configs) {
439+ UARTTestConfig & config = *ref;
438440 Wire.begin (config.default_rx_pin , config.default_tx_pin );
439441 config.recv_msg = " " ;
440442
@@ -465,8 +467,8 @@ void change_cpu_frequency_test(void) {
465467
466468 Serial.updateBaudRate (115200 );
467469
468- for (auto * ref : uart_test_configs) {
469- UARTTestConfig& config = *ref;
470+ for (auto * ref : uart_test_configs) {
471+ UARTTestConfig & config = *ref;
470472 log_d (" Trying to send message with the new CPU frequency on UART%d" , config.uart_num );
471473 config.transmit_and_check_msg (" with new CPU frequency" );
472474 }
@@ -477,8 +479,8 @@ void change_cpu_frequency_test(void) {
477479
478480 Serial.updateBaudRate (115200 );
479481
480- for (auto * ref : uart_test_configs) {
481- UARTTestConfig& config = *ref;
482+ for (auto * ref : uart_test_configs) {
483+ UARTTestConfig & config = *ref;
482484 log_d (" Trying to send message with the original CPU frequency on UART%d" , config.uart_num );
483485 config.transmit_and_check_msg (" with the original CPU frequency" );
484486 }
@@ -496,7 +498,7 @@ void setup() {
496498
497499 uart_test_configs = {
498500#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
500502 new UARTTestConfig (1 , Serial1, TX1, RX1),
501503#endif
502504#if SOC_UART_HP_NUM >= 3 && defined(RX2) && defined(TX2)
@@ -517,8 +519,8 @@ void setup() {
517519
518520 log_d (" TEST_UART_NUM = %d" , TEST_UART_NUM);
519521
520- for (auto * ref : uart_test_configs) {
521- UARTTestConfig& config = *ref;
522+ for (auto * ref : uart_test_configs) {
523+ UARTTestConfig & config = *ref;
522524 config.begin (115200 );
523525 log_d (" Setup internal loop-back from and back to UART%d TX >> UART%d RX" , config.uart_num , config.uart_num );
524526 config.serial .onReceive ([&config]() {
0 commit comments