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:
inmarket 2018-07-08 14:30:31 +10:00
parent e23ae94e91
commit 215f31ee3d
63 changed files with 359 additions and 348 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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) |\

View File

@ -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;
}

View File

@ -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.

View File

@ -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++) {

View File

@ -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) {

View File

@ -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

View File

@ -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)

View File

@ -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;
}
/*

View File

@ -224,7 +224,7 @@ void gadcHighSpeedSetISRCallback(GADCISRCallbackFunction isrfn) {
hsISRcallback = isrfn;
}
GDataBuffer *gadcHighSpeedGetData(delaytime_t ms) {
GDataBuffer *gadcHighSpeedGetData(gDelay ms) {
return (GDataBuffer *)gfxQueueGSyncGet(&hsListDone, ms);
}

View File

@ -172,7 +172,7 @@ void gadcHighSpeedSetISRCallback(GADCISRCallbackFunction isrfn);
* @api
* @{
*/
GDataBuffer *gadcHighSpeedGetData(delaytime_t ms);
GDataBuffer *gadcHighSpeedGetData(gDelay ms);
GDataBuffer *gadcHighSpeedGetDataI(void);
/** @} */

View File

@ -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);
}

View File

@ -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__)
/**

View File

@ -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);

View File

@ -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.

View File

@ -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 */

View File

@ -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) {

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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,

View File

@ -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.

View File

@ -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;
}

View File

@ -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

View File

@ -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 */
/** @} */

View File

@ -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;
}

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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();
}

View File

@ -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) {}

View File

@ -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:

View File

@ -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) {}

View File

@ -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;

View File

@ -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

View File

@ -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();
}

View File

@ -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)

View File

@ -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((*fn),p), void *param) {
gfxThreadHandle th;
(void) stackarea;
(void) stacksz;
@ -128,8 +128,8 @@ gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_
return th;
}
threadreturn_t gfxThreadWait(gfxThreadHandle thread) {
threadreturn_t retval;
gThreadreturn gfxThreadWait(gfxThreadHandle thread) {
gThreadreturn retval;
if (pthread_join(thread, &retval))
return 0;
@ -138,14 +138,14 @@ threadreturn_t gfxThreadWait(gfxThreadHandle thread) {
}
#if GFX_USE_POSIX_SEMAPHORES
void gfxSemInit(gfxSem *pSem, semcount_t val, semcount_t limit) {
void gfxSemInit(gfxSem *pSem, gSemcount val, gSemcount limit) {
pSem->max = limit;
sem_init(&pSem->sem, 0, val);
}
void gfxSemDestroy(gfxSem *pSem) {
sem_destroy(&pSem->sem);
}
gBool gfxSemWait(gfxSem *pSem, delaytime_t ms) {
gBool gfxSemWait(gfxSem *pSem, gDelay ms) {
switch (ms) {
case TIME_INFINITE:
return sem_wait(&pSem->sem) ? gFalse : gTrue;
@ -173,7 +173,7 @@ threadreturn_t gfxThreadWait(gfxThreadHandle thread) {
sem_post(&pSem->sem);
}
#else
void gfxSemInit(gfxSem *pSem, semcount_t val, semcount_t limit) {
void gfxSemInit(gfxSem *pSem, gSemcount val, gSemcount limit) {
pthread_mutex_init(&pSem->mtx, 0);
pthread_cond_init(&pSem->cond, 0);
pthread_mutex_lock(&pSem->mtx);
@ -185,7 +185,7 @@ threadreturn_t gfxThreadWait(gfxThreadHandle thread) {
pthread_mutex_destroy(&pSem->mtx);
pthread_cond_destroy(&pSem->cond);
}
gBool gfxSemWait(gfxSem *pSem, delaytime_t ms) {
gBool gfxSemWait(gfxSem *pSem, gDelay ms) {
pthread_mutex_lock(&pSem->mtx);
switch (ms) {

View File

@ -23,15 +23,15 @@
#include <semaphore.h>
#endif
typedef unsigned long systemticks_t;
typedef void * threadreturn_t;
typedef unsigned long delaytime_t;
typedef unsigned long gTicks;
typedef void * gThreadreturn;
typedef unsigned long gDelay;
typedef pthread_t gfxThreadHandle;
typedef int threadpriority_t;
typedef uint32_t semcount_t;
typedef int gThreadpriority;
typedef uint32_t gSemcount;
typedef pthread_mutex_t gfxMutex;
#define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(void *param)
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
#define DECLARE_THREAD_STACK(name, sz) uint8_t name[0];
#define THREAD_RETURN(retval) return retval
@ -50,8 +50,8 @@ typedef pthread_mutex_t gfxMutex;
#define gfxSemSignalI(psem) gfxSemSignal(psem)
#define TIME_IMMEDIATE 0
#define TIME_INFINITE ((delaytime_t)-1)
#define MAX_SEMAPHORE_COUNT ((semcount_t)-1)
#define TIME_INFINITE ((gDelay)-1)
#define MAX_SEMAPHORE_COUNT ((gSemcount)-1)
#define LOW_PRIORITY 10
#define NORMAL_PRIORITY 0
#define HIGH_PRIORITY -10
@ -59,14 +59,14 @@ typedef pthread_mutex_t gfxMutex;
#if GFX_USE_POSIX_SEMAPHORES
typedef struct gfxSem {
sem_t sem;
semcount_t max;
gSemcount max;
} gfxSem;
#else
typedef struct gfxSem {
pthread_mutex_t mtx;
pthread_cond_t cond;
semcount_t cnt;
semcount_t max;
gSemcount cnt;
gSemcount max;
} gfxSem;
#endif
@ -76,17 +76,17 @@ typedef pthread_mutex_t gfxMutex;
void gfxYield(void);
void gfxHalt(const char *msg);
void gfxSleepMilliseconds(delaytime_t ms);
void gfxSleepMicroseconds(delaytime_t ms);
systemticks_t gfxSystemTicks(void);
void gfxSleepMilliseconds(gDelay ms);
void gfxSleepMicroseconds(gDelay ms);
gTicks gfxSystemTicks(void);
void gfxSystemLock(void);
void gfxSystemUnlock(void);
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);
void gfxSemSignal(gfxSem *psem);
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
threadreturn_t gfxThreadWait(gfxThreadHandle thread);
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
gThreadreturn gfxThreadWait(gfxThreadHandle thread);
#endif /* GFX_USE_OS_LINUX */

View File

@ -52,12 +52,12 @@ void gfxExit(void) {
}
}
systemticks_t gfxSystemTicks(void)
gTicks gfxSystemTicks(void)
{
return alt_nticks();
}
systemticks_t gfxMillisecondsToTicks(delaytime_t ms)
gTicks gfxMillisecondsToTicks(gDelay ms)
{
return ms;
}

View File

@ -12,13 +12,13 @@
#include <sys/alt_alarm.h>
typedef alt_u32 systemticks_t;
typedef alt_u32 delaytime_t;
typedef alt_u32 gTicks;
typedef alt_u32 gDelay;
void gfxHalt(const char* msg);
void gfxExit(void);
systemticks_t gfxSystemTicks(void);
systemticks_t gfxMillisecondsToTicks(delaytime_t ms);
gTicks gfxSystemTicks(void);
gTicks gfxMillisecondsToTicks(gDelay ms);
// Use the generic thread handling and heap handling
#define GOS_NEED_X_THREADS GFXON

View File

@ -53,7 +53,7 @@ void gfxHalt(const char *msg) {
exit(1);
}
void gfxSleepMilliseconds(delaytime_t ms) {
void gfxSleepMilliseconds(gDelay ms) {
struct timespec ts;
switch(ms) {
@ -67,7 +67,7 @@ void gfxSleepMilliseconds(delaytime_t ms) {
}
}
void gfxSleepMicroseconds(delaytime_t us) {
void gfxSleepMicroseconds(gDelay us) {
struct timespec ts;
switch(us) {
@ -81,7 +81,7 @@ void gfxSleepMicroseconds(delaytime_t us) {
}
}
systemticks_t gfxSystemTicks(void) {
gTicks gfxSystemTicks(void) {
mach_timespec_t ts;
clock_serv_t cclock;
@ -92,7 +92,7 @@ systemticks_t gfxSystemTicks(void) {
return ts.tv_sec * 1000UL + 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((*fn),p), void *param) {
gfxThreadHandle th;
(void) stackarea;
(void) stacksz;
@ -110,15 +110,15 @@ gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_
return th;
}
threadreturn_t gfxThreadWait(gfxThreadHandle thread) {
threadreturn_t retval;
gThreadreturn gfxThreadWait(gfxThreadHandle thread) {
gThreadreturn retval;
if (pthread_join(thread, &retval))
return 0;
return retval;
}
void gfxSemInit(gfxSem *pSem, semcount_t val, semcount_t limit) {
void gfxSemInit(gfxSem *pSem, gSemcount val, gSemcount limit) {
pthread_mutex_init(&pSem->mtx, 0);
pthread_cond_init(&pSem->cond, 0);
pthread_mutex_lock(&pSem->mtx);
@ -132,7 +132,7 @@ void gfxSemDestroy(gfxSem *pSem) {
pthread_cond_destroy(&pSem->cond);
}
gBool gfxSemWait(gfxSem *pSem, delaytime_t ms) {
gBool gfxSemWait(gfxSem *pSem, gDelay ms) {
pthread_mutex_lock(&pSem->mtx);
switch (ms) {
case TIME_INFINITE:

View File

@ -14,15 +14,15 @@
#include <pthread.h>
#include <stdlib.h>
typedef unsigned long systemticks_t;
typedef void * threadreturn_t;
typedef unsigned long delaytime_t;
typedef unsigned long gTicks;
typedef void * gThreadreturn;
typedef unsigned long gDelay;
typedef pthread_t gfxThreadHandle;
typedef int threadpriority_t;
typedef uint32_t semcount_t;
typedef int gThreadpriority;
typedef uint32_t gSemcount;
typedef pthread_mutex_t gfxMutex;
#define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(void *param)
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
#define DECLARE_THREAD_STACK(name, sz) uint8_t name[0];
#define THREAD_RETURN(retval) return retval
@ -42,8 +42,8 @@ typedef pthread_mutex_t gfxMutex;
#define gfxSemSignalI(psem) gfxSemSignal(psem)
#define TIME_IMMEDIATE 0
#define TIME_INFINITE ((delaytime_t)-1)
#define MAX_SEMAPHORE_COUNT ((semcount_t)-1)
#define TIME_INFINITE ((gDelay)-1)
#define MAX_SEMAPHORE_COUNT ((gSemcount)-1)
#define LOW_PRIORITY 10
#define NORMAL_PRIORITY 0
#define HIGH_PRIORITY -10
@ -51,8 +51,8 @@ typedef pthread_mutex_t gfxMutex;
typedef struct gfxSem {
pthread_mutex_t mtx;
pthread_cond_t cond;
semcount_t cnt;
semcount_t max;
gSemcount cnt;
gSemcount max;
} gfxSem;
/*===========================================================================*/
@ -60,17 +60,17 @@ typedef struct gfxSem {
/*===========================================================================*/
void gfxHalt(const char *msg);
void gfxSleepMilliseconds(delaytime_t ms);
void gfxSleepMicroseconds(delaytime_t ms);
systemticks_t gfxSystemTicks(void);
void gfxSleepMilliseconds(gDelay ms);
void gfxSleepMicroseconds(gDelay ms);
gTicks gfxSystemTicks(void);
void gfxSystemLock(void);
void gfxSystemUnlock(void);
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);
void gfxSemSignal(gfxSem *psem);
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
threadreturn_t gfxThreadWait(gfxThreadHandle thread);
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
gThreadreturn gfxThreadWait(gfxThreadHandle thread);
#endif /* GFX_USE_OS_OSX */
#endif /* _GOS_OSX_H */

View File

@ -18,7 +18,7 @@ extern "C" void _gosPostInit(void);
class Thread : public QThread
{
public:
typedef threadreturn_t (*fptr)(void* param);
typedef gThreadreturn (*fptr)(void* param);
void setFunction(fptr function, void* param)
{
@ -26,7 +26,7 @@ public:
_param = param;
}
threadreturn_t returnValue()
gThreadreturn returnValue()
{
return _returnValue;
}
@ -43,7 +43,7 @@ public:
private:
fptr _function;
void* _param;
threadreturn_t _returnValue;
gThreadreturn _returnValue;
};
static QElapsedTimer _systickTimer;
@ -103,22 +103,22 @@ void gfxYield(void)
QThread::msleep(0);
}
void gfxSleepMilliseconds(delaytime_t ms)
void gfxSleepMilliseconds(gDelay ms)
{
QThread::msleep(ms);
}
void gfxSleepMicroseconds(delaytime_t us)
void gfxSleepMicroseconds(gDelay us)
{
QThread::usleep(us);
}
systemticks_t gfxSystemTicks(void)
gTicks gfxSystemTicks(void)
{
return _systickTimer.elapsed();
}
systemticks_t gfxMillisecondsToTicks(delaytime_t ms)
gTicks gfxMillisecondsToTicks(gDelay ms)
{
return ms;
}
@ -153,7 +153,7 @@ void gfxMutexExit(gfxMutex *pmutex)
static_cast<QMutex*>(*pmutex)->unlock();
}
void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit)
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit)
{
*psem = new QSemaphore(limit);
@ -165,7 +165,7 @@ void gfxSemDestroy(gfxSem *psem)
delete static_cast<QSemaphore*>(*psem);
}
gBool gfxSemWait(gfxSem *psem, delaytime_t ms)
gBool gfxSemWait(gfxSem *psem, gDelay ms)
{
return static_cast<QSemaphore*>(*psem)->tryAcquire(1, ms);
}
@ -185,7 +185,7 @@ void gfxSemSignalI(gfxSem *psem)
static_cast<QSemaphore*>(*psem)->release(1);
}
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)
{
Q_UNUSED(stackarea)
@ -199,11 +199,11 @@ gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_
return static_cast<gfxThreadHandle>(thread);
}
threadreturn_t gfxThreadWait(gfxThreadHandle thread)
gThreadreturn gfxThreadWait(gfxThreadHandle thread)
{
Thread* t = static_cast<Thread*>(thread);
threadreturn_t returnValue = t->returnValue();
gThreadreturn returnValue = t->returnValue();
t->wait();
t->exit();

View File

@ -10,24 +10,24 @@
#if GFX_USE_OS_QT
#define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(void *param)
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
#define DECLARE_THREAD_STACK(name, sz) uint8_t name[0]
#define THREAD_RETURN(retval) return retval
#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 2
#define NORMAL_PRIORITY 3
#define HIGH_PRIORITY 4
typedef int systemticks_t;
typedef int delaytime_t;
typedef int gTicks;
typedef int gDelay;
typedef void* gfxMutex;
typedef void* gfxSem;
typedef int semcount_t;
typedef int threadreturn_t;
typedef int threadpriority_t;
typedef int gSemcount;
typedef int gThreadreturn;
typedef int gThreadpriority;
typedef void* gfxThreadHandle;
void _gosInit();
@ -39,24 +39,24 @@ void* gfxAlloc(size_t sz);
void* gfxRealloc(void *ptr, size_t oldsz, size_t newsz);
void gfxFree(void* ptr);
void gfxYield(void);
void gfxSleepMilliseconds(delaytime_t ms);
void gfxSleepMicroseconds(delaytime_t us);
systemticks_t gfxSystemTicks(void);
systemticks_t gfxMillisecondsToTicks(delaytime_t ms);
void gfxSleepMilliseconds(gDelay ms);
void gfxSleepMicroseconds(gDelay us);
gTicks gfxSystemTicks(void);
gTicks gfxMillisecondsToTicks(gDelay ms);
void gfxSystemLock(void);
void gfxSystemUnlock(void);
void gfxMutexInit(gfxMutex *pmutex);
void gfxMutexDestroy(gfxMutex *pmutex);
void gfxMutexEnter(gfxMutex *pmutex);
void gfxMutexExit(gfxMutex *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);
threadreturn_t gfxThreadWait(gfxThreadHandle thread);
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION((*fn),p), void *param);
gThreadreturn gfxThreadWait(gfxThreadHandle thread);
gfxThreadHandle gfxThreadMe(void);
void gfxThreadClose(gfxThreadHandle thread);

View File

@ -74,8 +74,8 @@ void _gosDeinit(void)
#endif
#include <stdio.h>
systemticks_t gfxSystemTicks(void) { return GetTickCount(); }
systemticks_t gfxMillisecondsToTicks(delaytime_t ms) { return ms; }
gTicks gfxSystemTicks(void) { return GetTickCount(); }
gTicks gfxMillisecondsToTicks(gDelay ms) { return ms; }
#endif
/*********************************************************

View File

@ -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_RAW32_H
#define _GOS_RAW32_H

View File

@ -45,23 +45,23 @@ void _gosDeinit(void)
}
void gfxSleepMilliseconds(delaytime_t ms)
void gfxSleepMilliseconds(gDelay ms)
{
systemticks_t ticks = ms*RAW_TICKS_PER_SECOND/1000;
gTicks ticks = ms*RAW_TICKS_PER_SECOND/1000;
if(!ticks)ticks = 1;
raw_sleep(ticks);
}
void gfxSleepMicroseconds(delaytime_t us)
void gfxSleepMicroseconds(gDelay us)
{
systemticks_t ticks = (us/1000)*RAW_TICKS_PER_SECOND/1000;
gTicks ticks = (us/1000)*RAW_TICKS_PER_SECOND/1000;
if(!ticks)ticks = 1;
raw_sleep(ticks);
}
gBool gfxSemWait(gfxSem* psem, delaytime_t ms)
gBool gfxSemWait(gfxSem* psem, gDelay ms)
{
systemticks_t ticks = ms*RAW_TICKS_PER_SECOND/1000;
gTicks ticks = ms*RAW_TICKS_PER_SECOND/1000;
if(!ticks)ticks=1;
if(raw_semaphore_get((psem), ticks)==RAW_SUCCESS)
return gTrue;
@ -75,7 +75,7 @@ gBool gfxSemWaitI(gfxSem* psem)
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)
{
RAW_U16 ret;
gfxThreadHandle taskobj;

View File

@ -7,11 +7,11 @@
#define TIME_IMMEDIATE (RAW_NO_WAIT)
#define TIME_INFINITE (RAW_WAIT_FOREVER)
typedef uint32_t delaytime_t;
typedef RAW_TICK_TYPE systemticks_t;
typedef int32_t semcount_t;
typedef uint32_t threadreturn_t;
typedef RAW_U8 threadpriority_t;
typedef uint32_t gDelay;
typedef RAW_TICK_TYPE gTicks;
typedef int32_t gSemcount;
typedef uint32_t gThreadreturn;
typedef RAW_U8 gThreadpriority;
#define MAX_SEMAPHORE_COUNT RAW_SEMAPHORE_COUNT
#define LOW_PRIORITY (CONFIG_RAW_PRIO_MAX-2)
@ -22,7 +22,7 @@ typedef RAW_SEMAPHORE gfxSem;
typedef RAW_MUTEX gfxMutex;
typedef RAW_TASK_OBJ* gfxThreadHandle;
#define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(void *param)
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
#define DECLARE_THREAD_STACK(name, sz) PORT_STACK name[(sz) & ~3];
#define THREAD_RETURN(retval) return retval
@ -63,11 +63,11 @@ extern RAW_U16 raw_semaphore_delete(RAW_SEMAPHORE *semaphore_ptr);
extern RAW_U16 raw_semaphore_get(RAW_SEMAPHORE *semaphore_ptr, RAW_TICK_TYPE wait_option);
extern RAW_U16 raw_semaphore_put(RAW_SEMAPHORE *semaphore_ptr);
void gfxSleepMilliseconds(delaytime_t ms);
void gfxSleepMicroseconds(delaytime_t us);
gBool gfxSemWait(gfxSem* psem, delaytime_t ms);
void gfxSleepMilliseconds(gDelay ms);
void gfxSleepMicroseconds(gDelay us);
gBool gfxSemWait(gfxSem* psem, gDelay ms);
gBool gfxSemWaitI(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);
#endif

View File

@ -37,7 +37,7 @@ void gfxHalt(const char *msg) {
ExitProcess(1);
}
void gfxSleepMicroseconds(delaytime_t ms) {
void gfxSleepMicroseconds(gDelay ms) {
static LARGE_INTEGER pcfreq;
static int initflag;
LARGE_INTEGER t1, t2, tdiff;
@ -74,7 +74,7 @@ void gfxSystemUnlock(void) {
ReleaseMutex(SystemMutex);
}
gBool gfxSemWait(gfxSem *psem, delaytime_t ms) {
gBool gfxSemWait(gfxSem *psem, gDelay ms) {
return WaitForSingleObject(*psem, ms) == WAIT_OBJECT_0;
}
@ -87,7 +87,7 @@ typedef LONG (__stdcall *_NtQuerySemaphore)(
);
/* - Left here simply because of its undocumented cleverness...
semcount_t gfxSemCounter(gfxSem *pSem) {
gSemcount gfxSemCounter(gfxSem *pSem) {
static _NtQuerySemaphore NtQuerySemaphore;
struct _SEMAPHORE_BASIC_INFORMATION {
ULONG CurrentCount;
@ -103,7 +103,7 @@ semcount_t gfxSemCounter(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) {
(void) stackarea;
HANDLE thd;
@ -116,7 +116,7 @@ gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_
return thd;
}
threadreturn_t gfxThreadWait(gfxThreadHandle thread) {
gThreadreturn gfxThreadWait(gfxThreadHandle thread) {
DWORD ret;
WaitForSingleObject(thread, INFINITE);

View File

@ -25,19 +25,19 @@
#include <malloc.h>
typedef DWORD delaytime_t;
typedef DWORD systemticks_t;
typedef LONG semcount_t;
typedef DWORD threadreturn_t;
typedef int threadpriority_t;
typedef DWORD gDelay;
typedef DWORD gTicks;
typedef LONG gSemcount;
typedef DWORD gThreadreturn;
typedef int gThreadpriority;
#define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t (WINAPI fnName)(void *param)
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn (WINAPI fnName)(void *param)
#define DECLARE_THREAD_STACK(name, sz) uint8_t name[1];
#define THREAD_RETURN(retval) return retval
#define TIME_IMMEDIATE 0
#define TIME_INFINITE INFINITE
#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 THREAD_PRIORITY_BELOW_NORMAL
#define NORMAL_PRIORITY THREAD_PRIORITY_NORMAL
#define HIGH_PRIORITY THREAD_PRIORITY_ABOVE_NORMAL
@ -71,12 +71,12 @@ typedef HANDLE gfxThreadHandle;
/*===========================================================================*/
void gfxHalt(const char *msg);
void gfxSleepMicroseconds(delaytime_t ms);
gBool gfxSemWait(gfxSem *psem, delaytime_t ms);
void gfxSleepMicroseconds(gDelay ms);
gBool gfxSemWait(gfxSem *psem, gDelay ms);
void gfxSystemLock(void);
void gfxSystemUnlock(void);
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION(*fn,p), void *param);
threadreturn_t gfxThreadWait(gfxThreadHandle thread);
gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, gThreadpriority prio, DECLARE_THREAD_FUNCTION(*fn,p), void *param);
gThreadreturn gfxThreadWait(gfxThreadHandle thread);
#endif /* GFX_USE_OS_WIN32 */
#endif /* _GOS_WIN32_H */

View File

@ -45,13 +45,13 @@ void gfxMutexExit(gfxMutex *pmutex) {
pmutex[0] = 0;
}
void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit) {
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit) {
psem->cnt = val;
psem->limit = limit;
}
gBool gfxSemWait(gfxSem *psem, delaytime_t ms) {
systemticks_t starttm, delay;
gBool gfxSemWait(gfxSem *psem, gDelay ms) {
gTicks starttm, delay;
// Convert our delay to ticks
starttm = 0;
@ -112,8 +112,8 @@ void gfxSemSignalI(gfxSem *psem) {
* Sleep functions
*********************************************************/
void gfxSleepMilliseconds(delaytime_t ms) {
systemticks_t starttm, delay;
void gfxSleepMilliseconds(gDelay ms) {
gTicks starttm, delay;
// Safety first
switch (ms) {
@ -134,8 +134,8 @@ void gfxSleepMilliseconds(delaytime_t ms) {
} while (gfxSystemTicks() - starttm < delay);
}
void gfxSleepMicroseconds(delaytime_t ms) {
systemticks_t starttm, delay;
void gfxSleepMicroseconds(gDelay ms) {
gTicks starttm, delay;
// Safety first
switch (ms) {
@ -176,7 +176,7 @@ typedef struct thread {
#define FLG_THD_DEAD 0x0004
#define FLG_THD_WAIT 0x0008
size_t size; // Size of the thread stack (including this structure)
threadreturn_t (*fn)(void *param); // Thread function
gThreadreturn (*fn)(void *param); // Thread function
void * param; // Parameter for the thread function
void * cxt; // The current thread context.
} thread;
@ -485,7 +485,7 @@ void gfxYield(void) {
}
// This routine is not currently public - but it could be.
void gfxThreadExit(threadreturn_t ret) {
void gfxThreadExit(gThreadreturn ret) {
thread *me;
// Save the results in case someone is waiting
@ -508,7 +508,7 @@ void gfxThreadExit(threadreturn_t ret) {
// We never get back here as we didn't re-queue ourselves
}
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) {
thread * t;
thread * me;
(void) prio;
@ -543,7 +543,7 @@ gfxThreadHandle gfxThreadCreate(void *stackarea, size_t stacksz, threadpriority_
return t;
}
threadreturn_t gfxThreadWait(gfxThreadHandle th) {
gThreadreturn gfxThreadWait(gfxThreadHandle th) {
thread * t;
t = th;
@ -565,7 +565,7 @@ threadreturn_t gfxThreadWait(gfxThreadHandle th) {
gfxFree(t);
// Return the status left by the dead process
return (threadreturn_t)t->param;
return (gThreadreturn)t->param;
}
#endif /* GFX_USE_OS_RAW32 */

View File

@ -16,46 +16,46 @@
* memcpy() - for heap and threading
*
* 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_X_THREADS_H
#define _GOS_X_THREADS_H
#if GOS_NEED_X_THREADS
typedef uint32_t delaytime_t;
typedef uint32_t systemticks_t;
typedef short semcount_t;
typedef int threadreturn_t;
typedef int threadpriority_t;
typedef uint32_t gDelay;
typedef uint32_t gTicks;
typedef short gSemcount;
typedef int gThreadreturn;
typedef int gThreadpriority;
#define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(void *param)
#define DECLARE_THREAD_FUNCTION(fnName, param) gThreadreturn fnName(void *param)
#define DECLARE_THREAD_STACK(name, sz) uint8_t name[(sz) & ~3];
#define THREAD_RETURN(retval) return retval
#define TIME_IMMEDIATE 0
#define TIME_INFINITE ((delaytime_t)-1)
#define TIME_INFINITE ((gDelay)-1)
#define MAX_SEMAPHORE_COUNT 0x7FFF
#define LOW_PRIORITY 0
#define NORMAL_PRIORITY 1
#define HIGH_PRIORITY 2
typedef struct {
semcount_t cnt;
semcount_t limit;
gSemcount cnt;
gSemcount limit;
} gfxSem;
typedef uint32_t gfxMutex;
typedef void * gfxThreadHandle;
// Required timing functions - supplied by the user or the operating system
systemticks_t gfxSystemTicks(void);
systemticks_t gfxMillisecondsToTicks(delaytime_t ms);
gTicks gfxSystemTicks(void);
gTicks gfxMillisecondsToTicks(gDelay ms);
// Sleep Functions
void gfxSleepMilliseconds(delaytime_t ms);
void gfxSleepMicroseconds(delaytime_t ms);
void gfxSleepMilliseconds(gDelay ms);
void gfxSleepMicroseconds(gDelay ms);
void gfxYield(void);
// System Locking
@ -69,24 +69,24 @@ void gfxMutexEnter(gfxMutex *pmutex);
void gfxMutexExit(gfxMutex *pmutex);
// Semaphores
void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit);
void gfxSemInit(gfxSem *psem, gSemcount val, gSemcount limit);
#define gfxSemDestroy(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);
// Threads
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 gfxThreadClose(thread)
threadreturn_t gfxThreadWait(gfxThreadHandle thread);
gThreadreturn gfxThreadWait(gfxThreadHandle thread);
gfxThreadHandle gfxThreadMe(void);
/** The following is not part of the public ugfx API as some operating systems
* simply do not provide this capability.
* For RAW32 we need it anyway so we might as well declare it here.
*/
void gfxThreadExit(threadreturn_t ret);
void gfxThreadExit(gThreadreturn ret);
#endif /* GOS_NEED_X_THREADS */
#endif /* _GOS_X_THREADS_H */

View File

@ -9,7 +9,7 @@
#if GFX_USE_OS_ZEPHYR
systemticks_t gfxSystemTicks(void)
gTicks gfxSystemTicks(void)
{
s32_t ms = k_uptime_get_32();
return CONFIG_SYS_CLOCK_TICKS_PER_SEC*ms/1000;

View File

@ -16,14 +16,14 @@
/* Type definitions */
/*===========================================================================*/
typedef s32_t delaytime_t;
typedef u32_t systemticks_t;
typedef u32_t semcount_t;
typedef void threadreturn_t;
typedef int threadpriority_t;
typedef s32_t gDelay;
typedef u32_t gTicks;
typedef u32_t gSemcount;
typedef void gThreadreturn;
typedef int gThreadpriority;
#define DECLARE_THREAD_FUNCTION(fnName, param)\
threadreturn_t fnName(void* param, void* p2, void* p3)
gThreadreturn fnName(void* param, void* p2, void* p3)
#define DECLARE_THREAD_STACK(name, sz)\
K_THREAD_STACK_DEFINE(name, sz)
@ -32,7 +32,7 @@ typedef int threadpriority_t;
#define TIME_IMMEDIATE K_NO_WAIT
#define TIME_INFINITE K_FOREVER
#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 CONFIG_NUM_PREEMPT_PRIORITIES-1
#define NORMAL_PRIORITY 1
#define HIGH_PRIORITY 0
@ -59,7 +59,7 @@ typedef k_tid_t gfxThreadHandle;
#define gfxSleepMilliseconds(ms) k_sleep(ms)
#define gfxSleepMicroseconds(us) do{}while(0)
#define gfxMillisecondsToTicks(ms) CONFIG_SYS_CLOCK_TICKS_PER_SEC*ms/1000
systemticks_t gfxSystemTicks();
gTicks gfxSystemTicks();
#define gfxSystemLock() k_sched_lock()
#define gfxSystemUnlock() k_sched_unlock()

View File

@ -163,7 +163,7 @@ void _gqueueDeinit(void)
gfxSemDestroy(&pqueue->sem);
}
gfxQueueGSyncItem *gfxQueueGSyncGet(gfxQueueGSync *pqueue, delaytime_t ms) {
gfxQueueGSyncItem *gfxQueueGSyncGet(gfxQueueGSync *pqueue, gDelay ms) {
gfxQueueGSyncItem *pi;
if (!gfxSemWait(&pqueue->sem, ms))
@ -302,7 +302,7 @@ void _gqueueDeinit(void)
gfxSemDestroy(&pqueue->sem);
}
gfxQueueFSyncItem *gfxQueueFSyncGet(gfxQueueFSync *pqueue, delaytime_t ms) {
gfxQueueFSyncItem *gfxQueueFSyncGet(gfxQueueFSync *pqueue, gDelay ms) {
gfxQueueFSyncItem *pi;
if (!gfxSemWait(&pqueue->sem, ms))
@ -320,7 +320,7 @@ void _gqueueDeinit(void)
return pi;
}
gBool gfxQueueFSyncPut(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, delaytime_t ms) {
gBool gfxQueueFSyncPut(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, gDelay ms) {
if (!pitem) return; // Safety
gfxSemInit(&pitem->sem, 0, 1);
pitem->next = 0;
@ -339,7 +339,7 @@ void _gqueueDeinit(void)
return gfxSemWait(&pitem->sem, ms);
}
gBool gfxQueueFSyncPush(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, delaytime_t ms) {
gBool gfxQueueFSyncPush(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, gDelay ms) {
if (!pitem) return; // Safety
gfxSemInit(&pitem->sem, 0, 1);
@ -355,7 +355,7 @@ void _gqueueDeinit(void)
return gfxSemWait(&pitem->sem, ms);
}
gBool gfxQueueFSyncInsert(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, gfxQueueASyncItem *pafter, delaytime_t ms) {
gBool gfxQueueFSyncInsert(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, gfxQueueASyncItem *pafter, gDelay ms) {
if (!pitem) return; // Safety
gfxSemInit(&pitem->sem, 0, 1);
@ -454,7 +454,7 @@ void _gqueueDeinit(void)
void gfxBufferRelease(GDataBuffer *pd) { gfxQueueGSyncPut(&bufferFreeList, (gfxQueueGSyncItem *)pd); }
void gfxBufferReleaseI(GDataBuffer *pd) { gfxQueueGSyncPutI(&bufferFreeList, (gfxQueueGSyncItem *)pd); }
GDataBuffer *gfxBufferGet(delaytime_t ms) { return (GDataBuffer *)gfxQueueGSyncGet(&bufferFreeList, ms); }
GDataBuffer *gfxBufferGet(gDelay ms) { return (GDataBuffer *)gfxQueueGSyncGet(&bufferFreeList, ms); }
GDataBuffer *gfxBufferGetI(void) { return (GDataBuffer *)gfxQueueGSyncGetI(&bufferFreeList); }
gBool gfxBufferIsAvailable(void) { return bufferFreeList.head != 0; }

View File

@ -133,9 +133,9 @@ void gfxQueueFSyncDeinit(gfxQueueFSync *pqueue);
*/
gfxQueueASyncItem *gfxQueueASyncGet(gfxQueueASync *pqueue);
gfxQueueASyncItem *gfxQueueASyncGetI(gfxQueueASync *pqueue);
gfxQueueGSyncItem *gfxQueueGSyncGet(gfxQueueGSync *pqueue, delaytime_t ms);
gfxQueueGSyncItem *gfxQueueGSyncGet(gfxQueueGSync *pqueue, gDelay ms);
gfxQueueGSyncItem *gfxQueueGSyncGetI(gfxQueueGSync *pqueue);
gfxQueueFSyncItem *gfxQueueFSyncGet(gfxQueueFSync *pqueue, delaytime_t ms);
gfxQueueFSyncItem *gfxQueueFSyncGet(gfxQueueFSync *pqueue, gDelay ms);
/** @} */
/**
@ -159,7 +159,7 @@ void gfxQueueASyncPut(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem);
void gfxQueueASyncPutI(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem);
void gfxQueueGSyncPut(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem);
void gfxQueueGSyncPutI(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem);
gBool gfxQueueFSyncPut(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, delaytime_t ms);
gBool gfxQueueFSyncPut(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, gDelay ms);
/** @} */
/**
@ -197,7 +197,7 @@ void gfxQueueASyncPush(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem);
void gfxQueueASyncPushI(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem);
void gfxQueueGSyncPush(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem);
void gfxQueueGSyncPushI(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem);
gBool gfxQueueFSyncPush(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, delaytime_t ms);
gBool gfxQueueFSyncPush(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, gDelay ms);
/** @} */
/**
@ -223,7 +223,7 @@ void gfxQueueASyncInsert(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem, gfxQue
void gfxQueueASyncInsertI(gfxQueueASync *pqueue, gfxQueueASyncItem *pitem, gfxQueueASyncItem *pafter);
void gfxQueueGSyncInsert(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem, gfxQueueASyncItem *pafter);
void gfxQueueGSyncInsertI(gfxQueueGSync *pqueue, gfxQueueGSyncItem *pitem, gfxQueueASyncItem *pafter);
gBool gfxQueueFSyncInsert(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, gfxQueueASyncItem *pafter, delaytime_t ms);
gBool gfxQueueFSyncInsert(gfxQueueFSync *pqueue, gfxQueueFSyncItem *pitem, gfxQueueASyncItem *pafter, gDelay ms);
/** @} */
/**
@ -376,7 +376,7 @@ gBool gfxBufferIsAvailable(void);
* @api
* @{
*/
GDataBuffer *gfxBufferGet(delaytime_t ms);
GDataBuffer *gfxBufferGet(gDelay ms);
GDataBuffer *gfxBufferGetI(void);
/** @} */

View File

@ -22,7 +22,7 @@ static gfxMutex mutex;
static gfxThreadHandle hThread = 0;
static GTimer *pTimerHead = 0;
static gfxSem waitsem;
static systemticks_t ticks2ms;
static gTicks ticks2ms;
static DECLARE_THREAD_STACK(waTimerThread, GTIMER_THREAD_WORKAREA_SIZE);
/*===========================================================================*/
@ -31,9 +31,9 @@ static DECLARE_THREAD_STACK(waTimerThread, GTIMER_THREAD_WORKAREA_SIZE);
static DECLARE_THREAD_FUNCTION(GTimerThreadHandler, arg) {
GTimer *pt;
systemticks_t tm;
systemticks_t nxtTimeout;
systemticks_t lastTime;
gTicks tm;
gTicks nxtTimeout;
gTicks lastTime;
GTimerFunction fn;
void *param;
(void) arg;
@ -136,7 +136,7 @@ void gtimerDeinit(GTimer* pt)
gtimerStop(pt);
}
void gtimerStart(GTimer *pt, GTimerFunction fn, void *param, gBool periodic, delaytime_t millisec) {
void gtimerStart(GTimer *pt, GTimerFunction fn, void *param, gBool periodic, gDelay millisec) {
gfxMutexEnter(&mutex);
// Start our thread if not already going

View File

@ -52,8 +52,8 @@ typedef void (*GTimerFunction)(void *param);
typedef struct GTimer_t {
GTimerFunction fn;
void *param;
systemticks_t when;
systemticks_t period;
gTicks when;
gTicks period;
uint16_t flags;
struct GTimer_t *next;
struct GTimer_t *prev;
@ -110,7 +110,7 @@ void gtimerDeinit(GTimer* pt);
*
* @api
*/
void gtimerStart(GTimer *pt, GTimerFunction fn, void *param, gBool periodic, delaytime_t millisec);
void gtimerStart(GTimer *pt, GTimerFunction fn, void *param, gBool periodic, gDelay millisec);
/**
* @brief Stop a timer (periodic or otherwise)

View File

@ -37,7 +37,7 @@ static void ImageRedraw(GHandle gh) {
gCoord x, y, w, h, dx, dy;
gColor bg;
#if GWIN_NEED_IMAGE_ANIMATION
delaytime_t delay;
gDelay delay;
#endif
// The default display area

View File

@ -195,7 +195,7 @@ void gwinProgressbarDecrement(GHandle gh) {
#undef gsw
}
void gwinProgressbarStart(GHandle gh, delaytime_t delay) {
void gwinProgressbarStart(GHandle gh, gDelay delay) {
#define gsw ((GProgressbarObject *)gh)
if (gh->vmt != (gwinVMT *)&progressbarVMT)

View File

@ -159,7 +159,7 @@ void gwinProgressbarDecrement(GHandle gh);
*
* @api
*/
void gwinProgressbarStart(GHandle gh, delaytime_t delay);
void gwinProgressbarStart(GHandle gh, gDelay delay);
/**
* @brief Stop the timer which is started by @p gwinProgressbarStart()