We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent be5000b commit 6d7e8ebCopy full SHA for 6d7e8eb
libraries/ESP32/examples/Serial/Interrupt/Interrupt.ino
@@ -1,17 +1,21 @@
1
HardwareSerial hwSerial(0);
2
HardwareSerial hwSerial2(2);
3
4
-bool ok = true;
5
-
6
static void IRAM_ATTR onSerialRX(uint8_t c, void* user_arg){
7
hwSerial.print(c);
8
- ((HardwareSerial*)user_arg)->print(c);
+
+ // Cast the user_arg containing a void* to the Serial device, to HardwareSerial* to be used
+ HardwareSerial* serial = (HardwareSerial*)user_arg;
9
+ serial->print(c);
10
}
11
12
void setup()
13
{
14
hwSerial.begin(115200);
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*
19
hwSerial2.setRxInterrupt(onSerialRX, (void*)&hwSerial2);
20
21
0 commit comments