summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoruvok2025-07-18 20:12:10 +0200
committeruvok2025-07-18 20:12:10 +0200
commitbbf5b27ec18c8d65d515c01b36c2c9cef3c4272b (patch)
tree164621cdbc820528bac3f8ac995cefc88c9568de /src
parent4b2dd3b9f97a7bdf3a0cef36c9e12658f299bfc4 (diff)
Put Freertos stuff in struct
Diffstat (limited to 'src')
-rw-r--r--src/gpio.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/gpio.cpp b/src/gpio.cpp
index cf26fb3..f3f600f 100644
--- a/src/gpio.cpp
+++ b/src/gpio.cpp
@@ -15,29 +15,34 @@
#define PRV_KEY 6
#endif
-static unsigned long pressedTime = 0;
-static unsigned long releasedTime = 0;
-
static void gpio_loop(void *);
typedef uint32_t pin_notification_t;
#define GPIO_STACK 2048
#define GPIO_QUEUE_LEN 4
+static unsigned long pressedTime = 0;
+static unsigned long releasedTime = 0;
+
+static struct
+{
-static StaticTask_t gpio_task;
-static StackType_t gpio_stack[GPIO_STACK / sizeof(StackType_t)];
+ StaticTask_t task;
+ StackType_t task_stack[GPIO_STACK / sizeof(StackType_t)];
-static StaticQueue_t gpio_queue_storage;
-static uint8_t gpio_queue_content[GPIO_QUEUE_LEN * sizeof(pin_notification_t)];
-static QueueHandle_t gpio_q;
+ StaticQueue_t queue;
+ uint8_t queue_storage[GPIO_QUEUE_LEN * sizeof(pin_notification_t)];
+ QueueHandle_t queue_handle;
+} gpio_task_stuff;
static ARDUINO_ISR_ATTR void gpio_pin_irq(void *);
void de::uvok::badge::gpio_init(void)
{
- xTaskCreateStatic(gpio_loop, "gpio", GPIO_STACK, NULL, configMAX_PRIORITIES - 1, gpio_stack, &gpio_task);
- gpio_q = xQueueCreateStatic(4, sizeof(pin_notification_t), &(gpio_queue_content[0]), &gpio_queue_storage);
+ xTaskCreateStatic(gpio_loop, "gpio", GPIO_STACK, NULL, configMAX_PRIORITIES - 1, gpio_task_stuff.task_stack,
+ &gpio_task_stuff.task);
+ gpio_task_stuff.queue_handle =
+ xQueueCreateStatic(4, sizeof(pin_notification_t), &(gpio_task_stuff.queue_storage[0]), &gpio_task_stuff.queue);
#if UVOK_EPAP_BOARD == BOARD_ESP32_CROWPANEL
uint8_t inPins[] = {EXIT_KEY, HOME_KEY, NEXT_KEY, OK_KEY, PRV_KEY};
for (uint8_t p : inPins)
@@ -79,7 +84,7 @@ static void gpio_loop(void *ctx)
while (1)
{
pin_notification_t received;
- if (xQueueReceive(gpio_q, &received, portMAX_DELAY) == pdTRUE)
+ if (xQueueReceive(gpio_task_stuff.queue_handle, &received, portMAX_DELAY) == pdTRUE)
{
const int level = (received & 0x100) ? HIGH : LOW;
const bool pressed = !level;
@@ -96,7 +101,7 @@ static ARDUINO_ISR_ATTR void gpio_pin_irq(void *arg)
pin_notification_t send = (pinLevel << 8) | (pin_no);
BaseType_t wakeup = false;
- xQueueSendFromISR(gpio_q, &send, &wakeup);
+ xQueueSendFromISR(gpio_task_stuff.queue_handle, &send, &wakeup);
if (wakeup)
{
portYIELD_FROM_ISR();