@@ -35,13 +35,23 @@ String last_test = "";
35
35
int8_t uart1_rx_pin;
36
36
int8_t uart1_tx_pin;
37
37
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
+
38
48
/* Unity functions */
39
49
40
50
// This function is automatically called by unity before each test is run
41
51
void setUp (void ) {
42
52
log_v (" Setting up next test" );
43
53
Serial1.setPins (uart1_rx_pin, uart1_tx_pin);
44
- uart_internal_loopback (1 , SOC_RX0 );
54
+ uart_internal_loopback (1 , RX1 );
45
55
delay (100 );
46
56
log_v (" Running test" );
47
57
}
@@ -54,7 +64,7 @@ void tearDown(void) {
54
64
Serial1.flush ();
55
65
56
66
Serial1.setPins (uart1_rx_pin, uart1_tx_pin);
57
- uart_internal_loopback (1 , SOC_RX0 );
67
+ uart_internal_loopback (1 , RX1 );
58
68
delay (100 );
59
69
Serial1.print (last_test);
60
70
Serial1.println (" test: This should be printed" );
@@ -180,12 +190,10 @@ void touch_test(void) {
180
190
}
181
191
#endif
182
192
183
- #if SOC_GPSPI_SUPPORTED || CONFIG_ETH_USE_ESP32_EMAC
184
193
void eth_test (void ) {
185
194
ETH.begin ();
186
195
last_test = " ETH" ;
187
196
}
188
- #endif
189
197
190
198
/* Main functions */
191
199
@@ -196,7 +204,8 @@ void setup() {
196
204
Serial1.setPins (UART1_RX_DEFAULT, UART1_TX_DEFAULT);
197
205
Serial1.begin (115200 );
198
206
while (!Serial1) { delay (10 ); }
199
- uart_internal_loopback (1 , SOC_RX0);
207
+ Serial1.onReceive ([]() {onReceive_cb ();});
208
+ uart_internal_loopback (1 , RX1);
200
209
201
210
UNITY_BEGIN ();
202
211
0 commit comments