Skip to content

Commit

Permalink
CI: Add UART test (#8801)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasssvaz authored Oct 25, 2023
1 parent f04b7d9 commit 49644c1
Show file tree
Hide file tree
Showing 3 changed files with 595 additions and 8 deletions.
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

0 comments on commit 49644c1

Please sign in to comment.