File tree 1 file changed +9
-4
lines changed
libraries/ESP32/examples/Serial/onReceiveExample
1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -86,13 +86,18 @@ void UART0_RX_CB() {
86
86
// setup() and loop() are functions executed by a low priority task
87
87
// Therefore, there are 2 tasks running when using onReceive()
88
88
void setup () {
89
+ UART0.begin (115200 );
90
+
89
91
// creates a mutex object to control access to uart_buffer
90
92
uart_buffer_Mutex = xSemaphoreCreateMutex ();
91
93
if (uart_buffer_Mutex == NULL ) {
92
- log_e (" Error creating Mutex. Sketch will fail." );
93
- delay (1000 );
94
+ log_e (" Error creating Mutex. Sketch will fail." );
95
+ while (true ) {
96
+ UART0.println (" Mutex error (NULL). Program halted." );
97
+ delay (2000 );
98
+ }
94
99
}
95
- UART0. begin ( 115200 );
100
+
96
101
UART0.onReceive (UART0_RX_CB); // sets the callback function
97
102
UART0.println (" Send data to UART0 in order to activate the RX callback" );
98
103
}
@@ -113,7 +118,7 @@ void loop() {
113
118
// releases the mutex for more data to be received
114
119
xSemaphoreGive (uart_buffer_Mutex);
115
120
}
116
- }
121
+ }
117
122
UART0.println (" Sleeping for 1 second..." );
118
123
delay (1000 );
119
124
}
You can’t perform that action at this time.
0 commit comments