Fixing Mutex and Semaphores for CMSIS RTOS

ugfx_release_2.6
Joel Bodenmann 2015-10-25 22:10:00 +01:00
parent 96a912bbc0
commit ccd83187fa
2 changed files with 12 additions and 6 deletions

View File

@ -32,14 +32,20 @@ void _gosDeinit(void)
void gfxMutexInit(gfxMutex* pmutex) void gfxMutexInit(gfxMutex* pmutex)
{ {
pmutex->id = osMutexCreate(&(pmutex->def)); osMutexDef_t def;
def.mutex = pmutex->mutex;
pmutex->id = osMutexCreate(&def);
} }
void gfxSemInit(gfxSem* psem, semcount_t val, semcount_t limit) void gfxSemInit(gfxSem* psem, semcount_t val, semcount_t limit)
{ {
psem->id = osSemaphoreCreate(&(psem->def), limit); osSemaphoreDef_t def;
while(val--) def.semaphore = psem->semaphore;
osSemaphoreRelease(psem->id);
(void)limit;
psem->id = osSemaphoreCreate(&def, val);
} }
void gfxSemDestroy(gfxSem* psem) void gfxSemDestroy(gfxSem* psem)

View File

@ -42,12 +42,12 @@ typedef osPriority threadpriority_t;
#define HIGH_PRIORITY osPriorityHigh #define HIGH_PRIORITY osPriorityHigh
typedef struct gfxSem { typedef struct gfxSem {
osSemaphoreDef_t def; uint32_t semaphore[2];
osSemaphoreId id; osSemaphoreId id;
} gfxSem; } gfxSem;
typedef struct gfxMutex { typedef struct gfxMutex {
osMutexDef_t def; uint32_t mutex[4];
osMutexId id; osMutexId id;
} gfxMutex; } gfxMutex;