Skip to content

CI: Add UART test #8801

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions cores/esp32/esp32-hal-uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ bool uartSetPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t ctsPin, in
UART_MUTEX_UNLOCK();

if (!retCode) {
log_e("UART%d set pins failed.");
log_e("UART%d set pins failed.", uart_num);
}
return retCode;
}
Expand Down Expand Up @@ -958,7 +958,7 @@ unsigned long uartDetectBaudrate(uart_t *uart)
}

/*
These functions are for testing puspose only and can be used in Arduino Sketches
These functions are for testing purpose only and can be used in Arduino Sketches
Those are used in the UART examples
*/

Expand All @@ -968,15 +968,17 @@ unsigned long uartDetectBaudrate(uart_t *uart)
This code "replaces" the physical wiring for connecting TX <--> RX in a loopback
*/

// gets the right TX SIGNAL, based on the UART number
// gets the right TX or RX SIGNAL, based on the UART number from gpio_sig_map.h
#if SOC_UART_NUM > 2
#define UART_TX_SIGNAL(uartNumber) (uartNumber == UART_NUM_0 ? U0TXD_OUT_IDX : (uartNumber == UART_NUM_1 ? U1TXD_OUT_IDX : U2TXD_OUT_IDX))
#define UART_TX_SIGNAL(uartNumber) (uartNumber == UART_NUM_0 ? U0TXD_OUT_IDX : (uartNumber == UART_NUM_1 ? U1TXD_OUT_IDX : U2TXD_OUT_IDX))
#define UART_RX_SIGNAL(uartNumber) (uartNumber == UART_NUM_0 ? U0RXD_IN_IDX : (uartNumber == UART_NUM_1 ? U1RXD_IN_IDX : U2RXD_IN_IDX))
#else
#define UART_TX_SIGNAL(uartNumber) (uartNumber == UART_NUM_0 ? U0TXD_OUT_IDX : U1TXD_OUT_IDX)
#define UART_TX_SIGNAL(uartNumber) (uartNumber == UART_NUM_0 ? U0TXD_OUT_IDX : U1TXD_OUT_IDX)
#define UART_RX_SIGNAL(uartNumber) (uartNumber == UART_NUM_0 ? U0RXD_IN_IDX : U1RXD_IN_IDX)
#endif
/*
Make sure UART's RX signal is connected to TX pin
This creates a loop that lets us receive anything we send on the UART
This function internally binds defined UARTs TX signal with defined RX pin of any UART (same or different).
This creates a loop that lets us receive anything we send on the UART without external wires.
*/
void uart_internal_loopback(uint8_t uartNum, int8_t rxPin)
{
Expand Down Expand Up @@ -1008,4 +1010,4 @@ int uart_send_msg_with_break(uint8_t uartNum, uint8_t *msg, size_t msgSize)
return uart_write_bytes_with_break(uartNum, (const void *)msg, msgSize, 12);
}

#endif /* SOC_UART_SUPPORTED */
#endif /* SOC_UART_SUPPORTED */
2 changes: 2 additions & 0 deletions tests/uart/test_uart.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def test_uart(dut):
dut.expect_unity_test_output(timeout=120)
Loading