@@ -35,13 +35,23 @@ String last_test = "";
3535int8_t uart1_rx_pin;
3636int8_t uart1_tx_pin;
3737
38+ /* Callback functions */
39+
40+ void onReceive_cb (void ) {
41+ // This is a callback function that will be activated on UART RX events
42+ size_t available = Serial1.available ();
43+ while (available --) {
44+ Serial.print ((char )Serial1.read ());
45+ }
46+ }
47+
3848/* Unity functions */
3949
4050// This function is automatically called by unity before each test is run
4151void setUp (void ) {
4252 log_v (" Setting up next test" );
4353 Serial1.setPins (uart1_rx_pin, uart1_tx_pin);
44- uart_internal_loopback (1 , SOC_RX0 );
54+ uart_internal_loopback (1 , RX1 );
4555 delay (100 );
4656 log_v (" Running test" );
4757}
@@ -54,7 +64,7 @@ void tearDown(void) {
5464 Serial1.flush ();
5565
5666 Serial1.setPins (uart1_rx_pin, uart1_tx_pin);
57- uart_internal_loopback (1 , SOC_RX0 );
67+ uart_internal_loopback (1 , RX1 );
5868 delay (100 );
5969 Serial1.print (last_test);
6070 Serial1.println (" test: This should be printed" );
@@ -180,12 +190,10 @@ void touch_test(void) {
180190}
181191#endif
182192
183- #if SOC_GPSPI_SUPPORTED || CONFIG_ETH_USE_ESP32_EMAC
184193void eth_test (void ) {
185194 ETH.begin ();
186195 last_test = " ETH" ;
187196}
188- #endif
189197
190198/* Main functions */
191199
@@ -196,7 +204,8 @@ void setup() {
196204 Serial1.setPins (UART1_RX_DEFAULT, UART1_TX_DEFAULT);
197205 Serial1.begin (115200 );
198206 while (!Serial1) { delay (10 ); }
199- uart_internal_loopback (1 , SOC_RX0);
207+ Serial1.onReceive ([]() {onReceive_cb ();});
208+ uart_internal_loopback (1 , RX1);
200209
201210 UNITY_BEGIN ();
202211
0 commit comments