initial commit
This commit is contained in:
commit
cff2a21efc
550 files changed
+154887
No files matched your search
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* @file lv_cmsis_rtos2.h
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2023 Arm Limited or its affiliates. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef LV_CMSIS_RTOS2_H
|
||||
#define LV_CMSIS_RTOS2_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#if LV_USE_OS == LV_OS_CMSIS_RTOS2
|
||||
|
||||
#include "cmsis_os2.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef osThreadId_t lv_thread_t;
|
||||
|
||||
typedef osMutexId_t lv_mutex_t;
|
||||
|
||||
typedef osEventFlagsId_t lv_thread_sync_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_OS == LV_OS_CMSIS_RTOS2*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_OS_CMSIS_RTOS2*/
|
||||
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* @file lv_freertos.h
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Copyright 2023 NXP
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef LV_FREERTOS_H
|
||||
#define LV_FREERTOS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_os.h"
|
||||
|
||||
#if LV_USE_OS == LV_OS_FREERTOS
|
||||
|
||||
#if (ESP_PLATFORM)
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
#else
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "semphr.h"
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef struct {
|
||||
void (*pvStartRoutine)(void *); /**< Application thread function. */
|
||||
void * pTaskArg; /**< Arguments for application thread function. */
|
||||
TaskHandle_t xTaskHandle; /**< FreeRTOS task handle. */
|
||||
} lv_thread_t;
|
||||
|
||||
typedef struct {
|
||||
BaseType_t xIsInitialized; /**< Set to pdTRUE if this mutex is initialized, pdFALSE otherwise. */
|
||||
SemaphoreHandle_t xMutex; /**< FreeRTOS mutex. */
|
||||
} lv_mutex_t;
|
||||
|
||||
typedef struct {
|
||||
BaseType_t
|
||||
xIsInitialized; /**< Set to pdTRUE if this condition variable is initialized, pdFALSE otherwise. */
|
||||
BaseType_t xSyncSignal; /**< Set to pdTRUE if the thread is signaled, pdFALSE otherwise. */
|
||||
#if LV_USE_FREERTOS_TASK_NOTIFY
|
||||
TaskHandle_t xTaskToNotify; /**< The task waiting to be signalled. NULL if nothing is waiting. */
|
||||
#else
|
||||
SemaphoreHandle_t xCondWaitSemaphore; /**< Threads block on this semaphore in lv_thread_sync_wait. */
|
||||
uint32_t ulWaitingThreads; /**< The number of threads currently waiting on this condition variable. */
|
||||
SemaphoreHandle_t xSyncMutex; /**< Threads take this mutex before accessing the condition variable. */
|
||||
#endif
|
||||
} lv_thread_sync_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Set it for `traceTASK_SWITCHED_IN()` as
|
||||
* `lv_freertos_task_switch_in(pxCurrentTCB->pcTaskName)`
|
||||
* to save the start time stamp of a task
|
||||
* @param name the name of the which is switched in
|
||||
*/
|
||||
void lv_freertos_task_switch_in(const char * name);
|
||||
|
||||
/**
|
||||
* Set it for `traceTASK_SWITCHED_OUT()` as
|
||||
* `lv_freertos_task_switch_out()`
|
||||
* to save finish time stamp of a task
|
||||
*/
|
||||
void lv_freertos_task_switch_out(void);
|
||||
|
||||
/**
|
||||
* Set it for `LV_SYSMON_GET_IDLE` to show the CPU usage
|
||||
* as reported based the usage of FreeRTOS's idle task
|
||||
* If it's important when a GPU is used.
|
||||
* @return the idle percentage since the last call
|
||||
*/
|
||||
uint32_t lv_os_get_idle_percent(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_OS == LV_OS_FREERTOS*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_FREERTOS_H*/
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* @file lv_mqx.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_MQX_H
|
||||
#define LV_MQX_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "lv_os.h"
|
||||
|
||||
#if LV_USE_OS == LV_OS_MQX
|
||||
|
||||
#include "mqx.h"
|
||||
#include "mutex.h"
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef _task_id lv_thread_t;
|
||||
|
||||
typedef MUTEX_STRUCT lv_mutex_t;
|
||||
|
||||
typedef LWSEM_STRUCT lv_thread_sync_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_OS == LV_OS_MQX*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_MQX_H*/
|
||||
@@ -0,0 +1,186 @@
|
||||
/**
|
||||
* @file lv_os.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_OS_H
|
||||
#define LV_OS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* OS OPTIONS
|
||||
*********************/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#include "../lv_conf_internal.h"
|
||||
|
||||
#include "../misc/lv_types.h"
|
||||
|
||||
#if LV_USE_OS == LV_OS_NONE
|
||||
#include "lv_os_none.h"
|
||||
#elif LV_USE_OS == LV_OS_PTHREAD
|
||||
#include "lv_pthread.h"
|
||||
#elif LV_USE_OS == LV_OS_FREERTOS
|
||||
#include "lv_freertos.h"
|
||||
#elif LV_USE_OS == LV_OS_CMSIS_RTOS2
|
||||
#include "lv_cmsis_rtos2.h"
|
||||
#elif LV_USE_OS == LV_OS_RTTHREAD
|
||||
#include "lv_rtthread.h"
|
||||
#elif LV_USE_OS == LV_OS_WINDOWS
|
||||
#include "lv_windows.h"
|
||||
#elif LV_USE_OS == LV_OS_MQX
|
||||
#include "lv_mqx.h"
|
||||
#elif LV_USE_OS == LV_OS_CUSTOM
|
||||
#include LV_OS_CUSTOM_INCLUDE
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef enum {
|
||||
LV_THREAD_PRIO_LOWEST,
|
||||
LV_THREAD_PRIO_LOW,
|
||||
LV_THREAD_PRIO_MID,
|
||||
LV_THREAD_PRIO_HIGH,
|
||||
LV_THREAD_PRIO_HIGHEST,
|
||||
} lv_thread_prio_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/*----------------------------------------
|
||||
* These functions needs to be implemented
|
||||
* for specific operating systems
|
||||
*---------------------------------------*/
|
||||
|
||||
/**
|
||||
* Create a new thread
|
||||
* @param thread a variable in which the thread will be stored
|
||||
* @param prio priority of the thread
|
||||
* @param callback function of the thread
|
||||
* @param stack_size stack size in bytes
|
||||
* @param user_data arbitrary data, will be available in the callback
|
||||
* @return LV_RESULT_OK: success; LV_RESULT_INVALID: failure
|
||||
*/
|
||||
lv_result_t lv_thread_init(lv_thread_t * thread, lv_thread_prio_t prio, void (*callback)(void *), size_t stack_size,
|
||||
void * user_data);
|
||||
|
||||
/**
|
||||
* Delete a thread
|
||||
* @param thread the thread to delete
|
||||
* @return LV_RESULT_OK: success; LV_RESULT_INVALID: failure
|
||||
*/
|
||||
lv_result_t lv_thread_delete(lv_thread_t * thread);
|
||||
|
||||
/**
|
||||
* Create a mutex
|
||||
* @param mutex a variable in which the thread will be stored
|
||||
* @return LV_RESULT_OK: success; LV_RESULT_INVALID: failure
|
||||
*/
|
||||
lv_result_t lv_mutex_init(lv_mutex_t * mutex);
|
||||
|
||||
/**
|
||||
* Lock a mutex
|
||||
* @param mutex the mutex to lock
|
||||
* @return LV_RESULT_OK: success; LV_RESULT_INVALID: failure
|
||||
*/
|
||||
lv_result_t lv_mutex_lock(lv_mutex_t * mutex);
|
||||
|
||||
/**
|
||||
* Lock a mutex from interrupt
|
||||
* @param mutex the mutex to lock
|
||||
* @return LV_RESULT_OK: success; LV_RESULT_INVALID: failure
|
||||
*/
|
||||
lv_result_t lv_mutex_lock_isr(lv_mutex_t * mutex);
|
||||
|
||||
/**
|
||||
* Unlock a mutex
|
||||
* @param mutex the mutex to unlock
|
||||
* @return LV_RESULT_OK: success; LV_RESULT_INVALID: failure
|
||||
*/
|
||||
lv_result_t lv_mutex_unlock(lv_mutex_t * mutex);
|
||||
|
||||
/**
|
||||
* Delete a mutex
|
||||
* @param mutex the mutex to delete
|
||||
* @return LV_RESULT_OK: success; LV_RESULT_INVALID: failure
|
||||
*/
|
||||
lv_result_t lv_mutex_delete(lv_mutex_t * mutex);
|
||||
|
||||
/**
|
||||
* Create a thread synchronization object
|
||||
* @param sync a variable in which the sync will be stored
|
||||
* @return LV_RESULT_OK: success; LV_RESULT_INVALID: failure
|
||||
*/
|
||||
lv_result_t lv_thread_sync_init(lv_thread_sync_t * sync);
|
||||
|
||||
/**
|
||||
* Wait for a "signal" on a sync object
|
||||
* @param sync a sync object
|
||||
* @return LV_RESULT_OK: success; LV_RESULT_INVALID: failure
|
||||
*/
|
||||
lv_result_t lv_thread_sync_wait(lv_thread_sync_t * sync);
|
||||
|
||||
/**
|
||||
* Send a wake-up signal to a sync object
|
||||
* @param sync a sync object
|
||||
* @return LV_RESULT_OK: success; LV_RESULT_INVALID: failure
|
||||
*/
|
||||
lv_result_t lv_thread_sync_signal(lv_thread_sync_t * sync);
|
||||
|
||||
/**
|
||||
* Send a wake-up signal to a sync object from interrupt
|
||||
* @param sync a sync object
|
||||
* @return LV_RESULT_OK: success; LV_RESULT_INVALID: failure
|
||||
*/
|
||||
lv_result_t lv_thread_sync_signal_isr(lv_thread_sync_t * sync);
|
||||
|
||||
/**
|
||||
* Delete a sync object
|
||||
* @param sync a sync object to delete
|
||||
* @return LV_RESULT_OK: success; LV_RESULT_INVALID: failure
|
||||
*/
|
||||
lv_result_t lv_thread_sync_delete(lv_thread_sync_t * sync);
|
||||
|
||||
/**
|
||||
* Lock LVGL's general mutex.
|
||||
* LVGL is not thread safe, so a mutex is used to avoid executing multiple LVGL functions at the same time
|
||||
* from different threads. It shall be called when calling LVGL functions from threads
|
||||
* different than lv_timer_handler's thread. It doesn't need to be called in LVGL events because
|
||||
* they are called from lv_timer_handler().
|
||||
* It is called internally in lv_timer_handler().
|
||||
*/
|
||||
void lv_lock(void);
|
||||
|
||||
/**
|
||||
* Same as `lv_lock()` but can be called from an interrupt.
|
||||
* @return LV_RESULT_OK: success; LV_RESULT_INVALID: failure
|
||||
*/
|
||||
lv_result_t lv_lock_isr(void);
|
||||
|
||||
/**
|
||||
* The pair of `lv_lock()` and `lv_lock_isr()`.
|
||||
* It unlocks LVGL general mutex.
|
||||
* It is called internally in lv_timer_handler().
|
||||
*/
|
||||
void lv_unlock(void);
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_OS_H*/
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* @file lv_os_none.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_OS_NONE_H
|
||||
#define LV_OS_NONE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#if LV_USE_OS == LV_OS_NONE
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef int lv_mutex_t;
|
||||
typedef int lv_thread_t;
|
||||
typedef int lv_thread_sync_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_OS == LV_OS_NONE*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_OS_NONE_H*/
|
||||
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* @file lv_os_private.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_OS_PRIVATE_H
|
||||
#define LV_OS_PRIVATE_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* OS OPTIONS
|
||||
*********************/
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**
|
||||
* Initialize the OS layer
|
||||
*/
|
||||
void lv_os_init(void);
|
||||
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_OS_PRIVATE_H*/
|
||||
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* @file lv_pthread.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_PTHREAD_H
|
||||
#define LV_PTHREAD_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#if LV_USE_OS == LV_OS_PTHREAD
|
||||
|
||||
#include <pthread.h>
|
||||
#include <semaphore.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct {
|
||||
pthread_t thread;
|
||||
void (*callback)(void *);
|
||||
void * user_data;
|
||||
} lv_thread_t;
|
||||
|
||||
typedef pthread_mutex_t lv_mutex_t;
|
||||
|
||||
typedef struct {
|
||||
pthread_mutex_t mutex;
|
||||
pthread_cond_t cond;
|
||||
bool v;
|
||||
} lv_thread_sync_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_OS == LV_OS_PTHREAD*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_PTHREAD_H*/
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* @file lv_rtthread.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_RTTHREAD_H
|
||||
#define LV_RTTHREAD_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#if LV_USE_OS == LV_OS_RTTHREAD
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
typedef struct {
|
||||
rt_thread_t thread;
|
||||
} lv_thread_t;
|
||||
|
||||
typedef struct {
|
||||
rt_mutex_t mutex;
|
||||
} lv_mutex_t;
|
||||
|
||||
typedef struct {
|
||||
rt_sem_t sem;
|
||||
} lv_thread_sync_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_OS == LV_OS_RTTHREAD*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_RTTHREAD_H*/
|
||||
@@ -0,0 +1,54 @@
|
||||
/**
|
||||
* @file lv_windows.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef LV_WINDOWS_H
|
||||
#define LV_WINDOWS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#if LV_USE_OS == LV_OS_WINDOWS
|
||||
|
||||
#include <Windows.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/*********************
|
||||
* DEFINES
|
||||
*********************/
|
||||
|
||||
/**********************
|
||||
* TYPEDEFS
|
||||
**********************/
|
||||
|
||||
typedef HANDLE lv_thread_t;
|
||||
|
||||
typedef CRITICAL_SECTION lv_mutex_t;
|
||||
|
||||
typedef struct {
|
||||
CRITICAL_SECTION cs;
|
||||
CONDITION_VARIABLE cv;
|
||||
bool v;
|
||||
} lv_thread_sync_t;
|
||||
|
||||
/**********************
|
||||
* GLOBAL PROTOTYPES
|
||||
**********************/
|
||||
|
||||
/**********************
|
||||
* MACROS
|
||||
**********************/
|
||||
|
||||
#endif /*LV_USE_OS == LV_OS_WINDOWS*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /*extern "C"*/
|
||||
#endif
|
||||
|
||||
#endif /*LV_WINDOWS_H*/
|
||||
Reference in new issue
Block a user