- #include
- #include
- #include
-
- #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);
- }
|
|
2023-1-3 11:36:43
评论
举报
|
|
|