Skip to content

[2.0.0] Adds the setRXInterrupt #4656

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 46 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
4d262c5
Merge pull request #1 from espressif/master
timkoers Dec 23, 2020
a4df65f
Added UART RX interrupt function
timkoers Dec 23, 2020
b20b3cd
Merge branch 'master' of github.com:timkoers/arduino-esp32
timkoers Dec 23, 2020
725ad11
Updated HardwareSerial class with the interrupt functions
timkoers Dec 23, 2020
e8272c7
Added Serial 'tests' for Interrupt and stock code
timkoers Dec 23, 2020
623796a
This should add the Serial interrupt and no interrupt ino's to the co…
timkoers Dec 23, 2020
000482e
Platform IO sketch sources are messing everything up
timkoers Dec 23, 2020
2e657a7
Platform IO install script fixed
timkoers Dec 23, 2020
38914ff
Arduino Core install script fixed
timkoers Dec 23, 2020
8a27284
Fixed HardwareSerial setRXInterrupt argument type
timkoers Dec 23, 2020
ba351a8
Whoopsie
timkoers Dec 23, 2020
8db7e7f
tested and verified to work
timkoers Dec 24, 2020
96fa55f
Should fix compilation error
timkoers Dec 29, 2020
7d84946
Rewrite of the interrupt handlers for the uart devs
timkoers Jan 8, 2021
054c1a9
Should fix compilation error
timkoers Jan 8, 2021
c344425
Better use else if, or else the input get's duplicated whilest it is …
timkoers Jan 8, 2021
1ba43fc
Updated code formatting and removed commented lines from ci test scripts
timkoers Jan 12, 2021
cadb74d
Updated code formatting once again
timkoers Jan 12, 2021
02b29fd
Last code formatting fix
timkoers Jan 12, 2021
d63d896
Accidentally removed some args whilest formatting the code
timkoers Jan 12, 2021
7bea5a4
Free the interupt from the array on enable/disable of the interrupt, …
timkoers Jan 12, 2021
def8f9c
Renamed the interrupt management functions
timkoers Jan 12, 2021
21043d5
Removed tests from Windows and Mac
timkoers Jan 12, 2021
55ae3be
Fixed setRxInterrupt in HardwareSerial.cpp and fixed double deletion …
timkoers Jan 12, 2021
be5000b
Resolved the if statements
timkoers Jan 12, 2021
6d7e8eb
Cleaned up and commented the Interrupt example
timkoers Jan 12, 2021
e3298ea
Changed serials to Serial and Serial2
timkoers Jan 12, 2021
3bfadf8
Changed example to buffer
timkoers Jan 12, 2021
8cda769
Fixed compilation error
timkoers Jan 12, 2021
36ebb83
Fixed compilation error
timkoers Jan 12, 2021
cf98504
Lost my focus a bit, I think
timkoers Jan 12, 2021
0b2ae4e
Updated uart hal code, with comments regarding the interrupt clearing…
timkoers Jan 12, 2021
715f399
Reverted scripts back to it's original form
timkoers Jan 12, 2021
4f80e57
Reverted on-push to stock form
timkoers Jan 12, 2021
f33c332
Fixed ISR concurrency problems in example
timkoers Jan 12, 2021
5beb727
Update on-push.sh
timkoers Jan 12, 2021
52b8a41
Update on-push.sh
timkoers Jan 12, 2021
f948c78
Replaced tabs with spaces ;-)
timkoers Jan 13, 2021
4441190
And fixed the remaining things
timkoers Jan 13, 2021
ce3952d
Fixed whitespace refactoring and compilation error
timkoers Jan 13, 2021
d8f54ee
Added documentation to the examples and added another Interrupt handl…
timkoers Jan 17, 2021
b3511e5
Don't forget to actually add the example ;-)
timkoers Jan 17, 2021
32a7446
Fixed wrong define name
timkoers Jan 17, 2021
f89b634
Added include for queue.h
timkoers Jan 17, 2021
41a869a
Not sure how I got confused with Queue_t, but fixed
timkoers Jan 17, 2021
12b8725
Fixed
timkoers Jan 17, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fixed ISR concurrency problems in example
  • Loading branch information
timkoers committed Jan 12, 2021
commit f33c3322f34c898b38b7924e92f27aeb80ac013b
18 changes: 15 additions & 3 deletions libraries/ESP32/examples/Serial/Interrupt/Interrupt.ino
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#define BUFFER_SIZE 8

// This semaphore is here to handle the interruption of the loop when the interrupt is running.
SemaphoreHandle_t bufferSemaphore;

static volatile char inputBuffer[BUFFER_SIZE];
static volatile size_t inputBufferLength = 0;

Expand All @@ -10,13 +13,20 @@ static void IRAM_ATTR onSerialRX(uint8_t character, void* user_arg){
// Cast the user_arg back to a array
char* buffer = (char*)user_arg;

if(inputBufferLength < BUFFER_SIZE){
buffer[inputBufferLength++] = (char)character;
BaseType_t xHighPriorityTaskWoken;

if(xSemaphoreTakeFromISR(bufferSemaphore, &xHighPriorityTaskWoken) == pdTRUE){
if(inputBufferLength < BUFFER_SIZE){
buffer[inputBufferLength++] = (char)character;
}
xSemaphoreGiveFromISR(bufferSemaphore, &xHighPriorityTaskWoken);
}
}

void setup()
{
bufferSemaphore = xSemaphoreCreateBinary();

Serial.begin(115200);
Serial2.begin(115200);

Expand All @@ -27,7 +37,7 @@ void setup()

void loop()
{
if(inputBufferLength == (BUFFER_SIZE - 1)){
if(xSemaphoreTake(bufferSemaphore, portMAX_DELAY) == pdTRUE && inputBufferLength == (BUFFER_SIZE - 1)){
for(size_t i = 0; i < inputBufferLength; i++){
Serial.write(inputBuffer[i]);

Expand All @@ -36,6 +46,8 @@ void loop()
}
// Clear the bufferLength
inputBufferLength = 0;

xSemaphoreGive(bufferSemaphore);
}

delay(1000); // Wait for one second
Expand Down