diff --git a/src/draw/nxp/pxp/lv_pxp_osa.c b/src/draw/nxp/pxp/lv_pxp_osa.c index e5d3d55a6..539cefe50 100644 --- a/src/draw/nxp/pxp/lv_pxp_osa.c +++ b/src/draw/nxp/pxp/lv_pxp_osa.c @@ -25,11 +25,6 @@ #include "semphr.h" #endif -#if defined(__ZEPHYR__) - #include - #include -#endif - /********************* * DEFINES *********************/ @@ -66,8 +61,8 @@ static void _pxp_wait(void); * STATIC VARIABLES **********************/ -#if LV_USE_OS - static lv_thread_sync_t pxp_sync; +#if defined(SDK_OS_FREE_RTOS) + static SemaphoreHandle_t xPXPIdleSemaphore; #endif static volatile bool ucPXPIdle; @@ -88,23 +83,26 @@ 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 LV_USE_OS - lv_thread_sync_signal(&pxp_sync); +#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); #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; @@ -116,32 +114,22 @@ pxp_cfg_t * pxp_get_default_cfg(void) static void _pxp_interrupt_init(void) { -#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) + xPXPIdleSemaphore = xSemaphoreCreateBinary(); + 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_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) { -#if defined(SDK_OS_FREE_RTOS) 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); +#if defined(SDK_OS_FREE_RTOS) + vSemaphoreDelete(xPXPIdleSemaphore); #endif } @@ -161,10 +149,12 @@ 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 LV_USE_OS - if(lv_thread_sync_wait(&pxp_sync) == LV_RESULT_OK) + + if(xSemaphoreTake(xPXPIdleSemaphore, portMAX_DELAY) == pdTRUE) ucPXPIdle = true; #else while(ucPXPIdle == false) {