File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
libraries/ESP32/examples/Serial/Interrupt Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 1
1
HardwareSerial hwSerial (0 );
2
2
HardwareSerial hwSerial2 (2 );
3
3
4
- bool ok = true ;
5
-
6
4
static void IRAM_ATTR onSerialRX (uint8_t c, void * user_arg){
7
5
hwSerial.print (c);
8
- ((HardwareSerial*)user_arg)->print (c);
6
+
7
+ // Cast the user_arg containing a void* to the Serial device, to HardwareSerial* to be used
8
+ HardwareSerial* serial = (HardwareSerial*)user_arg;
9
+ serial->print (c);
9
10
}
10
11
11
12
void setup ()
12
13
{
13
14
hwSerial.begin (115200 );
14
15
hwSerial2.begin (115200 );
16
+
17
+ // The user_arg is expected to be a void pointer (void*),
18
+ // so take the reference of hwSerial2, and cast the HardwareSerial* to a void*
15
19
hwSerial2.setRxInterrupt (onSerialRX, (void *)&hwSerial2);
16
20
}
17
21
You can’t perform that action at this time.
0 commit comments