1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

feat(pxp): add zephyr support (#6159)

This commit is contained in:
Fabian Blatz 2024-05-24 05:47:32 +02:00 committed by GitHub
parent 16f79f4f04
commit e1cc12eb27
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -25,6 +25,11 @@
#include "semphr.h"
#endif
#if defined(__ZEPHYR__)
#include <zephyr/kernel.h>
#include <zephyr/irq.h>
#endif
/*********************
* DEFINES
*********************/
@ -61,8 +66,8 @@ static void _pxp_wait(void);
* STATIC VARIABLES
**********************/
#if defined(SDK_OS_FREE_RTOS)
static SemaphoreHandle_t xPXPIdleSemaphore;
#if LV_USE_OS
static lv_thread_sync_t pxp_sync;
#endif
static volatile bool ucPXPIdle;
@ -83,26 +88,23 @@ static pxp_cfg_t _pxp_default_cfg = {
void PXP_IRQHandler(void)
{
#if defined(SDK_OS_FREE_RTOS)
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
#endif
if(kPXP_CompleteFlag & PXP_GetStatusFlags(PXP_ID)) {
PXP_ClearStatusFlags(PXP_ID, kPXP_CompleteFlag);
#if defined(SDK_OS_FREE_RTOS)
xSemaphoreGiveFromISR(xPXPIdleSemaphore, &xHigherPriorityTaskWoken);
/* If xHigherPriorityTaskWoken is now set to pdTRUE then a context switch
should be performed to ensure the interrupt returns directly to the highest
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);
#if LV_USE_OS
lv_thread_sync_signal(&pxp_sync);
#else
ucPXPIdle = true;
#endif
}
}
#if defined(__ZEPHYR__)
static void PXP_ZephyrIRQHandler(void *)
{
PXP_IRQHandler();
}
#endif
pxp_cfg_t * pxp_get_default_cfg(void)
{
return &_pxp_default_cfg;
@ -114,22 +116,32 @@ pxp_cfg_t * pxp_get_default_cfg(void)
static void _pxp_interrupt_init(void)
{
#if defined(SDK_OS_FREE_RTOS)
xPXPIdleSemaphore = xSemaphoreCreateBinary();
PXP_ASSERT_MSG(xPXPIdleSemaphore, "xSemaphoreCreateBinary failed!");
#if LV_USE_OS
if(lv_thread_sync_init(&pxp_sync) != LV_RESULT_OK) {
PXP_ASSERT_MSG(false, "Failed to init thread_sync.");
}
#endif
#if defined(SDK_OS_FREE_RTOS)
NVIC_SetPriority(PXP_IRQ_ID, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY + 1);
NVIC_EnableIRQ(PXP_IRQ_ID);
#elif defined(__ZEPHYR__)
IRQ_CONNECT(DT_IRQN(DT_NODELABEL(pxp)), CONFIG_LV_Z_PXP_INTERRUPT_PRIORITY, PXP_ZephyrIRQHandler, NULL, 0);
irq_enable(DT_IRQN(DT_NODELABEL(pxp)));
#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)
vSemaphoreDelete(xPXPIdleSemaphore);
NVIC_DisableIRQ(PXP_IRQ_ID);
#elif defined(__ZEPHYR__)
irq_disable(DT_IRQN(DT_NODELABEL(pxp)));
#endif
#if LV_USE_OS
lv_thread_sync_delete(&pxp_sync);
#endif
}
@ -149,12 +161,10 @@ static void _pxp_run(void)
*/
static void _pxp_wait(void)
{
#if defined(SDK_OS_FREE_RTOS)
/* Return if PXP was never started, otherwise the semaphore will lock forever. */
if(ucPXPIdle == true)
return;
if(xSemaphoreTake(xPXPIdleSemaphore, portMAX_DELAY) == pdTRUE)
#if LV_USE_OS
if(lv_thread_sync_wait(&pxp_sync) == LV_RESULT_OK)
ucPXPIdle = true;
#else
while(ucPXPIdle == false) {