2021-06-23 01:33 AM
2021-06-29 04:56 AM
#include <cassert>
#include <touchgfx/hal/HAL.hpp>
#include <touchgfx/hal/OSWrappers.hpp>
#include "os.h"
static OS_SEM frame_buffer_sem;
CPU_CHAR frame_buffer_sem_str[20] = "frame_buffer_sem";
CPU_CHAR vsync_queue_str[20] = "vsync_queue";
OS_Q vsync_queue;
static uint32_t dummy = 0x5a;
using namespace touchgfx;
void OSWrappers::initialize()
{
OS_ERR err;
OSSemCreate(&frame_buffer_sem, frame_buffer_sem_str, 0u, &err);
OSQCreate(&vsync_queue, vsync_queue_str, 1, &err);
}
void OSWrappers::takeFrameBufferSemaphore()
{
OS_ERR err;
CPU_TS ts;
(void)OSSemPend(&frame_buffer_sem, 0u, OS_OPT_PEND_BLOCKING, &ts, &err);
}
void OSWrappers::giveFrameBufferSemaphore()
{
OS_ERR err;
OSSemPost(&frame_buffer_sem, OS_OPT_POST_1, &err);
}
void OSWrappers::tryTakeFrameBufferSemaphore()
{
OS_ERR err;
CPU_TS ts;
(void)OSSemPend(&frame_buffer_sem, 0u, OS_OPT_PEND_NON_BLOCKING, &ts, &err);
}
void OSWrappers::giveFrameBufferSemaphoreFromISR()
{
OS_ERR err;
OSSemPost(&frame_buffer_sem, OS_OPT_POST_NO_SCHED, &err);
}
void OSWrappers::signalVSync()
{
OS_ERR err;
OSQPost(&vsync_queue, &dummy, sizeof(uint32_t), OS_OPT_POST_FIFO, &err);
}
void OSWrappers::signalRenderingDone()
{
}
void OSWrappers::waitForVSync()
{
OS_ERR err;
CPU_TS ts;
OS_MSG_SIZE msg_size;
OSQPend(&vsync_queue, 0, OS_OPT_PEND_NON_BLOCKING, &msg_size, &ts, &err);
OSQPend(&vsync_queue, 0, OS_OPT_PEND_BLOCKING, &msg_size, &ts, &err);
}
void OSWrappers::taskDelay(uint16_t ms)
{
OS_ERR err;
OSTimeDly(ms, OS_OPT_TIME_DLY, &err);
}
Now it works well, you can rell me if you find any fault.
2021-06-28 07:46 PM
Hello JJ.Lin,
We've never worked with UCOSIII so unfortunately I cannot help you.
Hope someone will be able to.
/Alexandre
2021-06-29 04:49 AM
Thank you for your reply, I have done the porting by simply changing the function realization of freeRTOS with uCOS in OSWappers.cpp.
2021-06-29 04:56 AM
#include <cassert>
#include <touchgfx/hal/HAL.hpp>
#include <touchgfx/hal/OSWrappers.hpp>
#include "os.h"
static OS_SEM frame_buffer_sem;
CPU_CHAR frame_buffer_sem_str[20] = "frame_buffer_sem";
CPU_CHAR vsync_queue_str[20] = "vsync_queue";
OS_Q vsync_queue;
static uint32_t dummy = 0x5a;
using namespace touchgfx;
void OSWrappers::initialize()
{
OS_ERR err;
OSSemCreate(&frame_buffer_sem, frame_buffer_sem_str, 0u, &err);
OSQCreate(&vsync_queue, vsync_queue_str, 1, &err);
}
void OSWrappers::takeFrameBufferSemaphore()
{
OS_ERR err;
CPU_TS ts;
(void)OSSemPend(&frame_buffer_sem, 0u, OS_OPT_PEND_BLOCKING, &ts, &err);
}
void OSWrappers::giveFrameBufferSemaphore()
{
OS_ERR err;
OSSemPost(&frame_buffer_sem, OS_OPT_POST_1, &err);
}
void OSWrappers::tryTakeFrameBufferSemaphore()
{
OS_ERR err;
CPU_TS ts;
(void)OSSemPend(&frame_buffer_sem, 0u, OS_OPT_PEND_NON_BLOCKING, &ts, &err);
}
void OSWrappers::giveFrameBufferSemaphoreFromISR()
{
OS_ERR err;
OSSemPost(&frame_buffer_sem, OS_OPT_POST_NO_SCHED, &err);
}
void OSWrappers::signalVSync()
{
OS_ERR err;
OSQPost(&vsync_queue, &dummy, sizeof(uint32_t), OS_OPT_POST_FIFO, &err);
}
void OSWrappers::signalRenderingDone()
{
}
void OSWrappers::waitForVSync()
{
OS_ERR err;
CPU_TS ts;
OS_MSG_SIZE msg_size;
OSQPend(&vsync_queue, 0, OS_OPT_PEND_NON_BLOCKING, &msg_size, &ts, &err);
OSQPend(&vsync_queue, 0, OS_OPT_PEND_BLOCKING, &msg_size, &ts, &err);
}
void OSWrappers::taskDelay(uint16_t ms)
{
OS_ERR err;
OSTimeDly(ms, OS_OPT_TIME_DLY, &err);
}
Now it works well, you can rell me if you find any fault.