Revert "No xPortInIsrContext() on nRF52..."

This reverts commit cea129c164.
This commit is contained in:
WillyJL 2025-09-24 04:12:38 +02:00
parent cea129c164
commit 81c703dfc1
No known key found for this signature in database
6 changed files with 15 additions and 15 deletions

View File

@ -18,18 +18,18 @@ void InputBroker::registerSource(Observable<const InputEvent *> *source)
} }
#ifdef HAS_FREE_RTOS #ifdef HAS_FREE_RTOS
void InputBroker::requestPollSoon(InputPollable *pollable, bool fromIsr) void InputBroker::requestPollSoon(InputPollable *pollable)
{ {
if (fromIsr) { if (xPortInIsrContext() == pdTRUE) {
xQueueSendFromISR(pollSoonQueue, &pollable, NULL); xQueueSendFromISR(pollSoonQueue, &pollable, NULL);
} else { } else {
xQueueSend(pollSoonQueue, &pollable, 0); xQueueSend(pollSoonQueue, &pollable, 0);
} }
} }
void InputBroker::queueInputEvent(const InputEvent *event, bool fromIsr) void InputBroker::queueInputEvent(const InputEvent *event)
{ {
if (fromIsr) { if (xPortInIsrContext() == pdTRUE) {
xQueueSendFromISR(inputEventQueue, event, NULL); xQueueSendFromISR(inputEventQueue, event, NULL);
} else { } else {
xQueueSend(inputEventQueue, event, portMAX_DELAY); xQueueSend(inputEventQueue, event, portMAX_DELAY);

View File

@ -60,8 +60,8 @@ class InputBroker : public Observable<const InputEvent *>
void registerSource(Observable<const InputEvent *> *source); void registerSource(Observable<const InputEvent *> *source);
void injectInputEvent(const InputEvent *event) { handleInputEvent(event); } void injectInputEvent(const InputEvent *event) { handleInputEvent(event); }
#ifdef HAS_FREE_RTOS #ifdef HAS_FREE_RTOS
void requestPollSoon(InputPollable *pollable, bool fromIsr); void requestPollSoon(InputPollable *pollable);
void queueInputEvent(const InputEvent *event, bool fromIsr); void queueInputEvent(const InputEvent *event);
void processInputEventQueue(); void processInputEventQueue();
#endif #endif

View File

@ -102,7 +102,7 @@ void TCA8418KeyboardBase::reset()
void TCA8418KeyboardBase::attachInterruptHandler() void TCA8418KeyboardBase::attachInterruptHandler()
{ {
interruptInstance = this; interruptInstance = this;
auto interruptHandler = []() { interruptInstance->notifyObservers(true); }; auto interruptHandler = []() { interruptInstance->notifyObservers(interruptInstance); };
attachInterrupt(KB_INT, interruptHandler, FALLING); attachInterrupt(KB_INT, interruptHandler, FALLING);
} }
@ -126,7 +126,7 @@ int TCA8418KeyboardBase::beforeLightSleep(void *unused)
int TCA8418KeyboardBase::afterLightSleep(esp_sleep_wakeup_cause_t cause) int TCA8418KeyboardBase::afterLightSleep(esp_sleep_wakeup_cause_t cause)
{ {
attachInterruptHandler(); attachInterruptHandler();
this->notifyObservers(false); // Trigger a one-off poll in case a keypress woke us this->notifyObservers(this); // Trigger a one-off poll in case a keypress woke us
return 0; // Indicates success return 0; // Indicates success
} }
#endif // ARCH_ESP32 #endif // ARCH_ESP32

View File

@ -130,7 +130,7 @@ void KbI2cBase::pollOnce()
} }
if (e.inputEvent != INPUT_BROKER_NONE) { if (e.inputEvent != INPUT_BROKER_NONE) {
LOG_DEBUG("TCA8418 Notifying: %i Char: %c", e.inputEvent, e.kbchar); LOG_DEBUG("TCA8418 Notifying: %i Char: %c", e.inputEvent, e.kbchar);
inputBroker->queueInputEvent(&e, false); inputBroker->queueInputEvent(&e);
} }
} }
#endif #endif
@ -637,11 +637,11 @@ void KbI2cBase::toggleBacklight(bool on)
#endif #endif
} }
int KbI2cBase::onNotify(bool fromIsr) int KbI2cBase::onNotify(KbInterruptObservable *src)
{ {
// Called from interrupt context, request polling after exiting the ISR // Called from interrupt context, request polling after exiting the ISR
#ifdef KB_INT #ifdef KB_INT
inputBroker->requestPollSoon(this, fromIsr); inputBroker->requestPollSoon(this);
#endif #endif
return 0; return 0;
} }

View File

@ -20,7 +20,7 @@ class KbI2cBase : public Observable<const InputEvent *>,
virtual void pollOnce() override; virtual void pollOnce() override;
protected: protected:
virtual int onNotify(bool fromIsr) override; virtual int onNotify(KbInterruptObservable *src) override;
virtual int32_t runOnce() override; virtual int32_t runOnce() override;
private: private:

View File

@ -2,10 +2,10 @@
#include "Observer.h" #include "Observer.h"
class KbInterruptObservable : public Observable<bool> class KbInterruptObservable : public Observable<KbInterruptObservable *>
{ {
}; };
class KbInterruptObserver : public Observer<bool> class KbInterruptObserver : public Observer<KbInterruptObservable *>
{ {
}; };