rotary:[#9] process interrupts and send to master
This commit is contained in:
@@ -7,6 +7,9 @@
|
||||
|
||||
#include "Rotary.h"
|
||||
#include "board.h"
|
||||
#include "queue.h"
|
||||
|
||||
static QueueHandle_t * p_rotary_isr_q;
|
||||
|
||||
extern "C"
|
||||
{
|
||||
@@ -14,18 +17,30 @@ extern "C"
|
||||
PIN_INT0_IRQHandler (void)
|
||||
{
|
||||
Chip_PININT_ClearIntStatus (LPC_PININT, PININTCH (PIN_INT0_IRQn));
|
||||
portBASE_TYPE xHigherPriorityWoken = pdFALSE;
|
||||
uint8_t data = ThreadCommon::RotaryAction::Right;
|
||||
xQueueSendFromISR (*p_rotary_isr_q, &data, &xHigherPriorityWoken);
|
||||
portEND_SWITCHING_ISR(xHigherPriorityWoken);
|
||||
}
|
||||
|
||||
void
|
||||
PIN_INT1_IRQHandler (void)
|
||||
{
|
||||
Chip_PININT_ClearIntStatus (LPC_PININT, PININTCH (PIN_INT1_IRQn));
|
||||
portBASE_TYPE xHigherPriorityWoken = pdFALSE;
|
||||
uint8_t data = ThreadCommon::RotaryAction::Left;
|
||||
xQueueSendFromISR (*p_rotary_isr_q, &data, &xHigherPriorityWoken);
|
||||
portEND_SWITCHING_ISR(xHigherPriorityWoken);
|
||||
}
|
||||
|
||||
void
|
||||
PIN_INT2_IRQHandler (void)
|
||||
{
|
||||
Chip_PININT_ClearIntStatus (LPC_PININT, PININTCH (PIN_INT2_IRQn));
|
||||
portBASE_TYPE xHigherPriorityWoken = pdFALSE;
|
||||
uint8_t data = ThreadCommon::RotaryAction::Press;
|
||||
xQueueSendFromISR (*p_rotary_isr_q, &data, &xHigherPriorityWoken);
|
||||
portEND_SWITCHING_ISR(xHigherPriorityWoken);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,17 +53,28 @@ Rotary::~Rotary() {}
|
||||
|
||||
void Rotary::taskFunction()
|
||||
{
|
||||
Event data(Event::Null, 0);
|
||||
Event* e = new Event(Event::Rotary, ThreadCommon::RotaryAction::Idle);
|
||||
_qm->send<Event>(ThreadCommon::QueueManager::master_event_all, e, 10);
|
||||
auto action_from_rotary_isr = ThreadCommon::RotaryAction::Idle;
|
||||
Event * p_e= new Event(Event::EventType::Rotary, action_from_rotary_isr);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
vTaskDelay(500);
|
||||
xQueueReceive(*p_rotary_isr_q, &action_from_rotary_isr, portMAX_DELAY);
|
||||
p_e->setDataOf(Event::EventType::Rotary, action_from_rotary_isr);
|
||||
_qm->send<Event>(ThreadCommon::QueueManager::master_event_all, p_e, 10);
|
||||
}
|
||||
}
|
||||
|
||||
void rotary_thread(void* pvParams)
|
||||
{
|
||||
// Special case for ISR
|
||||
QueueHandle_t rotary_isr_q = xQueueCreate(15, sizeof(char));
|
||||
p_rotary_isr_q = &rotary_isr_q;
|
||||
|
||||
Rotary r(static_cast<ThreadCommon::QueueManager*>(pvParams));
|
||||
r.taskFunction();
|
||||
}
|
||||
|
||||
static inline void sendActionAndAssertQueue (uint8_t *data, BaseType_t *const pxHPW)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@ public:
|
||||
private:
|
||||
Event* message;
|
||||
ThreadCommon::QueueManager* _qm;
|
||||
DigitalIoPin signal[3] = { { 0, 1, true, true, false, true, PIN_INT0_IRQn},
|
||||
{ 0, 5, true, false, false, true, PIN_INT1_IRQn},
|
||||
DigitalIoPin signal[3] = { { 0, 1, true, true, false, true, PIN_INT0_IRQn}, //SW1
|
||||
{ 0, 16, true, true, false, true, PIN_INT1_IRQn}, //SW2
|
||||
{ 1, 8, true, false, false, true, PIN_INT2_IRQn} };
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user