IRQ: Make handlers more independent of EventDispatcher.

EventDispatcher is such a hairball...
This commit is contained in:
Jared Boone 2017-01-31 12:02:51 -08:00
parent f4fdc21c20
commit bf7f5d2567
4 changed files with 18 additions and 17 deletions

View File

@ -38,9 +38,13 @@
#include <cstdint> #include <cstdint>
constexpr auto EVT_MASK_RTC_TICK = EVENT_MASK(0);
constexpr auto EVT_MASK_LCD_FRAME_SYNC = EVENT_MASK(1);
constexpr auto EVT_MASK_SWITCHES = EVENT_MASK(3); constexpr auto EVT_MASK_SWITCHES = EVENT_MASK(3);
constexpr auto EVT_MASK_ENCODER = EVENT_MASK(4); constexpr auto EVT_MASK_ENCODER = EVENT_MASK(4);
constexpr auto EVT_MASK_TOUCH = EVENT_MASK(5); constexpr auto EVT_MASK_TOUCH = EVENT_MASK(5);
constexpr auto EVT_MASK_APPLICATION = EVENT_MASK(6);
constexpr auto EVT_MASK_LOCAL = EVENT_MASK(7);
class EventDispatcher { class EventDispatcher {
public: public:
@ -65,14 +69,6 @@ public:
} }
} }
static inline void event_isr_rtc_tick() {
events_flag_isr(EVT_MASK_RTC_TICK);
}
static inline void event_isr_lcd_frame_sync() {
events_flag_isr(EVT_MASK_LCD_FRAME_SYNC);
}
static inline void events_flag(const eventmask_t events) { static inline void events_flag(const eventmask_t events) {
if( thread_event_loop ) { if( thread_event_loop ) {
chEvtSignal(thread_event_loop, events); chEvtSignal(thread_event_loop, events);
@ -92,11 +88,6 @@ public:
} }
private: private:
static constexpr auto EVT_MASK_RTC_TICK = EVENT_MASK(0);
static constexpr auto EVT_MASK_LCD_FRAME_SYNC = EVENT_MASK(1);
static constexpr auto EVT_MASK_APPLICATION = EVENT_MASK(6);
static constexpr auto EVT_MASK_LOCAL = EVENT_MASK(7);
static Thread* thread_event_loop; static Thread* thread_event_loop;
touch::Manager touch_manager { }; touch::Manager touch_manager { };

View File

@ -40,6 +40,8 @@
#include "hackrf_hal.hpp" #include "hackrf_hal.hpp"
using namespace hackrf::one; using namespace hackrf::one;
static Thread* thread_controls_event = NULL;
static std::array<Debounce, 7> switch_debounce; static std::array<Debounce, 7> switch_debounce;
static Encoder encoder; static Encoder encoder;
@ -156,7 +158,7 @@ void timer0_callback(GPTDriver* const) {
/* Signal event loop */ /* Signal event loop */
if( event_mask ) { if( event_mask ) {
chSysLockFromIsr(); chSysLockFromIsr();
EventDispatcher::events_flag_isr(event_mask); chEvtSignalI(thread_controls_event, event_mask);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
} }
} }
@ -176,6 +178,8 @@ static GPTConfig timer0_config {
}; };
void controls_init() { void controls_init() {
thread_controls_event = chThdSelf();
touch::adc::start(); touch::adc::start();
/* GPT timer 0 is used to scan user interface controls -- touch screen, /* GPT timer 0 is used to scan user interface controls -- touch screen,

View File

@ -28,7 +28,10 @@
#include "portapack_hal.hpp" #include "portapack_hal.hpp"
static Thread* thread_lcd_frame_event = NULL;
static void pin_int4_interrupt_enable() { static void pin_int4_interrupt_enable() {
thread_lcd_frame_event = chThdSelf();
nvicEnableVector(PIN_INT4_IRQn, CORTEX_PRIORITY_MASK(LPC43XX_PIN_INT4_IRQ_PRIORITY)); nvicEnableVector(PIN_INT4_IRQn, CORTEX_PRIORITY_MASK(LPC43XX_PIN_INT4_IRQ_PRIORITY));
} }
@ -54,7 +57,7 @@ CH_IRQ_HANDLER(PIN_INT4_IRQHandler) {
CH_IRQ_PROLOGUE(); CH_IRQ_PROLOGUE();
chSysLockFromIsr(); chSysLockFromIsr();
EventDispatcher::event_isr_lcd_frame_sync(); chEvtSignalI(thread_lcd_frame_event, EVT_MASK_LCD_FRAME_SYNC);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
LPC_GPIO_INT->IST = (1U << 4); LPC_GPIO_INT->IST = (1U << 4);

View File

@ -28,7 +28,10 @@ using namespace lpc43xx;
#include "event_m0.hpp" #include "event_m0.hpp"
static Thread* thread_rtc_event = NULL;
void rtc_interrupt_enable() { void rtc_interrupt_enable() {
thread_rtc_event = chThdSelf();
rtc::interrupt::enable_second_inc(); rtc::interrupt::enable_second_inc();
nvicEnableVector(RTC_IRQn, CORTEX_PRIORITY_MASK(LPC_RTC_IRQ_PRIORITY)); nvicEnableVector(RTC_IRQn, CORTEX_PRIORITY_MASK(LPC_RTC_IRQ_PRIORITY));
} }
@ -39,7 +42,7 @@ CH_IRQ_HANDLER(RTC_IRQHandler) {
CH_IRQ_PROLOGUE(); CH_IRQ_PROLOGUE();
chSysLockFromIsr(); chSysLockFromIsr();
EventDispatcher::event_isr_rtc_tick(); chEvtSignalI(thread_rtc_event, EVT_MASK_RTC_TICK);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
rtc::interrupt::clear_all(); rtc::interrupt::clear_all();