1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-28 07:03:00 +08:00

feat(os): add mqx for osal (#6191)

This commit is contained in:
Joseph Chen 2024-05-10 04:00:53 +08:00 committed by GitHub
parent b44bcaee17
commit d0c88f2769
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 262 additions and 0 deletions

View File

@ -77,6 +77,7 @@
* - LV_OS_CMSIS_RTOS2
* - LV_OS_RTTHREAD
* - LV_OS_WINDOWS
* - LV_OS_MQX
* - LV_OS_CUSTOM */
#define LV_USE_OS LV_OS_NONE

View File

@ -141,6 +141,8 @@ menu "LVGL configuration"
bool "4: RTTHREAD"
config LV_OS_WINDOWS
bool "5: WINDOWS"
config LV_OS_MQX
bool "6: MQX"
config LV_OS_CUSTOM
bool "255: CUSTOM"
endchoice
@ -153,6 +155,7 @@ menu "LVGL configuration"
default 3 if LV_OS_CMSIS_RTOS2
default 4 if LV_OS_RTTHREAD
default 5 if LV_OS_WINDOWS
default 6 if LV_OS_MQX
default 255 if LV_OS_CUSTOM
config LV_OS_CUSTOM_INCLUDE

View File

@ -9,3 +9,4 @@
freertos
zephyr
px5
mqx

View File

@ -0,0 +1,8 @@
========
MQX RTOS
========
See `MQX RTOS's homepage <https://www.nxp.com/design/design-center/software/embedded-software/mqx-software-solutions/mqx-real-time-operating-system-rtos:MQXRTOS>`__
TODO

View File

@ -800,6 +800,7 @@
* - LV_OS_CMSIS_RTOS2
* - LV_OS_RTTHREAD
* - LV_OS_WINDOWS
* - LV_OS_MQX
* - LV_OS_CUSTOM
*/
#define LV_USE_OS LV_OS_PTHREAD
@ -823,6 +824,7 @@
* - LV_OS_CMSIS_RTOS2
* - LV_OS_RTTHREAD
* - LV_OS_WINDOWS
* - LV_OS_MQX
* - LV_OS_CUSTOM
*/
#define LV_USE_OS LV_OS_FREERTOS
@ -846,6 +848,7 @@
* - LV_OS_CMSIS_RTOS2
* - LV_OS_RTTHREAD
* - LV_OS_WINDOWS
* - LV_OS_MQX
* - LV_OS_CUSTOM
*/
#define LV_USE_OS LV_OS_CMSIS_RTOS2
@ -869,6 +872,7 @@
* - LV_OS_CMSIS_RTOS2
* - LV_OS_RTTHREAD
* - LV_OS_WINDOWS
* - LV_OS_MQX
* - LV_OS_CUSTOM
*/
#define LV_USE_OS LV_OS_RTTHREAD
@ -892,6 +896,7 @@
* - LV_OS_CMSIS_RTOS2
* - LV_OS_RTTHREAD
* - LV_OS_WINDOWS
* - LV_OS_MQX
* - LV_OS_CUSTOM
*/
#define LV_USE_OS LV_OS_WINDOWS
@ -900,6 +905,30 @@
</component>
<component Cgroup="OS Abstraction Layer" Cvariant="MQX" condition="LVGL-Essential">
<description>Add the support for MQX APIs</description>
<files>
<file category="sourceC" name="src/osal/lv_mqx.c"/>
</files>
<RTE_Components_h>
/* Select an operating system to use. Possible options:
* - LV_OS_NONE
* - LV_OS_PTHREAD
* - LV_OS_FREERTOS
* - LV_OS_CMSIS_RTOS2
* - LV_OS_RTTHREAD
* - LV_OS_WINDOWS
* - LV_OS_MQX
* - LV_OS_CUSTOM
*/
#define LV_USE_OS LV_OS_MQX
</RTE_Components_h>
</component>
<component Cgroup="OS Abstraction Layer" Cvariant="User Custom" condition="LVGL-Essential">
<description>Add a user customized (RT)OS support </description>
<files>

View File

@ -88,6 +88,7 @@
* - LV_OS_CMSIS_RTOS2
* - LV_OS_RTTHREAD
* - LV_OS_WINDOWS
* - LV_OS_MQX
* - LV_OS_CUSTOM */
#define LV_USE_OS LV_OS_NONE

View File

@ -37,6 +37,7 @@ fout.write(
#define LV_OS_CMSIS_RTOS2 3
#define LV_OS_RTTHREAD 4
#define LV_OS_WINDOWS 5
#define LV_OS_MQX 6
#define LV_OS_CUSTOM 255
#define LV_STDLIB_BUILTIN 0

View File

@ -15,6 +15,7 @@
#define LV_OS_CMSIS_RTOS2 3
#define LV_OS_RTTHREAD 4
#define LV_OS_WINDOWS 5
#define LV_OS_MQX 6
#define LV_OS_CUSTOM 255
#define LV_STDLIB_BUILTIN 0
@ -246,6 +247,7 @@
* - LV_OS_CMSIS_RTOS2
* - LV_OS_RTTHREAD
* - LV_OS_WINDOWS
* - LV_OS_MQX
* - LV_OS_CUSTOM */
#ifndef LV_USE_OS
#ifdef CONFIG_LV_USE_OS

163
src/osal/lv_mqx.c Normal file
View File

@ -0,0 +1,163 @@
/**
* @file lv_mqx.c
*
*/
/*********************
* INCLUDES
*********************/
#include "lv_os.h"
#if LV_USE_OS == LV_OS_MQX
#include "../misc/lv_log.h"
#include "../stdlib/lv_string.h"
/*********************
* DEFINES
*********************/
/**********************
* TYPEDEFS
**********************/
/**********************
* STATIC PROTOTYPES
**********************/
/**********************
* STATIC VARIABLES
**********************/
/**********************
* MACROS
**********************/
/**********************
* GLOBAL FUNCTIONS
**********************/
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)
{
TASK_TEMPLATE_STRUCT task_template;
lv_memzero(&task_template, sizeof(task_template));
task_template.TASK_ADDRESS = (TASK_FPTR)callback;
task_template.TASK_STACKSIZE = stack_size;
task_template.TASK_PRIORITY = _sched_get_min_priority(0) - prio;
task_template.TASK_NAME = "lvglDraw";
task_template.CREATION_PARAMETER = (uint32_t)user_data;
*thread = _task_create(0, 0, (uint32_t)&task_template);
if(*thread == MQX_NULL_TASK_ID) {
LV_LOG_WARN("_task_create failed!");
return LV_RESULT_INVALID;
}
return LV_RESULT_OK;
}
lv_result_t lv_thread_delete(lv_thread_t * thread)
{
_mqx_uint ret = _task_destroy(*thread);
if(ret != MQX_OK) {
LV_LOG_WARN("_task_destroy failed!");
return LV_RESULT_INVALID;
}
return LV_RESULT_OK;
}
lv_result_t lv_mutex_init(lv_mutex_t * mutex)
{
if(MQX_OK != _mutex_init(mutex, NULL)) {
LV_LOG_WARN("create mutex failed");
return LV_RESULT_INVALID;
}
return LV_RESULT_OK;
}
lv_result_t lv_mutex_lock(lv_mutex_t * mutex)
{
_mqx_uint ret = _mutex_lock(mutex);
if(ret != MQX_OK) {
LV_LOG_WARN("Error: %x", ret);
return LV_RESULT_INVALID;
}
return LV_RESULT_OK;
}
lv_result_t lv_mutex_lock_isr(lv_mutex_t * mutex)
{
_mqx_uint ret = _mutex_lock(mutex);
if(ret != MQX_OK) {
LV_LOG_WARN("Error: %x", ret);
return LV_RESULT_INVALID;
}
return LV_RESULT_OK;
}
lv_result_t lv_mutex_unlock(lv_mutex_t * mutex)
{
_mqx_uint ret = _mutex_unlock(mutex);
if(ret != MQX_OK) {
LV_LOG_WARN("Error: %x", ret);
return LV_RESULT_INVALID;
}
return LV_RESULT_OK;
}
lv_result_t lv_mutex_delete(lv_mutex_t * mutex)
{
_mqx_uint ret = _mutex_destroy(mutex);
if(ret != MQX_OK) {
LV_LOG_WARN("Error: %x", ret);
return LV_RESULT_INVALID;
}
return LV_RESULT_OK;
}
lv_result_t lv_thread_sync_init(lv_thread_sync_t * sync)
{
if(MQX_OK != _lwsem_create(sync, 0)) {
LV_LOG_WARN("create semaphore failed");
return LV_RESULT_INVALID;
}
return LV_RESULT_OK;
}
lv_result_t lv_thread_sync_wait(lv_thread_sync_t * sync)
{
_mqx_uint ret = _lwsem_wait(sync);
if(ret != MQX_OK) {
LV_LOG_WARN("Error: %x", ret);
return LV_RESULT_INVALID;
}
return LV_RESULT_OK;
}
lv_result_t lv_thread_sync_signal(lv_thread_sync_t * sync)
{
_mqx_uint ret = _lwsem_post(sync);
if(ret != MQX_OK) {
LV_LOG_WARN("Error: %x", ret);
return LV_RESULT_INVALID;
}
return LV_RESULT_OK;
}
lv_result_t lv_thread_sync_delete(lv_thread_sync_t * sync)
{
_mqx_uint ret = _lwsem_destroy(sync);
if(ret != MQX_OK) {
LV_LOG_WARN("Error: %x", ret);
return LV_RESULT_INVALID;
}
return LV_RESULT_OK;
}
/**********************
* STATIC FUNCTIONS
**********************/
#endif /*LV_USE_OS == LV_OS_MQX*/

51
src/osal/lv_mqx.h Normal file
View File

@ -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*/

View File

@ -33,6 +33,8 @@ extern "C" {
#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