help with understandig freeRTOS code
Posted: Fri Jan 08, 2021 8:42 pm
dear espressif forum,
I have used a bit of code but i don't understand fully how it works and what the variables do.
This code is used for reading a encoder value and so it needed to be an interupt.
what i don't understand are these 2 things:
I know what xQueueSendToBackFromISR does.
It sends the value that's in currentReading to encoderQueue back to code that isn't part of the ISR. The last bit is how long it should wait.
what does &pxHigherPriorityTaskWoken mean or do?
I have used a bit of code but i don't understand fully how it works and what the variables do.
This code is used for reading a encoder value and so it needed to be an interupt.
Code: Select all
void ESP_ISR callBack(Encoder & enc) {
BaseType_t pxHigherPriorityTaskWoken = pdFALSE;
static int16_t lastReading = 0;
int16_t currentReading = enc;
if (currentReading != lastReading) {
lastReading = currentReading;
xQueueSendToBackFromISR(encoderQueue, ¤tReading, &pxHigherPriorityTaskWoken);
if (pxHigherPriorityTaskWoken) {
portYIELD_FROM_ISR();
}
}
}
Code: Select all
BaseType_t pxHigherPriorityTaskWoken = pdFALSE;
Code: Select all
if (pxHigherPriorityTaskWoken) {
portYIELD_FROM_ISR();
}
Code: Select all
xQueueSendToBackFromISR(encoderQueue, ¤tReading, &pxHigherPriorityTaskWoken);
what does &pxHigherPriorityTaskWoken mean or do?