rotary:[#9] process interrupts and send to master

This commit is contained in:
Vasily Davydov
2023-04-27 01:44:17 +03:00
parent da50fa4de1
commit 2ed0653056
4 changed files with 52 additions and 8 deletions

View File

@@ -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)
{
}