mirror of
https://github.com/meshtastic/firmware.git
synced 2025-10-28 07:13:25 +00:00
No xPortInIsrContext() on nRF52...
This commit is contained in:
parent
3171937f4d
commit
cea129c164
@ -18,18 +18,18 @@ void InputBroker::registerSource(Observable<const InputEvent *> *source)
|
||||
}
|
||||
|
||||
#ifdef HAS_FREE_RTOS
|
||||
void InputBroker::requestPollSoon(InputPollable *pollable)
|
||||
void InputBroker::requestPollSoon(InputPollable *pollable, bool fromIsr)
|
||||
{
|
||||
if (xPortInIsrContext() == pdTRUE) {
|
||||
if (fromIsr) {
|
||||
xQueueSendFromISR(pollSoonQueue, &pollable, NULL);
|
||||
} else {
|
||||
xQueueSend(pollSoonQueue, &pollable, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void InputBroker::queueInputEvent(const InputEvent *event)
|
||||
void InputBroker::queueInputEvent(const InputEvent *event, bool fromIsr)
|
||||
{
|
||||
if (xPortInIsrContext() == pdTRUE) {
|
||||
if (fromIsr) {
|
||||
xQueueSendFromISR(inputEventQueue, event, NULL);
|
||||
} else {
|
||||
xQueueSend(inputEventQueue, event, portMAX_DELAY);
|
||||
|
||||
@ -60,8 +60,8 @@ class InputBroker : public Observable<const InputEvent *>
|
||||
void registerSource(Observable<const InputEvent *> *source);
|
||||
void injectInputEvent(const InputEvent *event) { handleInputEvent(event); }
|
||||
#ifdef HAS_FREE_RTOS
|
||||
void requestPollSoon(InputPollable *pollable);
|
||||
void queueInputEvent(const InputEvent *event);
|
||||
void requestPollSoon(InputPollable *pollable, bool fromIsr);
|
||||
void queueInputEvent(const InputEvent *event, bool fromIsr);
|
||||
void processInputEventQueue();
|
||||
#endif
|
||||
|
||||
|
||||
@ -102,7 +102,7 @@ void TCA8418KeyboardBase::reset()
|
||||
void TCA8418KeyboardBase::attachInterruptHandler()
|
||||
{
|
||||
interruptInstance = this;
|
||||
auto interruptHandler = []() { interruptInstance->notifyObservers(interruptInstance); };
|
||||
auto interruptHandler = []() { interruptInstance->notifyObservers(true); };
|
||||
attachInterrupt(KB_INT, interruptHandler, FALLING);
|
||||
}
|
||||
|
||||
@ -126,8 +126,8 @@ int TCA8418KeyboardBase::beforeLightSleep(void *unused)
|
||||
int TCA8418KeyboardBase::afterLightSleep(esp_sleep_wakeup_cause_t cause)
|
||||
{
|
||||
attachInterruptHandler();
|
||||
this->notifyObservers(this); // Trigger a one-off poll in case a keypress woke us
|
||||
return 0; // Indicates success
|
||||
this->notifyObservers(false); // Trigger a one-off poll in case a keypress woke us
|
||||
return 0; // Indicates success
|
||||
}
|
||||
#endif // ARCH_ESP32
|
||||
|
||||
|
||||
@ -130,7 +130,7 @@ void KbI2cBase::pollOnce()
|
||||
}
|
||||
if (e.inputEvent != INPUT_BROKER_NONE) {
|
||||
LOG_DEBUG("TCA8418 Notifying: %i Char: %c", e.inputEvent, e.kbchar);
|
||||
inputBroker->queueInputEvent(&e);
|
||||
inputBroker->queueInputEvent(&e, false);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -637,11 +637,11 @@ void KbI2cBase::toggleBacklight(bool on)
|
||||
#endif
|
||||
}
|
||||
|
||||
int KbI2cBase::onNotify(KbInterruptObservable *src)
|
||||
int KbI2cBase::onNotify(bool fromIsr)
|
||||
{
|
||||
// Called from interrupt context, request polling after exiting the ISR
|
||||
#ifdef KB_INT
|
||||
inputBroker->requestPollSoon(this);
|
||||
inputBroker->requestPollSoon(this, fromIsr);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@ -20,7 +20,7 @@ class KbI2cBase : public Observable<const InputEvent *>,
|
||||
virtual void pollOnce() override;
|
||||
|
||||
protected:
|
||||
virtual int onNotify(KbInterruptObservable *src) override;
|
||||
virtual int onNotify(bool fromIsr) override;
|
||||
virtual int32_t runOnce() override;
|
||||
|
||||
private:
|
||||
|
||||
@ -2,10 +2,10 @@
|
||||
|
||||
#include "Observer.h"
|
||||
|
||||
class KbInterruptObservable : public Observable<KbInterruptObservable *>
|
||||
class KbInterruptObservable : public Observable<bool>
|
||||
{
|
||||
};
|
||||
|
||||
class KbInterruptObserver : public Observer<KbInterruptObservable *>
|
||||
class KbInterruptObserver : public Observer<bool>
|
||||
{
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user