mirror of
https://github.com/meshtastic/firmware.git
synced 2025-10-28 23:34:03 +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
|
#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);
|
xQueueSendFromISR(pollSoonQueue, &pollable, NULL);
|
||||||
} else {
|
} else {
|
||||||
xQueueSend(pollSoonQueue, &pollable, 0);
|
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);
|
xQueueSendFromISR(inputEventQueue, event, NULL);
|
||||||
} else {
|
} else {
|
||||||
xQueueSend(inputEventQueue, event, portMAX_DELAY);
|
xQueueSend(inputEventQueue, event, portMAX_DELAY);
|
||||||
|
|||||||
@ -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);
|
void requestPollSoon(InputPollable *pollable, bool fromIsr);
|
||||||
void queueInputEvent(const InputEvent *event);
|
void queueInputEvent(const InputEvent *event, bool fromIsr);
|
||||||
void processInputEventQueue();
|
void processInputEventQueue();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -102,7 +102,7 @@ void TCA8418KeyboardBase::reset()
|
|||||||
void TCA8418KeyboardBase::attachInterruptHandler()
|
void TCA8418KeyboardBase::attachInterruptHandler()
|
||||||
{
|
{
|
||||||
interruptInstance = this;
|
interruptInstance = this;
|
||||||
auto interruptHandler = []() { interruptInstance->notifyObservers(interruptInstance); };
|
auto interruptHandler = []() { interruptInstance->notifyObservers(true); };
|
||||||
attachInterrupt(KB_INT, interruptHandler, FALLING);
|
attachInterrupt(KB_INT, interruptHandler, FALLING);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,8 +126,8 @@ 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(this); // Trigger a one-off poll in case a keypress woke us
|
this->notifyObservers(false); // 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
|
||||||
|
|
||||||
|
|||||||
@ -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);
|
inputBroker->queueInputEvent(&e, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -637,11 +637,11 @@ void KbI2cBase::toggleBacklight(bool on)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int KbI2cBase::onNotify(KbInterruptObservable *src)
|
int KbI2cBase::onNotify(bool fromIsr)
|
||||||
{
|
{
|
||||||
// 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);
|
inputBroker->requestPollSoon(this, fromIsr);
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -20,7 +20,7 @@ class KbI2cBase : public Observable<const InputEvent *>,
|
|||||||
virtual void pollOnce() override;
|
virtual void pollOnce() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int onNotify(KbInterruptObservable *src) override;
|
virtual int onNotify(bool fromIsr) override;
|
||||||
virtual int32_t runOnce() override;
|
virtual int32_t runOnce() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@ -2,10 +2,10 @@
|
|||||||
|
|
||||||
#include "Observer.h"
|
#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