8000 Rewrite of the interrupt handlers for the uart devs · timkoers/arduino-esp32@7d84946 · GitHub
[go: up one dir, main page]

8000 Skip to content

Commit 7d84946

Browse files
committed
Rewrite of the interrupt handlers for the uart devs
1 parent 96fa55f commit 7d84946

File tree

5 files changed

+288
-167
lines changed

5 files changed

+288
-167
lines changed

cores/esp32/HardwareSerial.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,15 @@ void HardwareSerial::updateBaudRate(unsigned long baud)
8484
}
8585

8686
// Make sure that the function that the function pointer is pointing to is inside IRAM
87-
void HardwareSerial::setRXInterrupt(void (*arg)(char c)){
87+
void HardwareSerial::setRXInterrupt(void (*arg)(uint8_t, void*), void* user_arg){
88+
89+
// Make sure that the previous interrupt_info is not used anymore
8890
uartDisableInterrupt(_uart);
89-
uartEnableInterrupt(_uart, arg);
91+
92+
if(interrupt_info)
93+
delete(interrupt_info);
94+
95+
uartEnableInterrupt(_uart, &interrupt_info, arg, user_arg);
9096
}
9197

9298
void HardwareSerial::end()

cores/esp32/HardwareSerial.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
Modified 31 March 2015 by Markus Sattler (rewrite the code for UART0 + UART1 support in ESP8266)
2424
Modified 25 April 2015 by Thomas Flayols (add configuration different from 8N1 in ESP8266)
2525
Modified 13 October 2018 by Jeroen Döll (add baudrate detection)
26+
Modified 08 januari 2012 by Tim Koers (added RX IRQ handling)
2627
Baudrate detection example usage (detection on Serial1):
2728
void setup() {
2829
Serial.begin(115200);
@@ -58,7 +59,7 @@ class HardwareSerial: public Stream
5859
void begin(unsigned long baud, uint32_t config=SERIAL_8N1, int8_t rxPin=-1, int8_t txPin=-1, bool invert=false, unsigned long timeout_ms = 20000UL);
5960
void end();
6061
void updateBaudRate(unsigned long baud);
61-
void setRXInterrupt(void (*arg)(char));
62+
void setRXInterrupt(void (*arg)(uint8_t, void*), void* user_arg);
6263
int available(void);
6364
int availableForWrite(< 6B39 span class="pl-k">void);
6465
int peek(void);
@@ -109,6 +110,7 @@ class HardwareSerial: public Stream
109110
uart_t* _uart;
110111
uint8_t _tx_pin;
111112
uint8_t _rx_pin;
113+
uart_interrupt_struct_t* interrupt_info;
112114
};
113115

114116
extern void serialEventRun(void) __attribute__((weak));

0 commit comments

Comments
 (0)
0