2015-10-19 20:22:13 +00:00
|
|
|
/*
|
|
|
|
* This file is subject to the terms of the GFX License. If a copy of
|
|
|
|
* the license was not distributed with this file, you can obtain one at:
|
|
|
|
*
|
2018-10-01 15:32:39 +00:00
|
|
|
* http://ugfx.io/license.html
|
2015-10-19 20:22:13 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file src/gos/gos_cmsis.h
|
|
|
|
* @brief GOS - Operating System Support header file for CMSIS RTOS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _GOS_CMSIS_H
|
|
|
|
#define _GOS_CMSIS_H
|
|
|
|
|
|
|
|
#if GFX_USE_OS_CMSIS
|
|
|
|
|
|
|
|
#include "cmsis_os.h"
|
|
|
|
|
|
|
|
#ifndef GFX_OS_HEAP_SIZE
|
|
|
|
#define GFX_OS_HEAP_SIZE 10240
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Type definitions */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
2018-07-08 05:15:15 +00:00
|
|
|
#define gDelayNone 0
|
|
|
|
#define gDelayForever osWaitForever
|
2018-07-08 04:30:31 +00:00
|
|
|
typedef uint32_t gDelay;
|
|
|
|
typedef uint32_t gTicks;
|
|
|
|
typedef uint16_t gSemcount;
|
|
|
|
typedef void gThreadreturn;
|
|
|
|
typedef osPriority gThreadpriority;
|
2015-10-19 20:22:13 +00:00
|
|
|
|
|
|
|
#define MAX_SEMAPHORE_COUNT osFeature_Semaphore
|
2018-07-08 05:32:26 +00:00
|
|
|
#define gThreadpriorityLow osPriorityLow
|
|
|
|
#define gThreadpriorityNormal osPriorityNormal
|
|
|
|
#define gThreadpriorityHigh osPriorityHigh
|
2015-10-19 20:22:13 +00:00
|
|
|
|
|
|
|
typedef struct gfxSem {
|
2015-10-26 13:04:51 +00:00
|
|
|
uint32_t semaphore[2];
|
|
|
|
osSemaphoreId id;
|
2018-07-08 04:30:31 +00:00
|
|
|
gSemcount available;
|
2015-10-19 20:22:13 +00:00
|
|
|
} gfxSem;
|
|
|
|
|
|
|
|
typedef struct gfxMutex {
|
2015-10-25 21:10:00 +00:00
|
|
|
uint32_t mutex[4];
|
2015-10-19 20:22:13 +00:00
|
|
|
osMutexId id;
|
|
|
|
} gfxMutex;
|
|
|
|
|
2018-07-08 05:40:27 +00:00
|
|
|
typedef osThreadId gThread;
|
2015-10-19 20:22:13 +00:00
|
|
|
|
|
|
|
#define DECLARE_THREAD_STACK(name, sz) uint8_t name[1]; // Some compilers don't allow zero sized arrays. Let's waste one byte
|
2018-07-08 04:30:31 +00:00
|
|
|
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void* param)
|
2015-10-19 20:22:13 +00:00
|
|
|
#define THREAD_RETURN(retval)
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Function declarations. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
#define gfxExit() os_error(0)
|
|
|
|
#define gfxHalt(msg) os_error(1)
|
|
|
|
#define gfxSystemTicks() osKernelSysTick()
|
|
|
|
#define gfxMillisecondsToTicks(ms) osKernelSysTickMicroSec(1000*ms)
|
|
|
|
#define gfxSystemLock() osKernelInitialize()
|
|
|
|
#define gfxSystemUnlock() osKernelStart()
|
|
|
|
#define gfxSleepMilliseconds(ms) osDelay(ms)
|
|
|
|
|
|
|
|
void gfxMutexInit(gfxMutex* pmutex);
|
|
|
|
#define gfxMutexDestroy(pmutex) osMutexDelete((pmutex)->id)
|
2018-07-08 05:15:15 +00:00
|
|
|
#define gfxMutexEnter(pmutex) osMutexWait((pmutex)->id, gDelayForever)
|
2015-10-19 20:22:13 +00:00
|
|
|
#define gfxMutexExit(pmutex) osMutexRelease((pmutex)->id)
|
|
|
|
|
2018-07-08 04:30:31 +00:00
|
|
|
void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit);
|
2015-10-19 20:22:13 +00:00
|
|
|
void gfxSemDestroy(gfxSem* psem);
|
2018-07-08 04:30:31 +00:00
|
|
|
gBool gfxSemWait(gfxSem* psem, gDelay ms);
|
2018-06-23 03:02:07 +00:00
|
|
|
gBool gfxSemWaitI(gfxSem* psem);
|
2015-10-19 20:22:13 +00:00
|
|
|
void gfxSemSignal(gfxSem* psem);
|
|
|
|
void gfxSemSignalI(gfxSem* psem);
|
|
|
|
|
2018-07-08 05:40:27 +00:00
|
|
|
gThread gfxThreadCreate(void* stackarea, size_t stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void* param);
|
2015-10-19 20:22:13 +00:00
|
|
|
#define gfxYield() osThreadYield()
|
|
|
|
#define gfxThreadMe() osThreadGetId()
|
|
|
|
#define gfxThreadClose(thread) {}
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Use the generic heap handling */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
2018-02-27 07:44:21 +00:00
|
|
|
#define GOS_NEED_X_HEAP GFXON
|
2015-10-19 20:22:13 +00:00
|
|
|
#include "gos_x_heap.h"
|
|
|
|
|
|
|
|
#endif /* GFX_USE_OS_CMSIS */
|
|
|
|
#endif /* _GOS_CMSIS_H */
|