1 /** 2 * @file lv_freertos.h 3 * 4 */ 5 6 /** 7 * Copyright 2023 NXP 8 * 9 * SPDX-License-Identifier: MIT 10 */ 11 12 #ifndef LV_FREERTOS_H 13 #define LV_FREERTOS_H 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif 18 19 /********************* 20 * INCLUDES 21 *********************/ 22 #include "lv_os.h" 23 24 #if LV_USE_OS == LV_OS_FREERTOS 25 26 #ifdef ESP_PLATFORM 27 #include "freertos/FreeRTOS.h" 28 #include "freertos/task.h" 29 #include "freertos/semphr.h" 30 #else 31 #include "FreeRTOS.h" 32 #include "task.h" 33 #include "semphr.h" 34 #endif 35 36 /********************* 37 * DEFINES 38 *********************/ 39 40 /********************** 41 * TYPEDEFS 42 **********************/ 43 44 typedef struct { 45 void (*pvStartRoutine)(void *); /**< Application thread function. */ 46 void * pTaskArg; /**< Arguments for application thread function. */ 47 TaskHandle_t xTaskHandle; /**< FreeRTOS task handle. */ 48 } lv_thread_t; 49 50 typedef struct { 51 BaseType_t xIsInitialized; /**< Set to pdTRUE if this mutex is initialized, pdFALSE otherwise. */ 52 SemaphoreHandle_t xMutex; /**< FreeRTOS mutex. */ 53 } lv_mutex_t; 54 55 typedef struct { 56 BaseType_t 57 xIsInitialized; /**< Set to pdTRUE if this condition variable is initialized, pdFALSE otherwise. */ 58 BaseType_t xSyncSignal; /**< Set to pdTRUE if the thread is signaled, pdFALSE otherwise. */ 59 #if LV_USE_FREERTOS_TASK_NOTIFY 60 TaskHandle_t xTaskToNotify; /**< The task waiting to be signalled. NULL if nothing is waiting. */ 61 #else 62 SemaphoreHandle_t xCondWaitSemaphore; /**< Threads block on this semaphore in lv_thread_sync_wait. */ 63 uint32_t ulWaitingThreads; /**< The number of threads currently waiting on this condition variable. */ 64 SemaphoreHandle_t xSyncMutex; /**< Threads take this mutex before accessing the condition variable. */ 65 #endif 66 } lv_thread_sync_t; 67 68 /********************** 69 * GLOBAL PROTOTYPES 70 **********************/ 71 72 /** 73 * Set it for `traceTASK_SWITCHED_IN()` as 74 * `lv_freertos_task_switch_in(pxCurrentTCB->pcTaskName)` 75 * to save the start time stamp of a task 76 * @param name the name of the which is switched in 77 */ 78 void lv_freertos_task_switch_in(const char * name); 79 80 /** 81 * Set it for `traceTASK_SWITCHED_OUT()` as 82 * `lv_freertos_task_switch_out()` 83 * to save finish time stamp of a task 84 */ 85 void lv_freertos_task_switch_out(void); 86 87 /** 88 * Set it for `LV_SYSMON_GET_IDLE` to show the CPU usage 89 * as reported based the usage of FreeRTOS's idle task 90 * If it's important when a GPU is used. 91 * @return the idle percentage since the last call 92 */ 93 uint32_t lv_os_get_idle_percent(void); 94 95 /********************** 96 * MACROS 97 **********************/ 98 99 #endif /*LV_USE_OS == LV_OS_FREERTOS*/ 100 101 #ifdef __cplusplus 102 } /*extern "C"*/ 103 #endif 104 105 #endif /*LV_FREERTOS_H*/ 106