Skip to content

Commit

Permalink
feat(os): add mqx for osal (lvgl#6191)
Browse files Browse the repository at this point in the history
  • Loading branch information
josepho0918 authored May 9, 2024
1 parent b44bcae commit d0c88f2
Show file tree
Hide file tree
Showing 11 changed files with 262 additions and 0 deletions.
1 change: 1 addition & 0 deletions .devcontainer/__lv_conf.h__
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/integration/os/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
freertos
zephyr
px5
mqx
8 changes: 8 additions & 0 deletions docs/integration/os/mqx.rst
Original file line number Diff line number Diff line change
@@ -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
29 changes: 29 additions & 0 deletions env_support/cmsis-pack/LVGL.lvgl.pdsc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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>
Expand Down
1 change: 1 addition & 0 deletions lv_conf_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions scripts/lv_conf_internal_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,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
Expand Down
2 changes: 2 additions & 0 deletions src/lv_conf_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
163 changes: 163 additions & 0 deletions src/osal/lv_mqx.c
Original file line number Diff line number Diff line change
@@ -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 changes: 51 additions & 0 deletions src/osal/lv_mqx.h
Original file line number Diff line number Diff line change
@@ -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*/
2 changes: 2 additions & 0 deletions src/osal/lv_os.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d0c88f2

Please sign in to comment.