Skip to content

Commit

Permalink
feat(pxp): Add zephyr support
Browse files Browse the repository at this point in the history
Add semaphore and connect IRQ.
Originally proposed by @0xFarahFl.
  • Loading branch information
faxe1008 committed Apr 30, 2024
1 parent 447f9b8 commit 7bfda9c
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/draw/nxp/pxp/lv_pxp_osa.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
#include "semphr.h"
#endif

#if defined(__ZEPHYR__)
#include <zephyr/kernel.h>
#include <zephyr/irq.h>
#endif

/*********************
* DEFINES
*********************/
Expand Down Expand Up @@ -64,6 +69,9 @@ static void _pxp_wait(void);
#if defined(SDK_OS_FREE_RTOS)
static SemaphoreHandle_t xPXPIdleSemaphore;
#endif
#if defined(__ZEPHYR__)
static K_SEM_DEFINE(s_pxpIdleSem, 0, 1);
#endif
static volatile bool ucPXPIdle;

static pxp_cfg_t _pxp_default_cfg = {
Expand Down Expand Up @@ -97,6 +105,8 @@ void PXP_IRQHandler(void)
priority task. The macro used for this purpose is dependent on the port in
use and may be called portEND_SWITCHING_ISR(). */
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
#elif defined(__ZEPHYR__)
k_sem_give(&s_pxpIdleSem);
#else
ucPXPIdle = true;
#endif
Expand All @@ -119,17 +129,22 @@ static void _pxp_interrupt_init(void)
PXP_ASSERT_MSG(xPXPIdleSemaphore, "xSemaphoreCreateBinary failed!");

NVIC_SetPriority(PXP_IRQ_ID, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY + 1);
NVIC_EnableIRQ(PXP_IRQ_ID);
#elif defined(__ZEPHYR__)
IRQ_DIRECT_CONNECT(PXP_IRQ_ID, CONFIG_DMA_INIT_PRIORITY, PXP_IRQHandler, 0);
irq_enable(PXP_IRQ_ID);
#endif
ucPXPIdle = true;

NVIC_EnableIRQ(PXP_IRQ_ID);
}

static void _pxp_interrupt_deinit(void)
{
NVIC_DisableIRQ(PXP_IRQ_ID);
#if defined(SDK_OS_FREE_RTOS)
NVIC_DisableIRQ(PXP_IRQ_ID);
vSemaphoreDelete(xPXPIdleSemaphore);
#elif defined(__ZEPHYR__)
irq_disable(PXP_IRQ_ID);
k_sem_reset(&s_pxpIdleSem);
#endif
}

Expand All @@ -156,6 +171,9 @@ static void _pxp_wait(void)

if(xSemaphoreTake(xPXPIdleSemaphore, portMAX_DELAY) == pdTRUE)
ucPXPIdle = true;
#elif defined(__ZEPHYR__)
if(k_sem_take(&s_pxpIdleSem, K_FOREVER) == 0)
s_pxpIdle = true;
#else
while(ucPXPIdle == false) {
}
Expand Down

0 comments on commit 7bfda9c

Please sign in to comment.