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 11HardwareSerial hwSerial (0 );
22HardwareSerial hwSerial2 (2 );
33
4- bool ok = true ;
5-
64static void IRAM_ATTR onSerialRX (uint8_t c, void * user_arg){
75 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);
910}
1011
1112void setup ()
1213{
1314 hwSerial.begin (115200 );
1415 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*
1519 hwSerial2.setRxInterrupt (onSerialRX, (void *)&hwSerial2);
1620}
1721
You can’t perform that action at this time.
0 commit comments