2015-01-21 07:26:24 +00:00
|
|
|
/*
|
|
|
|
* This file is subject to the terms of the GFX License. If a copy of
|
|
|
|
* the license was not distributed with this file, you can obtain one at:
|
|
|
|
*
|
2018-10-01 15:32:39 +00:00
|
|
|
* http://ugfx.io/license.html
|
2015-01-21 07:26:24 +00:00
|
|
|
*/
|
|
|
|
|
2015-11-21 09:27:08 +00:00
|
|
|
#include "../../gfx.h"
|
2014-07-29 01:01:08 +00:00
|
|
|
|
|
|
|
#if GFX_USE_OS_RAWRTOS
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include "raw_api.h"
|
|
|
|
#include "raw_config.h"
|
|
|
|
|
|
|
|
#if CONFIG_RAW_MUTEX != 1
|
|
|
|
#error "GOS: CONFIG_RAW_MUTEX must be defined in raw_config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if CONFIG_RAW_SEMAPHORE != 1
|
|
|
|
#error "GOS: CONFIG_RAW_SEMAPHORE must be defined in raw_config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
void _gosInit(void)
|
|
|
|
{
|
2015-08-16 15:21:01 +00:00
|
|
|
#if !GFX_OS_NO_INIT
|
2018-02-27 07:44:21 +00:00
|
|
|
#error "GOS: Operating System initialization for RawRTOS is not yet implemented in uGFX. Please set GFX_OS_NO_INIT to GFXON in your gfxconf.h"
|
2015-07-16 09:02:59 +00:00
|
|
|
#endif
|
|
|
|
#if !GFX_OS_INIT_NO_WARNING
|
2017-06-30 09:43:51 +00:00
|
|
|
#if GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_DIRECT
|
|
|
|
#warning "GOS: Operating System initialization has been turned off. Make sure you call raw_os_start() before gfxInit() in your application!"
|
|
|
|
#elif GFX_COMPILER_WARNING_TYPE == GFX_COMPILER_WARNING_MACRO
|
|
|
|
COMPILER_WARNING("GOS: Operating System initialization has been turned off. Make sure you call raw_os_start() before gfxInit() in your application!")
|
|
|
|
#endif
|
2014-07-29 02:00:47 +00:00
|
|
|
#endif
|
2014-07-29 01:01:08 +00:00
|
|
|
}
|
|
|
|
|
2017-03-04 05:02:55 +00:00
|
|
|
void _gosPostInit(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-07-29 01:01:08 +00:00
|
|
|
void _gosDeinit(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-07-08 04:30:31 +00:00
|
|
|
void gfxSleepMilliseconds(gDelay ms)
|
2014-07-29 01:01:08 +00:00
|
|
|
{
|
2018-07-08 04:30:31 +00:00
|
|
|
gTicks ticks = ms*RAW_TICKS_PER_SECOND/1000;
|
2014-07-29 01:01:08 +00:00
|
|
|
if(!ticks)ticks = 1;
|
|
|
|
raw_sleep(ticks);
|
|
|
|
}
|
|
|
|
|
2018-07-08 04:30:31 +00:00
|
|
|
void gfxSleepMicroseconds(gDelay us)
|
2014-07-29 01:01:08 +00:00
|
|
|
{
|
2018-07-08 04:30:31 +00:00
|
|
|
gTicks ticks = (us/1000)*RAW_TICKS_PER_SECOND/1000;
|
2014-07-29 01:01:08 +00:00
|
|
|
if(!ticks)ticks = 1;
|
|
|
|
raw_sleep(ticks);
|
|
|
|
}
|
|
|
|
|
2018-11-03 02:29:30 +00:00
|
|
|
gBool gfxSemWait(gSem* psem, gDelay ms)
|
2014-07-29 01:01:08 +00:00
|
|
|
{
|
2018-07-08 04:30:31 +00:00
|
|
|
gTicks ticks = ms*RAW_TICKS_PER_SECOND/1000;
|
2014-07-29 01:01:08 +00:00
|
|
|
if(!ticks)ticks=1;
|
|
|
|
if(raw_semaphore_get((psem), ticks)==RAW_SUCCESS)
|
2018-06-23 03:02:07 +00:00
|
|
|
return gTrue;
|
|
|
|
return gFalse;
|
2014-07-29 01:01:08 +00:00
|
|
|
}
|
|
|
|
|
2018-11-03 02:29:30 +00:00
|
|
|
gBool gfxSemWaitI(gSem* psem)
|
2014-07-29 01:01:08 +00:00
|
|
|
{
|
2018-07-08 05:15:15 +00:00
|
|
|
if(raw_semaphore_get((psem), RAW_NO_WAIT)==RAW_SUCCESS)
|
2018-06-23 03:02:07 +00:00
|
|
|
return gTrue;
|
|
|
|
return gFalse;
|
2014-07-29 01:01:08 +00:00
|
|
|
}
|
|
|
|
|
2018-11-03 02:29:30 +00:00
|
|
|
gThread gfxThreadCreate(void *stackarea, gMemSize stacksz, gThreadpriority prio, GFX_THREAD_FUNCTION((*fn),p), void *param)
|
2014-07-29 01:01:08 +00:00
|
|
|
{
|
|
|
|
RAW_U16 ret;
|
2018-07-08 05:40:27 +00:00
|
|
|
gThread taskobj;
|
2014-07-29 01:01:08 +00:00
|
|
|
|
|
|
|
taskobj = gfxAlloc(sizeof(RAW_TASK_OBJ));
|
|
|
|
ret = raw_task_create(taskobj, (RAW_U8 *)"uGFX_TASK", param,
|
|
|
|
prio, 0, stackarea,
|
|
|
|
stacksz/sizeof(PORT_STACK) , fn, 1);
|
|
|
|
|
|
|
|
if (ret != RAW_SUCCESS) {
|
|
|
|
for (;;);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (taskobj);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|