Skip to content

Commit c329742

Browse files
authored
fix(uart): Refactor UART test to detach only one pin
Updated UART test configuration to detach only one pin instead of both, ensuring the UART driver continues to function. Removed redundant code related to UART driver restart when both pins are detached.
1 parent 51a912c commit c329742

File tree

1 file changed

+4
-26
lines changed

1 file changed

+4
-26
lines changed

tests/validation/uart/uart.ino

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,9 @@ void periman_test(void) {
450450

451451
for (auto *ref : uart_test_configs) {
452452
UARTTestConfig &config = *ref;
453-
// when both RX and TX are detached the UART driver is stopped,
454-
// therefore, it may change just one the UART pins for testing
455-
Wire.begin(config.default_rx_pin, -1);
453+
// detaching both pins will result in stoping the UART driver
454+
// Only detach one of the pins
455+
Wire.begin(config.default_rx_pin, /*config.default_tx_pin*/ -1);
456456
config.recv_msg = "";
457457

458458
log_d("Trying to send message using UART%d with I2C enabled", config.uart_num);
@@ -461,30 +461,7 @@ void periman_test(void) {
461461

462462
log_d("Disabling I2C and re-enabling UART%d", config.uart_num);
463463

464-
// when just chenging one UART pin, the driver will continue to work
465-
// and it is possible to just change back the UART pins
466464
config.serial.setPins(config.default_rx_pin, config.default_tx_pin);
467-
468-
uart_internal_loopback(config.uart_num, config.default_rx_pin);
469-
470-
log_d("Trying to send message using UART%d with I2C disabled", config.uart_num);
471-
config.transmit_and_check_msg("while I2C is disabled");
472-
473-
474-
// when both RX and TX are detached the UART driver is stopped,
475-
// Therefore, it needs to be restarted
476-
Wire.begin(config.default_rx_pin, config.default_tx_pin);
477-
config.recv_msg = "";
478-
479-
log_d("Trying to send message using UART%d with I2C enabled", config.uart_num);
480-
config.transmit_and_check_msg("while used by I2C", false);
481-
TEST_ASSERT_EQUAL_STRING("", config.recv_msg.c_str());
482-
483-
log_d("Disabling I2C and re-enabling UART%d", config.uart_num);
484-
485-
// when both RX and TX are detached the UART driver is stopped, therefore, starting the driver again is necessary
486-
config.serial.begin(115200, SERIAL_8N1, config.default_rx_pin, config.default_tx_pin);
487-
488465
uart_internal_loopback(config.uart_num, config.default_rx_pin);
489466

490467
log_d("Trying to send message using UART%d with I2C disabled", config.uart_num);
@@ -493,6 +470,7 @@ void periman_test(void) {
493470

494471
Serial.println("Peripheral manager test successful");
495472
}
473+
496474
// This test checks if messages can be transmitted and received correctly after changing the CPU frequency
497475
void change_cpu_frequency_test(void) {
498476
uint32_t old_freq = getCpuFrequencyMhz();

0 commit comments

Comments
 (0)