Added type gDelay to replace V2.x delaytime_t
Added type gTicks to replace V2.x systemticks_t Added type gThreadreturn to replace V2.x threadreturn_t Added type gThreadpriority to replace V2.x threadpriority_t
This commit is contained in:
parent
e23ae94e91
commit
215f31ee3d
@ -13,12 +13,12 @@
|
||||
{
|
||||
}
|
||||
|
||||
systemticks_t gfxSystemTicks(void)
|
||||
gTicks gfxSystemTicks(void)
|
||||
{
|
||||
return HAL_GetTick();
|
||||
}
|
||||
|
||||
systemticks_t gfxMillisecondsToTicks(delaytime_t ms)
|
||||
gTicks gfxMillisecondsToTicks(gDelay ms)
|
||||
{
|
||||
return ms;
|
||||
}
|
||||
|
@ -8,12 +8,12 @@
|
||||
#include "stm32f4xx_hal.h"
|
||||
|
||||
#if !GFX_USE_OS_CHIBIOS
|
||||
systemticks_t gfxSystemTicks(void)
|
||||
gTicks gfxSystemTicks(void)
|
||||
{
|
||||
return HAL_GetTick();
|
||||
}
|
||||
|
||||
systemticks_t gfxMillisecondsToTicks(delaytime_t ms)
|
||||
gTicks gfxMillisecondsToTicks(gDelay ms)
|
||||
{
|
||||
return ms;
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ static HAL_StatusTypeDef _HAL_SDRAM_SendCommand(SDRAM_HandleTypeDef *hsdram, FMC
|
||||
static HAL_StatusTypeDef _FMC_SDRAM_SendCommand(FMC_SDRAM_TypeDef *Device, FMC_SDRAM_CommandTypeDef *Command, uint32_t Timeout)
|
||||
{
|
||||
__IO uint32_t tmpr = 0;
|
||||
systemticks_t tickstart = 0;
|
||||
gTicks tickstart = 0;
|
||||
|
||||
/* Set command register */
|
||||
tmpr = (uint32_t)((Command->CommandMode) |\
|
||||
|
@ -9,12 +9,12 @@
|
||||
#if GFX_USE_OS_CHIBIOS
|
||||
#define HAL_GPIO_Init(port, ptr) palSetGroupMode(port, (ptr)->Pin, 0, (ptr)->Mode|((ptr)->Speed<<3)|((ptr)->Pull<<5)|((ptr)->Alternate<<7))
|
||||
#else
|
||||
systemticks_t gfxSystemTicks(void)
|
||||
gTicks gfxSystemTicks(void)
|
||||
{
|
||||
return HAL_GetTick();
|
||||
}
|
||||
|
||||
systemticks_t gfxMillisecondsToTicks(delaytime_t ms)
|
||||
gTicks gfxMillisecondsToTicks(gDelay ms)
|
||||
{
|
||||
return ms;
|
||||
}
|
||||
|
@ -15,17 +15,21 @@ FEATURE: Added GFX_COMPAT_OLDCOLORS to allow V2.x Red, Green, Blue color names.
|
||||
CHANGE: Added GFX_RED, GFX_BLUE, GFX_GREEN etc to replace V2.x Red, Gree, Blue color names
|
||||
CHANGE: Added GFXON/GFXOFF to replace V2.x TRUE/FALSE for configuration options.
|
||||
CHANGE: Added types gI8, gU8 .. gI32, gU32 to replace V2.x int8_t etc
|
||||
CHANGE: Added type gBool to replace V2.x bool_t, and values gTrue/gFalse to replace TRUE/FALSE
|
||||
CHANGE: Added type gPoint to replace V2.x point and point_t
|
||||
CHANGE: Added type gCoord to replace V2.x coord_t
|
||||
CHANGE: Added type gPixel to replace V2.x pixel_t
|
||||
CHANGE: Added type gColor to replace V2.x color_t
|
||||
CHANGE: Added type gColorformat to replace V2.x colorformat
|
||||
CHANGE: Added type gFont to replace V2.x font_t
|
||||
CHANGE: Added type gPowermode to replace V2.x powermode_t, and values gPowerXXX replace powerXXX
|
||||
CHANGE: Added type gJustify to replace V2.x justify_t, and values gJustifyXXX replace justifyXXX
|
||||
CHANGE: Added type gFontmetric to replace V2.x fontmetric_t, and values gFontXXX replace fontXXX
|
||||
CHANGE: Added type gOrientation to replace V2.x orientation_t, and values gOrientationX replace GDISP_ROTATE_X
|
||||
CHANGE: Added type gBool to replace V2.x bool_t, and values gTrue/gFalse to replace TRUE/FALSE
|
||||
CHANGE: Added type gDelay to replace V2.x delaytime_t
|
||||
CHANGE: Added type gTicks to replace V2.x systemticks_t
|
||||
CHANGE: Added type gThreadreturn to replace V2.x threadreturn_t
|
||||
CHANGE: Added type gThreadpriority to replace V2.x threadpriority_t
|
||||
CHANGE: Added type gPoint to replace V2.x point and point_t
|
||||
CHANGE: Added type gCoord to replace V2.x coord_t
|
||||
CHANGE: Added type gPixel to replace V2.x pixel_t
|
||||
CHANGE: Added type gColor to replace V2.x color_t
|
||||
CHANGE: Added type gColorformat to replace V2.x colorformat
|
||||
CHANGE: Added type gFont to replace V2.x font_t
|
||||
CHANGE: Added type gPowermode to replace V2.x powermode_t, and values gPowerXXX replace powerXXX
|
||||
CHANGE: Added type gJustify to replace V2.x justify_t, and values gJustifyXXX replace justifyXXX
|
||||
CHANGE: Added type gFontmetric to replace V2.x fontmetric_t, and values gFontXXX replace fontXXX
|
||||
CHANGE: Added type gOrientation to replace V2.x orientation_t, and values gOrientationX replace GDISP_ROTATE_X
|
||||
CHANGE: Added macros JUSTIFYMASK_HORIZONTAL, JUSTIFYMASK_VERTICAL to replace macros JUSTIFYMASK_LEFTRIGHT, JUSTIFYMASK_TOPBOTTOM
|
||||
FEATURE: Added types gPtr and gPtrDiff
|
||||
FEATURE: Added gI64 and gU64 when the compiler supports it. GFX_TYPE_64 macro is defined as GFXON if it does.
|
||||
|
@ -102,8 +102,8 @@ static void clean_SelCheck(void) {
|
||||
|
||||
static void remove_Selected(void) {
|
||||
uint16_t i ,j, step;
|
||||
systemticks_t delay_start = 0;
|
||||
systemticks_t delay=0;
|
||||
gTicks delay_start = 0;
|
||||
gTicks delay=0;
|
||||
for (step = 0; step < JG10_ANIM_IMAGES; step++) {
|
||||
delay_start = gfxSystemTicks();
|
||||
for (i = 0; i < JG10_FIELD_WIDTH; i++) {
|
||||
|
@ -78,8 +78,8 @@ const int tetrisShapes[TETRIS_SHAPE_COUNT][4][2] = {
|
||||
int tetrisField[TETRIS_FIELD_HEIGHT][TETRIS_FIELD_WIDTH]; // main tetris field array
|
||||
unsigned int tetrisGameSpeed = 500; // game auto-move speed in ms
|
||||
unsigned int tetrisKeySpeed = 140; // game key repeat speed in ms
|
||||
systemticks_t tetrisPreviousGameTime = 0;
|
||||
systemticks_t tetrisPreviousKeyTime = 0;
|
||||
gTicks tetrisPreviousGameTime = 0;
|
||||
gTicks tetrisPreviousKeyTime = 0;
|
||||
int tetrisCurrentShape[4][2];
|
||||
int tetrisNextShape[4][2];
|
||||
int tetrisOldShape[4][2];
|
||||
@ -474,7 +474,7 @@ static DECLARE_THREAD_FUNCTION(thdTetris, arg) {
|
||||
tetrisPreviousKeyTime = gfxSystemTicks();
|
||||
}
|
||||
}
|
||||
return (threadreturn_t)0;
|
||||
return (gThreadreturn)0;
|
||||
}
|
||||
|
||||
static void tetrisDeinit(void) {
|
||||
|
@ -55,7 +55,7 @@ static gdispImage myImage;
|
||||
*/
|
||||
int main(void) {
|
||||
gCoord swidth, sheight, errx, erry, errcx, errcy;
|
||||
delaytime_t delay;
|
||||
gDelay delay;
|
||||
|
||||
gfxInit(); // Initialize the display
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
#error "--"
|
||||
#endif
|
||||
|
||||
threadreturn_t heartbeat1(void* param)
|
||||
gThreadreturn heartbeat1(void* param)
|
||||
{
|
||||
(void)param;
|
||||
|
||||
@ -31,10 +31,10 @@ threadreturn_t heartbeat1(void* param)
|
||||
gfxSleepMilliseconds(500);
|
||||
}
|
||||
|
||||
return (threadreturn_t)0;
|
||||
return (gThreadreturn)0;
|
||||
}
|
||||
|
||||
threadreturn_t heartbeat2(void* param)
|
||||
gThreadreturn heartbeat2(void* param)
|
||||
{
|
||||
(void)param;
|
||||
|
||||
@ -43,7 +43,7 @@ threadreturn_t heartbeat2(void* param)
|
||||
gfxSleepMilliseconds(900);
|
||||
}
|
||||
|
||||
return (threadreturn_t)0;
|
||||
return (gThreadreturn)0;
|
||||
}
|
||||
|
||||
int main(void)
|
||||
|
@ -63,7 +63,7 @@ gfxThreadHandle thd;
|
||||
* Thread function
|
||||
* Prints a message
|
||||
*/
|
||||
threadreturn_t Thread_function(void* param)
|
||||
gThreadreturn Thread_function(void* param)
|
||||
{
|
||||
/* Cast the paramter into a gBool pointer so we can use it */
|
||||
gBool* doExit = (gBool*)param;
|
||||
@ -75,7 +75,7 @@ threadreturn_t Thread_function(void* param)
|
||||
}
|
||||
|
||||
/* Don't return anything */
|
||||
return (threadreturn_t)0;
|
||||
return (gThreadreturn)0;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -224,7 +224,7 @@ void gadcHighSpeedSetISRCallback(GADCISRCallbackFunction isrfn) {
|
||||
hsISRcallback = isrfn;
|
||||
}
|
||||
|
||||
GDataBuffer *gadcHighSpeedGetData(delaytime_t ms) {
|
||||
GDataBuffer *gadcHighSpeedGetData(gDelay ms) {
|
||||
return (GDataBuffer *)gfxQueueGSyncGet(&hsListDone, ms);
|
||||
}
|
||||
|
||||
|
@ -172,7 +172,7 @@ void gadcHighSpeedSetISRCallback(GADCISRCallbackFunction isrfn);
|
||||
* @api
|
||||
* @{
|
||||
*/
|
||||
GDataBuffer *gadcHighSpeedGetData(delaytime_t ms);
|
||||
GDataBuffer *gadcHighSpeedGetData(gDelay ms);
|
||||
GDataBuffer *gadcHighSpeedGetDataI(void);
|
||||
/** @} */
|
||||
|
||||
|
@ -119,7 +119,7 @@ void _gaudioDeinit(void)
|
||||
return gaudio_play_lld_set_volume(vol);
|
||||
}
|
||||
|
||||
gBool gaudioPlayWait(delaytime_t ms) {
|
||||
gBool gaudioPlayWait(gDelay ms) {
|
||||
if (!(playFlags & PLAYFLG_PLAYING))
|
||||
return gTrue;
|
||||
return gfxSemWait(&playComplete, ms);
|
||||
@ -213,7 +213,7 @@ void _gaudioDeinit(void)
|
||||
gfxBufferRelease(pd);
|
||||
}
|
||||
|
||||
GDataBuffer *gaudioRecordGetData(delaytime_t ms) {
|
||||
GDataBuffer *gaudioRecordGetData(gDelay ms) {
|
||||
return (GDataBuffer *)gfxQueueGSyncGet(&recordList, ms);
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
gBool gaudioPlayWait(delaytime_t ms);
|
||||
gBool gaudioPlayWait(gDelay ms);
|
||||
#endif
|
||||
|
||||
#if GAUDIO_NEED_RECORD || defined(__DOXYGEN__)
|
||||
@ -260,7 +260,7 @@
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
GDataBuffer *gaudioRecordGetData(delaytime_t ms);
|
||||
GDataBuffer *gaudioRecordGetData(gDelay ms);
|
||||
|
||||
#if GFX_USE_GEVENT || defined(__DOXYGEN__)
|
||||
/**
|
||||
|
@ -16,7 +16,7 @@
|
||||
extern void gdispImageClose_NATIVE(gdispImage *img);
|
||||
extern gdispImageError gdispImageCache_NATIVE(gdispImage *img);
|
||||
extern gdispImageError gdispGImageDraw_NATIVE(GDisplay *g, gdispImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy);
|
||||
extern delaytime_t gdispImageNext_NATIVE(gdispImage *img);
|
||||
extern gDelay gdispImageNext_NATIVE(gdispImage *img);
|
||||
#endif
|
||||
|
||||
#if GDISP_NEED_IMAGE_GIF
|
||||
@ -24,7 +24,7 @@
|
||||
extern void gdispImageClose_GIF(gdispImage *img);
|
||||
extern gdispImageError gdispImageCache_GIF(gdispImage *img);
|
||||
extern gdispImageError gdispGImageDraw_GIF(GDisplay *g, gdispImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy);
|
||||
extern delaytime_t gdispImageNext_GIF(gdispImage *img);
|
||||
extern gDelay gdispImageNext_GIF(gdispImage *img);
|
||||
#endif
|
||||
|
||||
#if GDISP_NEED_IMAGE_BMP
|
||||
@ -32,7 +32,7 @@
|
||||
extern void gdispImageClose_BMP(gdispImage *img);
|
||||
extern gdispImageError gdispImageCache_BMP(gdispImage *img);
|
||||
extern gdispImageError gdispGImageDraw_BMP(GDisplay *g, gdispImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy);
|
||||
extern delaytime_t gdispImageNext_BMP(gdispImage *img);
|
||||
extern gDelay gdispImageNext_BMP(gdispImage *img);
|
||||
extern uint16_t gdispImageGetPaletteSize_BMP(gdispImage *img);
|
||||
extern gColor gdispImageGetPalette_BMP(gdispImage *img, uint16_t index);
|
||||
extern gBool gdispImageAdjustPalette_BMP(gdispImage *img, uint16_t index, gColor newColor);
|
||||
@ -43,7 +43,7 @@
|
||||
extern void gdispImageClose_JPG(gdispImage *img);
|
||||
extern gdispImageError gdispImageCache_JPG(gdispImage *img);
|
||||
extern gdispImageError gdispGImageDraw_JPG(GDisplay *g, gdispImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy);
|
||||
extern delaytime_t gdispImageNext_JPG(gdispImage *img);
|
||||
extern gDelay gdispImageNext_JPG(gdispImage *img);
|
||||
#endif
|
||||
|
||||
#if GDISP_NEED_IMAGE_PNG
|
||||
@ -51,7 +51,7 @@
|
||||
extern void gdispImageClose_PNG(gdispImage *img);
|
||||
extern gdispImageError gdispImageCache_PNG(gdispImage *img);
|
||||
extern gdispImageError gdispGImageDraw_PNG(GDisplay *g, gdispImage *img, gCoord x, gCoord y, gCoord cx, gCoord cy, gCoord sx, gCoord sy);
|
||||
extern delaytime_t gdispImageNext_PNG(gdispImage *img);
|
||||
extern gDelay gdispImageNext_PNG(gdispImage *img);
|
||||
#endif
|
||||
|
||||
/* The structure defining the routines for image drawing */
|
||||
@ -64,7 +64,7 @@ typedef struct gdispImageHandlers {
|
||||
gCoord x, gCoord y,
|
||||
gCoord cx, gCoord cy,
|
||||
gCoord sx, gCoord sy); /* The draw function */
|
||||
delaytime_t (*next)(gdispImage *img); /* The next frame function */
|
||||
gDelay (*next)(gdispImage *img); /* The next frame function */
|
||||
uint16_t (*getPaletteSize)(gdispImage *img); /* Retrieve the size of the palette (number of entries) */
|
||||
gColor (*getPalette)(gdispImage *img, uint16_t index); /* Retrieve a specific color value of the palette */
|
||||
gBool (*adjustPalette)(gdispImage *img, uint16_t index, gColor newColor); /* Replace a color value in the palette */
|
||||
@ -186,7 +186,7 @@ gdispImageError gdispGImageDraw(GDisplay *g, gdispImage *img, gCoord x, gCoord y
|
||||
return img->fns->draw(g, img, x, y, cx, cy, sx, sy);
|
||||
}
|
||||
|
||||
delaytime_t gdispImageNext(gdispImage *img) {
|
||||
gDelay gdispImageNext(gdispImage *img) {
|
||||
if (!img) return GDISP_IMAGE_ERR_NULLPOINTER;
|
||||
if (!img->fns) return GDISP_IMAGE_ERR_BADFORMAT;
|
||||
return img->fns->next(img);
|
||||
|
@ -243,7 +243,7 @@ gdispImageError gdispGImageDraw(GDisplay *g, gdispImage *img, gCoord x, gCoord y
|
||||
* @note Calling gdispImageDraw() after getting a TIME_INFINITE will go back to drawing the first
|
||||
* frame/page.
|
||||
*/
|
||||
delaytime_t gdispImageNext(gdispImage *img);
|
||||
gDelay gdispImageNext(gdispImage *img);
|
||||
|
||||
/**
|
||||
* @brief Get the number of entries in the color palette.
|
||||
|
@ -815,7 +815,7 @@ gdispImageError gdispGImageDraw_BMP(GDisplay *g, gdispImage *img, gCoord x, gCoo
|
||||
return GDISP_IMAGE_ERR_OK;
|
||||
}
|
||||
|
||||
delaytime_t gdispImageNext_BMP(gdispImage *img) {
|
||||
gDelay gdispImageNext_BMP(gdispImage *img) {
|
||||
(void) img;
|
||||
|
||||
/* No more frames/pages */
|
||||
|
@ -1106,15 +1106,15 @@ baddatacleanup:
|
||||
return GDISP_IMAGE_ERR_BADDATA;
|
||||
}
|
||||
|
||||
delaytime_t gdispImageNext_GIF(gdispImage *img) {
|
||||
gDelay gdispImageNext_GIF(gdispImage *img) {
|
||||
gdispImagePrivate_GIF * priv;
|
||||
delaytime_t delay;
|
||||
gDelay delay;
|
||||
uint8_t blocksz;
|
||||
|
||||
priv = (gdispImagePrivate_GIF *)img->priv;
|
||||
|
||||
// Save the delay and convert to millisecs
|
||||
delay = (delaytime_t)priv->frame.delay * 10;
|
||||
delay = (gDelay)priv->frame.delay * 10;
|
||||
|
||||
// We need to get to the end of this frame
|
||||
if (!priv->frame.posend) {
|
||||
|
@ -198,7 +198,7 @@ gdispImageError gdispGImageDraw_JPG(GDisplay *g, gdispImage *img, gCoord x, gCoo
|
||||
return GDISP_IMAGE_ERR_OK;
|
||||
}
|
||||
|
||||
delaytime_t gdispImageNext_JPG(gdispImage *img) {
|
||||
gDelay gdispImageNext_JPG(gdispImage *img) {
|
||||
(void) img;
|
||||
|
||||
/* No more frames/pages */
|
||||
|
@ -140,7 +140,7 @@ gdispImageError gdispGImageDraw_NATIVE(GDisplay *g, gdispImage *img, gCoord x, g
|
||||
return GDISP_IMAGE_ERR_OK;
|
||||
}
|
||||
|
||||
delaytime_t gdispImageNext_NATIVE(gdispImage *img) {
|
||||
gDelay gdispImageNext_NATIVE(gdispImage *img) {
|
||||
(void) img;
|
||||
|
||||
/* No more frames/pages */
|
||||
|
@ -1621,7 +1621,7 @@ baddata:
|
||||
return GDISP_IMAGE_ERR_BADDATA;
|
||||
}
|
||||
|
||||
delaytime_t gdispImageNext_PNG(gdispImage *img) {
|
||||
gDelay gdispImageNext_PNG(gdispImage *img) {
|
||||
(void) img;
|
||||
|
||||
/* No more frames/pages */
|
||||
|
@ -115,7 +115,7 @@ void geventDetachSource(GListener *pl, GSourceHandle gsh) {
|
||||
}
|
||||
}
|
||||
|
||||
GEvent *geventEventWait(GListener *pl, delaytime_t timeout) {
|
||||
GEvent *geventEventWait(GListener *pl, gDelay timeout) {
|
||||
/* NOTE:
|
||||
We no longer try to protect against two threads trying to listen on the
|
||||
one listener. This was never allowed, it makes little sense to try to do so,
|
||||
|
@ -157,7 +157,7 @@ void geventDetachSource(GListener *pl, GSourceHandle gsh);
|
||||
*
|
||||
* @return NULL on timeout
|
||||
*/
|
||||
GEvent *geventEventWait(GListener *pl, delaytime_t timeout);
|
||||
GEvent *geventEventWait(GListener *pl, gDelay timeout);
|
||||
|
||||
/**
|
||||
* @brief Release the GEvent buffer associated with a listener.
|
||||
|
@ -48,7 +48,7 @@
|
||||
/*------------------------------------------------------------------------*/
|
||||
int ff_req_grant(_SYNC_t sobj)
|
||||
{
|
||||
if (gfxSemWait( (gfxSem*)&sobj, (delaytime_t)_FS_TIMEOUT) )
|
||||
if (gfxSemWait( (gfxSem*)&sobj, (gDelay)_FS_TIMEOUT) )
|
||||
return gTrue;
|
||||
return gFalse;
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ typedef struct GMouse {
|
||||
#define GMOUSE_FLG_NEEDREAD 0x0040 // The mouse needs reading
|
||||
#define GMOUSE_FLG_DRIVER_FIRST 0x0100 // The first flag available for the driver
|
||||
gPoint clickpos; // The position of the last click event
|
||||
systemticks_t clicktime; // The time of the last click event
|
||||
gTicks clicktime; // The time of the last click event
|
||||
GDisplay * display; // The display the mouse is associated with
|
||||
#if !GINPUT_TOUCH_NOCALIBRATE
|
||||
GMouseCalibration caldata; // The calibration data
|
||||
|
@ -57,11 +57,11 @@
|
||||
* @note Your platform may use slightly different definitions to these
|
||||
* @{
|
||||
*/
|
||||
typedef unsigned long delaytime_t;
|
||||
typedef unsigned long systemticks_t;
|
||||
typedef short semcount_t;
|
||||
typedef int threadreturn_t;
|
||||
typedef int threadpriority_t;
|
||||
typedef unsigned long gDelay;
|
||||
typedef unsigned long gTicks;
|
||||
typedef short gSemcount;
|
||||
typedef int gThreadreturn;
|
||||
typedef int gThreadpriority;
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
@ -70,7 +70,7 @@
|
||||
* @param[in] fnName The name of the function
|
||||
* @param[in] param A custom parameter that is passed to the function
|
||||
*/
|
||||
#define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(void *param)
|
||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
||||
|
||||
/**
|
||||
* @brief Declare a thread stack
|
||||
@ -100,8 +100,8 @@
|
||||
* @{
|
||||
*/
|
||||
#define TIME_IMMEDIATE 0
|
||||
#define TIME_INFINITE ((delaytime_t)-1)
|
||||
#define MAX_SEMAPHORE_COUNT ((semcount_t)(((unsigned long)((semcount_t)(-1))) >> 1))
|
||||
#define TIME_INFINITE ((gDelay)-1)
|
||||
#define MAX_SEMAPHORE_COUNT ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
|
||||
#define LOW_PRIORITY 0
|
||||
#define NORMAL_PRIORITY 1
|
||||
#define HIGH_PRIORITY 2
|
||||
@ -221,7 +221,7 @@
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
void gfxSleepMilliseconds(delaytime_t ms);
|
||||
void gfxSleepMilliseconds(gDelay ms);
|
||||
|
||||
/**
|
||||
* @brief Put the current thread to sleep for the specified period in microseconds
|
||||
@ -233,7 +233,7 @@
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
void gfxSleepMicroseconds(delaytime_t us);
|
||||
void gfxSleepMicroseconds(gDelay us);
|
||||
|
||||
/**
|
||||
* @brief Get the current operating system tick time
|
||||
@ -249,7 +249,7 @@
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
systemticks_t gfxSystemTicks(void);
|
||||
gTicks gfxSystemTicks(void);
|
||||
|
||||
/**
|
||||
* @brief Convert a given number of millseconds to a number of operating system ticks
|
||||
@ -262,7 +262,7 @@
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
systemticks_t gfxMillisecondsToTicks(delaytime_t ms);
|
||||
gTicks gfxMillisecondsToTicks(gDelay ms);
|
||||
|
||||
/**
|
||||
* @brief Lock the operating system to protect a sequence of code
|
||||
@ -344,7 +344,7 @@
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit);
|
||||
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit);
|
||||
|
||||
/**
|
||||
* @brief Destroy a Counted Semaphore
|
||||
@ -368,7 +368,7 @@
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
gBool gfxSemWait(gfxSem *psem, delaytime_t ms);
|
||||
gBool gfxSemWait(gfxSem *psem, gDelay ms);
|
||||
|
||||
/**
|
||||
* @brief Test if a wait on a semaphore can be satisfied immediately
|
||||
@ -420,7 +420,7 @@
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
||||
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
||||
|
||||
/**
|
||||
* @brief Wait for a thread to finish.
|
||||
@ -432,7 +432,7 @@
|
||||
* once the thread has ended.
|
||||
* @api
|
||||
*/
|
||||
threadreturn_t gfxThreadWait(gfxThreadHandle thread);
|
||||
gThreadreturn gfxThreadWait(gfxThreadHandle thread);
|
||||
|
||||
/**
|
||||
* @brief Get the current thread handle.
|
||||
@ -493,5 +493,12 @@
|
||||
#error "Your operating system is not supported yet"
|
||||
#endif
|
||||
|
||||
#if GFX_COMPAT_V2
|
||||
typedef gDelay delaytime_t;
|
||||
typedef gTicks systemticks_t;
|
||||
typedef gThreadreturn threadreturn_t;
|
||||
typedef gThreadpriority threadpriority_t;
|
||||
#endif
|
||||
|
||||
#endif /* _GOS_H */
|
||||
/** @} */
|
||||
|
@ -72,10 +72,10 @@ void gfxExit(void) {
|
||||
* Sleep functions
|
||||
*********************************************************/
|
||||
|
||||
systemticks_t gfxSystemTicks(void) {
|
||||
gTicks gfxSystemTicks(void) {
|
||||
return millis();
|
||||
}
|
||||
systemticks_t gfxMillisecondsToTicks(delaytime_t ms) {
|
||||
gTicks gfxMillisecondsToTicks(gDelay ms) {
|
||||
return ms;
|
||||
}
|
||||
|
||||
|
@ -17,8 +17,8 @@
|
||||
* malloc(), realloc and free() - if GOS_RAW_HEAP_SIZE == 0
|
||||
*
|
||||
* You must also define the following routines in your own code so that timing functions will work...
|
||||
* systemticks_t gfxSystemTicks(void);
|
||||
* systemticks_t gfxMillisecondsToTicks(delaytime_t ms);
|
||||
* gTicks gfxSystemTicks(void);
|
||||
* gTicks gfxMillisecondsToTicks(gDelay ms);
|
||||
*/
|
||||
#ifndef _GOS_ARDUINO_H
|
||||
#define _GOS_ARDUINO_H
|
||||
|
@ -81,7 +81,7 @@ void *gfxRealloc(void *ptr, size_t oldsz, size_t newsz)
|
||||
return np;
|
||||
}
|
||||
|
||||
void gfxSleepMilliseconds(delaytime_t ms)
|
||||
void gfxSleepMilliseconds(gDelay ms)
|
||||
{
|
||||
switch(ms) {
|
||||
case TIME_IMMEDIATE: chThdYield(); return;
|
||||
@ -90,7 +90,7 @@ void gfxSleepMilliseconds(delaytime_t ms)
|
||||
}
|
||||
}
|
||||
|
||||
void gfxSleepMicroseconds(delaytime_t ms)
|
||||
void gfxSleepMicroseconds(gDelay ms)
|
||||
{
|
||||
switch(ms) {
|
||||
case TIME_IMMEDIATE: return;
|
||||
@ -99,7 +99,7 @@ void gfxSleepMicroseconds(delaytime_t ms)
|
||||
}
|
||||
}
|
||||
|
||||
void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit)
|
||||
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit)
|
||||
{
|
||||
if (val > limit)
|
||||
val = limit;
|
||||
@ -118,7 +118,7 @@ void gfxSemDestroy(gfxSem *psem)
|
||||
chSemReset(&psem->sem, 1);
|
||||
}
|
||||
|
||||
gBool gfxSemWait(gfxSem *psem, delaytime_t ms)
|
||||
gBool gfxSemWait(gfxSem *psem, gDelay ms)
|
||||
{
|
||||
#if CH_KERNEL_MAJOR <= 2
|
||||
switch(ms) {
|
||||
@ -175,7 +175,7 @@ void gfxSemSignalI(gfxSem *psem)
|
||||
#endif
|
||||
}
|
||||
|
||||
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param)
|
||||
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param)
|
||||
{
|
||||
if (!stackarea) {
|
||||
if (!stacksz) stacksz = 256;
|
||||
|
@ -31,28 +31,28 @@
|
||||
*/
|
||||
|
||||
#if CH_KERNEL_MAJOR <= 4
|
||||
typedef systime_t delaytime_t;
|
||||
typedef systime_t gDelay;
|
||||
#else
|
||||
typedef sysinterval_t delaytime_t;
|
||||
typedef sysinterval_t gDelay;
|
||||
#endif
|
||||
typedef systime_t systemticks_t;
|
||||
typedef cnt_t semcount_t;
|
||||
typedef msg_t threadreturn_t;
|
||||
typedef tprio_t threadpriority_t;
|
||||
typedef systime_t gTicks;
|
||||
typedef cnt_t gSemcount;
|
||||
typedef msg_t gThreadreturn;
|
||||
typedef tprio_t gThreadpriority;
|
||||
|
||||
#define MAX_SEMAPHORE_COUNT ((semcount_t)(((unsigned long)((semcount_t)(-1))) >> 1))
|
||||
#define MAX_SEMAPHORE_COUNT ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
|
||||
#define LOW_PRIORITY LOWPRIO
|
||||
#define NORMAL_PRIORITY NORMALPRIO
|
||||
#define HIGH_PRIORITY HIGHPRIO
|
||||
|
||||
#define DECLARE_THREAD_STACK(name, sz) WORKING_AREA(name, sz)
|
||||
#define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(void *param)
|
||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
||||
#define THREAD_RETURN(retval) return retval
|
||||
|
||||
#if CH_KERNEL_MAJOR <= 2
|
||||
typedef struct {
|
||||
Semaphore sem;
|
||||
semcount_t limit;
|
||||
gSemcount limit;
|
||||
} gfxSem;
|
||||
|
||||
typedef Mutex gfxMutex;
|
||||
@ -63,7 +63,7 @@ typedef tprio_t threadpriority_t;
|
||||
|
||||
typedef struct {
|
||||
semaphore_t sem;
|
||||
semcount_t limit;
|
||||
gSemcount limit;
|
||||
} gfxSem;
|
||||
|
||||
typedef mutex_t gfxMutex;
|
||||
@ -104,15 +104,15 @@ typedef tprio_t threadpriority_t;
|
||||
#define gfxMutexDestroy(pmutex) (void)pmutex
|
||||
#define gfxMutexEnter(pmutex) chMtxLock(pmutex)
|
||||
void *gfxRealloc(void *ptr, size_t oldsz, size_t newsz);
|
||||
void gfxSleepMilliseconds(delaytime_t ms);
|
||||
void gfxSleepMicroseconds(delaytime_t ms);
|
||||
void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit);
|
||||
void gfxSleepMilliseconds(gDelay ms);
|
||||
void gfxSleepMicroseconds(gDelay ms);
|
||||
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit);
|
||||
void gfxSemDestroy(gfxSem *psem);
|
||||
gBool gfxSemWait(gfxSem *psem, delaytime_t ms);
|
||||
gBool gfxSemWait(gfxSem *psem, gDelay ms);
|
||||
gBool gfxSemWaitI(gfxSem *psem);
|
||||
void gfxSemSignal(gfxSem *psem);
|
||||
void gfxSemSignalI(gfxSem *psem);
|
||||
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
||||
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
||||
#define gfxThreadWait(thread) chThdWait(thread)
|
||||
#define gfxThreadMe() chThdSelf()
|
||||
#define gfxThreadClose(thread) (void)thread
|
||||
|
@ -46,7 +46,7 @@ void gfxMutexInit(gfxMutex* pmutex)
|
||||
pmutex->id = osMutexCreate(&def);
|
||||
}
|
||||
|
||||
void gfxSemInit(gfxSem* psem, semcount_t val, semcount_t limit)
|
||||
void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit)
|
||||
{
|
||||
osSemaphoreDef_t def;
|
||||
def.semaphore = psem->semaphore;
|
||||
@ -61,7 +61,7 @@ void gfxSemDestroy(gfxSem* psem)
|
||||
osSemaphoreDelete(psem->id);
|
||||
}
|
||||
|
||||
gBool gfxSemWait(gfxSem* psem, delaytime_t ms)
|
||||
gBool gfxSemWait(gfxSem* psem, gDelay ms)
|
||||
{
|
||||
if (osSemaphoreWait(psem->id, ms) > 0) {
|
||||
psem->available++;
|
||||
@ -88,7 +88,7 @@ void gfxSemSignalI(gfxSem* psem)
|
||||
}
|
||||
}
|
||||
|
||||
gfxThreadHandle gfxThreadCreate(void* stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void* param)
|
||||
gfxThreadHandle gfxThreadCreate(void* stackarea, size_t stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void* param)
|
||||
{
|
||||
osThreadDef_t def;
|
||||
|
||||
@ -102,7 +102,7 @@ gfxThreadHandle gfxThreadCreate(void* stackarea, size_t stacksz, threadpriority_
|
||||
return osThreadCreate(&def, param);
|
||||
}
|
||||
|
||||
threadreturn_t gfxThreadWait(gfxThreadHandle thread) {
|
||||
gThreadreturn gfxThreadWait(gfxThreadHandle thread) {
|
||||
while(osThreadGetPriority(thread) == osPriorityError)
|
||||
gfxYield();
|
||||
}
|
||||
|
@ -27,11 +27,11 @@
|
||||
|
||||
#define TIME_IMMEDIATE 0
|
||||
#define TIME_INFINITE osWaitForever
|
||||
typedef uint32_t delaytime_t;
|
||||
typedef uint32_t systemticks_t;
|
||||
typedef uint16_t semcount_t;
|
||||
typedef void threadreturn_t;
|
||||
typedef osPriority threadpriority_t;
|
||||
typedef uint32_t gDelay;
|
||||
typedef uint32_t gTicks;
|
||||
typedef uint16_t gSemcount;
|
||||
typedef void gThreadreturn;
|
||||
typedef osPriority gThreadpriority;
|
||||
|
||||
#define MAX_SEMAPHORE_COUNT osFeature_Semaphore
|
||||
#define LOW_PRIORITY osPriorityLow
|
||||
@ -41,7 +41,7 @@ typedef osPriority threadpriority_t;
|
||||
typedef struct gfxSem {
|
||||
uint32_t semaphore[2];
|
||||
osSemaphoreId id;
|
||||
semcount_t available;
|
||||
gSemcount available;
|
||||
} gfxSem;
|
||||
|
||||
typedef struct gfxMutex {
|
||||
@ -52,7 +52,7 @@ typedef struct gfxMutex {
|
||||
typedef osThreadId gfxThreadHandle;
|
||||
|
||||
#define DECLARE_THREAD_STACK(name, sz) uint8_t name[1]; // Some compilers don't allow zero sized arrays. Let's waste one byte
|
||||
#define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(void* param)
|
||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void* param)
|
||||
#define THREAD_RETURN(retval)
|
||||
|
||||
/*===========================================================================*/
|
||||
@ -72,14 +72,14 @@ void gfxMutexInit(gfxMutex* pmutex);
|
||||
#define gfxMutexEnter(pmutex) osMutexWait((pmutex)->id, TIME_INFINITE)
|
||||
#define gfxMutexExit(pmutex) osMutexRelease((pmutex)->id)
|
||||
|
||||
void gfxSemInit(gfxSem* psem, semcount_t val, semcount_t limit);
|
||||
void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit);
|
||||
void gfxSemDestroy(gfxSem* psem);
|
||||
gBool gfxSemWait(gfxSem* psem, delaytime_t ms);
|
||||
gBool gfxSemWait(gfxSem* psem, gDelay ms);
|
||||
gBool gfxSemWaitI(gfxSem* psem);
|
||||
void gfxSemSignal(gfxSem* psem);
|
||||
void gfxSemSignalI(gfxSem* psem);
|
||||
|
||||
gfxThreadHandle gfxThreadCreate(void* stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void* param);
|
||||
gfxThreadHandle gfxThreadCreate(void* stackarea, size_t stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void* param);
|
||||
#define gfxYield() osThreadYield()
|
||||
#define gfxThreadMe() osThreadGetId()
|
||||
#define gfxThreadClose(thread) {}
|
||||
|
@ -64,19 +64,19 @@ void gfxMutexInit(gfxMutex* pmutex)
|
||||
*pmutex = osMutexNew(NULL);
|
||||
}
|
||||
|
||||
void gfxSemInit(gfxSem* psem, semcount_t val, semcount_t limit)
|
||||
void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit)
|
||||
{
|
||||
*psem = osSemaphoreNew(limit, val, NULL);
|
||||
}
|
||||
|
||||
gBool gfxSemWait(gfxSem* psem, delaytime_t ms)
|
||||
gBool gfxSemWait(gfxSem* psem, gDelay ms)
|
||||
{
|
||||
if (osSemaphoreAcquire(*psem, gfxMillisecondsToTicks(ms)) == osOK)
|
||||
return gTrue;
|
||||
return gFalse;
|
||||
}
|
||||
|
||||
gfxThreadHandle gfxThreadCreate(void* stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void* param)
|
||||
gfxThreadHandle gfxThreadCreate(void* stackarea, size_t stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void* param)
|
||||
{
|
||||
osThreadAttr_t def;
|
||||
|
||||
@ -93,7 +93,7 @@ gfxThreadHandle gfxThreadCreate(void* stackarea, size_t stacksz, threadpriority_
|
||||
return osThreadNew((osThreadFunc_t)fn, param, &def);
|
||||
}
|
||||
|
||||
threadreturn_t gfxThreadWait(gfxThreadHandle thread) {
|
||||
gThreadreturn gfxThreadWait(gfxThreadHandle thread) {
|
||||
while(1) {
|
||||
switch(osThreadGetState(thread)) {
|
||||
case osThreadReady:
|
||||
|
@ -27,11 +27,11 @@
|
||||
|
||||
#define TIME_IMMEDIATE 0
|
||||
#define TIME_INFINITE osWaitForever
|
||||
typedef uint32_t delaytime_t;
|
||||
typedef uint32_t systemticks_t;
|
||||
typedef uint16_t semcount_t;
|
||||
typedef void threadreturn_t;
|
||||
typedef osPriority_t threadpriority_t;
|
||||
typedef uint32_t gDelay;
|
||||
typedef uint32_t gTicks;
|
||||
typedef uint16_t gSemcount;
|
||||
typedef void gThreadreturn;
|
||||
typedef osPriority_t gThreadpriority;
|
||||
|
||||
#define MAX_SEMAPHORE_COUNT 65535UL
|
||||
#define LOW_PRIORITY osPriorityLow
|
||||
@ -45,7 +45,7 @@ typedef osMutexId_t gfxMutex;
|
||||
typedef osThreadId_t gfxThreadHandle;
|
||||
|
||||
#define DECLARE_THREAD_STACK(name, sz) uint8_t name[1]; // Some compilers don't allow zero sized arrays. Let's waste one byte
|
||||
#define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(void* param)
|
||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void* param)
|
||||
#define THREAD_RETURN(retval)
|
||||
|
||||
/*===========================================================================*/
|
||||
@ -65,14 +65,14 @@ void gfxMutexInit(gfxMutex* pmutex);
|
||||
#define gfxMutexEnter(pmutex) osMutexAcquire(*(pmutex), TIME_INFINITE)
|
||||
#define gfxMutexExit(pmutex) osMutexRelease(*(pmutex))
|
||||
|
||||
void gfxSemInit(gfxSem* psem, semcount_t val, semcount_t limit);
|
||||
void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit);
|
||||
#define gfxSemDestroy(psem) osSemaphoreDelete(*(psem))
|
||||
gBool gfxSemWait(gfxSem* psem, delaytime_t ms);
|
||||
gBool gfxSemWait(gfxSem* psem, gDelay ms);
|
||||
#define gfxSemWaitI(psem) gfxSemWait((psem), 0)
|
||||
#define gfxSemSignal(psem) osSemaphoreRelease(*(psem))
|
||||
#define gfxSemSignalI(psem) osSemaphoreRelease(*(psem))
|
||||
|
||||
gfxThreadHandle gfxThreadCreate(void* stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void* param);
|
||||
gfxThreadHandle gfxThreadCreate(void* stackarea, size_t stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void* param);
|
||||
#define gfxYield() osThreadYield()
|
||||
#define gfxThreadMe() osThreadGetId()
|
||||
#define gfxThreadClose(thread) {}
|
||||
|
@ -32,7 +32,7 @@ void _gosDeinit(void)
|
||||
/* ToDo */
|
||||
}
|
||||
|
||||
void gfxSleepMilliseconds(delaytime_t ms)
|
||||
void gfxSleepMilliseconds(gDelay ms)
|
||||
{
|
||||
switch(ms) {
|
||||
case TIME_IMMEDIATE: cyg_thread_yield(); return;
|
||||
@ -41,7 +41,7 @@ void gfxSleepMilliseconds(delaytime_t ms)
|
||||
}
|
||||
}
|
||||
|
||||
void gfxSleepMicroseconds(delaytime_t ms)
|
||||
void gfxSleepMicroseconds(gDelay ms)
|
||||
{
|
||||
switch(ms) {
|
||||
case TIME_IMMEDIATE: return;
|
||||
@ -50,7 +50,7 @@ void gfxSleepMicroseconds(delaytime_t ms)
|
||||
}
|
||||
}
|
||||
|
||||
void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit)
|
||||
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit)
|
||||
{
|
||||
if (val > limit)
|
||||
val = limit;
|
||||
@ -64,7 +64,7 @@ void gfxSemDestroy(gfxSem *psem)
|
||||
cyg_semaphore_destroy(&psem->sem);
|
||||
}
|
||||
|
||||
gBool gfxSemWait(gfxSem *psem, delaytime_t ms)
|
||||
gBool gfxSemWait(gfxSem *psem, gDelay ms)
|
||||
{
|
||||
switch(ms) {
|
||||
case TIME_IMMEDIATE: return cyg_semaphore_trywait(&psem->sem);
|
||||
@ -96,7 +96,7 @@ void gfxSemSignalI(gfxSem *psem)
|
||||
cyg_semaphore_post(&psem->sem);
|
||||
}
|
||||
|
||||
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param)
|
||||
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param)
|
||||
{
|
||||
gfxThreadHandle th;
|
||||
|
||||
|
@ -21,11 +21,11 @@
|
||||
#define TIME_IMMEDIATE 0
|
||||
#define TIME_INFINITE 0xFFFFFFFF
|
||||
|
||||
typedef cyg_ucount32 delaytime_t;
|
||||
typedef cyg_tick_count_t systemticks_t;
|
||||
typedef cyg_count32 semcount_t;
|
||||
typedef void threadreturn_t;
|
||||
typedef cyg_addrword_t threadpriority_t;
|
||||
typedef cyg_ucount32 gDelay;
|
||||
typedef cyg_tick_count_t gTicks;
|
||||
typedef cyg_count32 gSemcount;
|
||||
typedef void gThreadreturn;
|
||||
typedef cyg_addrword_t gThreadpriority;
|
||||
typedef cyg_handle_t gfxThreadHandle;
|
||||
|
||||
#define MAX_SEMAPHORE_COUNT 0x7FFFFFFF
|
||||
@ -34,12 +34,12 @@ typedef cyg_handle_t gfxThreadHandle;
|
||||
#define HIGH_PRIORITY 0
|
||||
|
||||
#define DECLARE_THREAD_STACK(name, sz) struct { cyg_thread t; unsigned char stk[(sz) & ~3]; } name[1]
|
||||
#define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(cyg_addrword_t param)
|
||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(cyg_addrword_t param)
|
||||
#define THREAD_RETURN(retval)
|
||||
|
||||
typedef struct {
|
||||
cyg_sem_t sem;
|
||||
semcount_t limit;
|
||||
gSemcount limit;
|
||||
} gfxSem;
|
||||
|
||||
typedef cyg_mutex_t gfxMutex;
|
||||
@ -55,8 +55,8 @@ typedef cyg_mutex_t gfxMutex;
|
||||
#define gfxYield() cyg_thread_yield()
|
||||
|
||||
#define gfxMillisecondsToTicks(ms) (((ms)*(CYGNUM_HAL_RTC_DENOMINATOR*1000))/(CYGNUM_HAL_RTC_NUMERATOR/1000))
|
||||
void gfxSleepMilliseconds(delaytime_t ms);
|
||||
void gfxSleepMicroseconds(delaytime_t ms);
|
||||
void gfxSleepMilliseconds(gDelay ms);
|
||||
void gfxSleepMicroseconds(gDelay ms);
|
||||
|
||||
#define gfxAlloc(sz) malloc(sz)
|
||||
#define gfxFree(ptr) free(ptr)
|
||||
@ -70,14 +70,14 @@ void gfxSleepMicroseconds(delaytime_t ms);
|
||||
#define gfxMutexDestroy(pmutex) cyg_mutex_destroy(pmutex)
|
||||
#define gfxMutexEnter(pmutex) cyg_mutex_lock(pmutex)
|
||||
|
||||
void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit);
|
||||
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit);
|
||||
void gfxSemDestroy(gfxSem *psem);
|
||||
gBool gfxSemWait(gfxSem *psem, delaytime_t ms);
|
||||
gBool gfxSemWait(gfxSem *psem, gDelay ms);
|
||||
gBool gfxSemWaitI(gfxSem *psem);
|
||||
void gfxSemSignal(gfxSem *psem);
|
||||
void gfxSemSignalI(gfxSem *psem);
|
||||
|
||||
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
||||
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
||||
#define gfxThreadWait(thread) NOTIMPLEMENTED_YET
|
||||
#define gfxThreadMe() cyg_thread_self()
|
||||
#define gfxThreadClose(thread) (void)thread
|
||||
|
@ -85,12 +85,12 @@ void* gfxRealloc(void *ptr, size_t oldsz, size_t newsz)
|
||||
return np;
|
||||
}
|
||||
|
||||
void gfxSleepMilliseconds(delaytime_t ms)
|
||||
void gfxSleepMilliseconds(gDelay ms)
|
||||
{
|
||||
vTaskDelay(gfxMillisecondsToTicks(ms));
|
||||
}
|
||||
|
||||
void gfxSleepMicroseconds(delaytime_t ms)
|
||||
void gfxSleepMicroseconds(gDelay ms)
|
||||
{
|
||||
|
||||
// delay milli seconds - microsecond resolution delay is not supported in FreeRTOS
|
||||
@ -106,7 +106,7 @@ void gfxMutexInit(gfxMutex *pmutex)
|
||||
#endif
|
||||
}
|
||||
|
||||
void gfxSemInit(gfxSem* psem, semcount_t val, semcount_t limit)
|
||||
void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit)
|
||||
{
|
||||
if (val > limit)
|
||||
val = limit;
|
||||
@ -117,7 +117,7 @@ void gfxSemInit(gfxSem* psem, semcount_t val, semcount_t limit)
|
||||
#endif
|
||||
}
|
||||
|
||||
gBool gfxSemWait(gfxSem* psem, delaytime_t ms)
|
||||
gBool gfxSemWait(gfxSem* psem, gDelay ms)
|
||||
{
|
||||
if (xSemaphoreTake(*psem, gfxMillisecondsToTicks(ms)) == pdPASS)
|
||||
return gTrue;
|
||||
@ -146,7 +146,7 @@ void gfxSemSignalI(gfxSem* psem)
|
||||
xSemaphoreGiveFromISR(*psem,&xHigherPriorityTaskWoken);
|
||||
}
|
||||
|
||||
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param)
|
||||
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param)
|
||||
{
|
||||
gfxThreadHandle task;
|
||||
(void) stackarea;
|
||||
@ -165,7 +165,7 @@ gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_
|
||||
}
|
||||
|
||||
#if INCLUDE_eTaskGetState == 1
|
||||
threadreturn_t gfxThreadWait(gfxThreadHandle thread) {
|
||||
gThreadreturn gfxThreadWait(gfxThreadHandle thread) {
|
||||
while (eTaskGetState(thread) != eDeleted)
|
||||
gfxYield();
|
||||
}
|
||||
|
@ -25,21 +25,21 @@
|
||||
/*===========================================================================*/
|
||||
|
||||
#define TIME_IMMEDIATE 0
|
||||
#define TIME_INFINITE ((delaytime_t)-1)
|
||||
typedef uint32_t delaytime_t;
|
||||
typedef portTickType systemticks_t;
|
||||
typedef int32_t semcount_t;
|
||||
typedef void threadreturn_t;
|
||||
typedef portBASE_TYPE threadpriority_t;
|
||||
#define TIME_INFINITE ((gDelay)-1)
|
||||
typedef uint32_t gDelay;
|
||||
typedef portTickType gTicks;
|
||||
typedef int32_t gSemcount;
|
||||
typedef void gThreadreturn;
|
||||
typedef portBASE_TYPE gThreadpriority;
|
||||
|
||||
#define MAX_SEMAPHORE_COUNT ((semcount_t)(((unsigned long)((semcount_t)(-1))) >> 1))
|
||||
#define MAX_SEMAPHORE_COUNT ((gSemcount)(((unsigned long)((gSemcount)(-1))) >> 1))
|
||||
#define LOW_PRIORITY 0
|
||||
#define NORMAL_PRIORITY configMAX_PRIORITIES/2
|
||||
#define HIGH_PRIORITY configMAX_PRIORITIES-1
|
||||
|
||||
/* FreeRTOS will allocate the stack when creating the thread */
|
||||
#define DECLARE_THREAD_STACK(name, sz) uint8_t name[1]
|
||||
#define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(void *param)
|
||||
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
|
||||
#define THREAD_RETURN(retval)
|
||||
|
||||
typedef xSemaphoreHandle gfxSem;
|
||||
@ -56,7 +56,7 @@ typedef xTaskHandle gfxThreadHandle;
|
||||
#define gfxFree(ptr) vPortFree(ptr)
|
||||
#define gfxYield() taskYIELD()
|
||||
#define gfxSystemTicks() xTaskGetTickCount()
|
||||
#define gfxMillisecondsToTicks(ms) ((systemticks_t)((ms) / portTICK_PERIOD_MS))
|
||||
#define gfxMillisecondsToTicks(ms) ((gTicks)((ms) / portTICK_PERIOD_MS))
|
||||
#define gfxSystemLock() taskENTER_CRITICAL()
|
||||
#define gfxSystemUnlock() taskEXIT_CRITICAL()
|
||||
|
||||
@ -66,20 +66,20 @@ void gfxMutexInit(gfxMutex* s);
|
||||
#define gfxMutexExit(pmutex) xSemaphoreGive(*(pmutex))
|
||||
|
||||
void *gfxRealloc(void *ptr, size_t oldsz, size_t newsz);
|
||||
void gfxSleepMilliseconds(delaytime_t ms);
|
||||
void gfxSleepMicroseconds(delaytime_t ms);
|
||||
void gfxSleepMilliseconds(gDelay ms);
|
||||
void gfxSleepMicroseconds(gDelay ms);
|
||||
|
||||
void gfxSemInit(gfxSem* psem, semcount_t val, semcount_t limit);
|
||||
void gfxSemInit(gfxSem* psem, gSemcount val, gSemcount limit);
|
||||
#define gfxSemDestroy(psem) vSemaphoreDelete(*(psem))
|
||||
gBool gfxSemWait(gfxSem* psem, delaytime_t ms);
|
||||
gBool gfxSemWait(gfxSem* psem, gDelay ms);
|
||||
gBool gfxSemWaitI(gfxSem* psem);
|
||||
void gfxSemSignal(gfxSem* psem);
|
||||
void gfxSemSignalI(gfxSem* psem);
|
||||
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
||||
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
|
||||
|
||||
#define gfxThreadMe() xTaskGetCurrentTaskHandle()
|
||||
#if INCLUDE_eTaskGetState == 1
|
||||
threadreturn_t gfxThreadWait(gfxThreadHandle thread);
|
||||
gThreadreturn gfxThreadWait(gfxThreadHandle thread);
|
||||
#endif
|
||||
#define gfxThreadClose(thread)
|
||||
|
||||
|
@ -60,7 +60,7 @@ void gfxHalt(const char *msg) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
void gfxSleepMilliseconds(delaytime_t ms) {
|
||||
void gfxSleepMilliseconds(gDelay ms) {
|
||||
struct timespec ts;
|
||||
|
||||
switch(ms) {
|
||||
@ -81,7 +81,7 @@ void gfxSleepMilliseconds(delaytime_t ms) {
|
||||
}
|
||||
}
|
||||
|
||||
void gfxSleepMicroseconds(delaytime_t us) {
|
||||
void gfxSleepMicroseconds(gDelay us) {
|
||||
struct timespec ts;
|
||||
|
||||
switch(us) {
|
||||
@ -102,14 +102,14 @@ void gfxSleepMicroseconds(delaytime_t us) {
|
||||
}
|
||||
}
|
||||
|
||||
systemticks_t gfxSystemTicks(void) {
|
||||
gTicks gfxSystemTicks(void) {
|
||||
struct timespec ts;
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
return ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
|
||||
}
|
||||
|
||||
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param) {
|
||||
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION |