First attempt at Keil CMSIS support
parent
ddf79cd411
commit
92b0002918
|
@ -34,6 +34,8 @@
|
||||||
//#define GFX_USE_OS_OSX FALSE
|
//#define GFX_USE_OS_OSX FALSE
|
||||||
//#define GFX_USE_OS_ECOS FALSE
|
//#define GFX_USE_OS_ECOS FALSE
|
||||||
//#define GFX_USE_OS_RAWRTOS FALSE
|
//#define GFX_USE_OS_RAWRTOS FALSE
|
||||||
|
//#define GFX_USE_OS_ARDUINO FALSE
|
||||||
|
//#define GFX_USE_OS_KEIL FALSE
|
||||||
//#define GFX_USE_OS_RAW32 FALSE
|
//#define GFX_USE_OS_RAW32 FALSE
|
||||||
// #define INTERRUPTS_OFF() optional_code
|
// #define INTERRUPTS_OFF() optional_code
|
||||||
// #define INTERRUPTS_ON() optional_code
|
// #define INTERRUPTS_ON() optional_code
|
||||||
|
|
|
@ -464,6 +464,8 @@
|
||||||
#include "src/gos/gos_ecos.h"
|
#include "src/gos/gos_ecos.h"
|
||||||
#elif GFX_USE_OS_ARDUINO
|
#elif GFX_USE_OS_ARDUINO
|
||||||
#include "src/gos/gos_arduino.h"
|
#include "src/gos/gos_arduino.h"
|
||||||
|
#elif GFX_USE_OS_KEIL
|
||||||
|
#include "src/gos/gos_keil.h"
|
||||||
#else
|
#else
|
||||||
#error "Your operating system is not supported yet"
|
#error "Your operating system is not supported yet"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -12,6 +12,7 @@ GFXSRC += $(GFXLIB)/src/gos/gos_chibios.c \
|
||||||
$(GFXLIB)/src/gos/gos_ecos.c \
|
$(GFXLIB)/src/gos/gos_ecos.c \
|
||||||
$(GFXLIB)/src/gos/gos_rawrtos.c \
|
$(GFXLIB)/src/gos/gos_rawrtos.c \
|
||||||
$(GFXLIB)/src/gos/gos_arduino.c \
|
$(GFXLIB)/src/gos/gos_arduino.c \
|
||||||
|
$(GFXLIB)/src/gos/gos_keil.c \
|
||||||
$(GFXLIB)/src/gos/gos_x_threads.c \
|
$(GFXLIB)/src/gos/gos_x_threads.c \
|
||||||
$(GFXLIB)/src/gos/gos_x_heap.c
|
$(GFXLIB)/src/gos/gos_x_heap.c
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,80 @@
|
||||||
|
/*
|
||||||
|
* 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:
|
||||||
|
*
|
||||||
|
* http://ugfx.org/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gfx.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#if GFX_USE_OS_KEIL
|
||||||
|
|
||||||
|
void _gosInit(void)
|
||||||
|
{
|
||||||
|
#if !GFX_OS_NO_INIT
|
||||||
|
osKernelInitialize();
|
||||||
|
if (!osKernelRunning())
|
||||||
|
osKernelStart();
|
||||||
|
#elif !GFX_OS_INIT_NO_WARNING
|
||||||
|
#warning "GOS: Operating System initialization has been turned off. Make sure you call osKernelInitialize() and osKernelStart() before gfxInit() in your application!"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Set up the heap allocator
|
||||||
|
_gosHeapInit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void _gosDeinit(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void gfxMutexInit(gfxMutex* pmutex)
|
||||||
|
{
|
||||||
|
pmutex->id = osMutexCreate(pmutex->osMutex(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
void gfxSemInit(gfxSem* psem, semcount_t val, semcount_t limit)
|
||||||
|
{
|
||||||
|
psem->id = osSemaphoreCreate(psem->osSemaphore(id), limit);
|
||||||
|
while(val--)
|
||||||
|
osSemaphoreRelease(psem->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void gfxSemDestroy(gfxSem* psem)
|
||||||
|
{
|
||||||
|
osSemaphoreDelete(psem->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool_t gfxSemWait(gfxSem* psem, delaytime_t ms)
|
||||||
|
{
|
||||||
|
return osSemaphoreWait(psem->id, ms) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool_t gfxSemWaitI(gfxSem* psem)
|
||||||
|
{
|
||||||
|
return osSemaphoreWait(psem->id, 0) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void gfxSemSignal(gfxSem* psem)
|
||||||
|
{
|
||||||
|
osSemaphoreRelease(psem->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void gfxSemSignalI(gfxSem* psem)
|
||||||
|
{
|
||||||
|
osSemaphoreRelease(psem->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
gfxThreadHandle gfxThreadCreate(void* stackarea, size_t stacksz, threadpriority_t prio, DECLARE_THREAD_FUNCTION((*fn),p), void* param)
|
||||||
|
{
|
||||||
|
osThreadDef(ugfx_thread, prio, 1, stacksz);
|
||||||
|
|
||||||
|
return osThreadCreate(osThread(ugfx_thread), param);
|
||||||
|
}
|
||||||
|
|
||||||
|
threadreturn_t gfxThreadWait(gfxThreadHandle thread) {
|
||||||
|
while(osThreadGetPriority(thread) == osPriorityError)
|
||||||
|
gfxYield();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* GFX_USE_OS_KEIL */
|
|
@ -0,0 +1,99 @@
|
||||||
|
/*
|
||||||
|
* 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:
|
||||||
|
*
|
||||||
|
* http://ugfx.org/license.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @file src/gos/gos_keil.h
|
||||||
|
* @brief GOS - Operating System Support header file for Keil RTX.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _GOS_KEIL_H
|
||||||
|
#define _GOS_KEIL_H
|
||||||
|
|
||||||
|
#if GFX_USE_OS_KEIL
|
||||||
|
|
||||||
|
#ifndef GFX_OS_HEAP_SIZE
|
||||||
|
#define GFX_OS_HEAP_SIZE 10240
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Type definitions */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
#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;
|
||||||
|
|
||||||
|
#define MAX_SEMAPHORE_COUNT osFeature_Semaphore
|
||||||
|
#define LOW_PRIORITY osPriorityLow
|
||||||
|
#define NORMAL_PRIORITY osPriorityNormal
|
||||||
|
#define HIGH_PRIORITY osPriorityHigh
|
||||||
|
|
||||||
|
typedef struct gfxSem {
|
||||||
|
osSemaphoreId id;
|
||||||
|
osSemaphoreDef(id);
|
||||||
|
} gfxSem;
|
||||||
|
|
||||||
|
typedef struct gfxMutex {
|
||||||
|
osMutexId id;
|
||||||
|
osMutexDef(id);
|
||||||
|
} gfxMutex;
|
||||||
|
|
||||||
|
typedef osThreadId gfxThreadHandle;
|
||||||
|
|
||||||
|
#define DECLARE_THREAD_STACK(name, sz)
|
||||||
|
#define DECLARE_THREAD_FUNCTION(fnName, param) threadreturn_t fnName(void* params)
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Function declarations. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define gfxExit() os_error(0)
|
||||||
|
#define gfxHalt(msg) os_error(1)
|
||||||
|
#define gfxSystemTicks() osKernelSysTick()
|
||||||
|
#define gfxMillisecondsToTicks(ms) osKernelSysTickMicroSec(1000*(ms))
|
||||||
|
#define gfxSystemLock() osKernelInitialize()
|
||||||
|
#define gfxSystemUnlock() osKernelStart()
|
||||||
|
#define gfxSleepMilliseconds(ms) osDelay(ms)
|
||||||
|
|
||||||
|
void gfxMutexInit(gfxMutex* pmutex);
|
||||||
|
#define gfxMutexDestroy(pmutex) osMutexDelete((pmutex)->id)
|
||||||
|
#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 gfxSemDestroy(gfxSem* psem);
|
||||||
|
bool_t gfxSemWait(gfxSem* psem, delaytime_t ms);
|
||||||
|
bool_t 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);
|
||||||
|
#define gfxYield() osThreadYield()
|
||||||
|
#define gfxThreadMe() osThreadGetId()
|
||||||
|
#define gfxThreadClose(thread) {}
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Use the generic thread handling and heap handling */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
#define GOS_NEED_X_HEAP TRUE
|
||||||
|
#include "gos_x_heap.h"
|
||||||
|
|
||||||
|
#endif /* GFX_USE_OS_KEIL */
|
||||||
|
#endif /* _GOS_KEIL_H */
|
|
@ -14,5 +14,6 @@
|
||||||
#include "gos_raw32.c"
|
#include "gos_raw32.c"
|
||||||
#include "gos_rawrtos.c"
|
#include "gos_rawrtos.c"
|
||||||
#include "gos_win32.c"
|
#include "gos_win32.c"
|
||||||
|
#include "gos_keil.c"
|
||||||
#include "gos_x_threads.c"
|
#include "gos_x_threads.c"
|
||||||
#include "gos_x_heap.c"
|
#include "gos_x_heap.c"
|
||||||
|
|
|
@ -76,6 +76,13 @@
|
||||||
#ifndef GFX_USE_OS_ARDUINO
|
#ifndef GFX_USE_OS_ARDUINO
|
||||||
#define GFX_USE_OS_ARDUINO FALSE
|
#define GFX_USE_OS_ARDUINO FALSE
|
||||||
#endif
|
#endif
|
||||||
|
/**
|
||||||
|
* @brief Use Keil CMSIS
|
||||||
|
* @details Defaults to FALSE
|
||||||
|
*/
|
||||||
|
#ifndef GFX_USE_OS_KEIL
|
||||||
|
#define GFX_USE_OS_KEIL FALSE
|
||||||
|
#endif
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*
|
*
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#ifndef _GOS_RULES_H
|
#ifndef _GOS_RULES_H
|
||||||
#define _GOS_RULES_H
|
#define _GOS_RULES_H
|
||||||
|
|
||||||
#if !GFX_USE_OS_CHIBIOS && !GFX_USE_OS_WIN32 && !GFX_USE_OS_LINUX && !GFX_USE_OS_OSX && !GFX_USE_OS_RAW32 && !GFX_USE_OS_FREERTOS && !GFX_USE_OS_ECOS && !GFX_USE_OS_RAWRTOS && !GFX_USE_OS_ARDUINO
|
#if !GFX_USE_OS_CHIBIOS && !GFX_USE_OS_WIN32 && !GFX_USE_OS_LINUX && !GFX_USE_OS_OSX && !GFX_USE_OS_RAW32 && !GFX_USE_OS_FREERTOS && !GFX_USE_OS_ECOS && !GFX_USE_OS_RAWRTOS && !GFX_USE_OS_ARDUINO && !GFX_USE_OS_KEIL
|
||||||
#if GFX_DISPLAY_RULE_WARNINGS
|
#if GFX_DISPLAY_RULE_WARNINGS
|
||||||
#warning "GOS: No Operating System has been defined. ChibiOS (GFX_USE_OS_CHIBIOS) has been turned on for you."
|
#warning "GOS: No Operating System has been defined. ChibiOS (GFX_USE_OS_CHIBIOS) has been turned on for you."
|
||||||
#endif
|
#endif
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
#define GFX_USE_OS_CHIBIOS TRUE
|
#define GFX_USE_OS_CHIBIOS TRUE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if GFX_USE_OS_CHIBIOS + GFX_USE_OS_WIN32 + GFX_USE_OS_LINUX + GFX_USE_OS_OSX + GFX_USE_OS_RAW32 + GFX_USE_OS_FREERTOS + GFX_USE_OS_ECOS + GFX_USE_OS_RAWRTOS + GFX_USE_OS_ARDUINO != 1 * TRUE
|
#if GFX_USE_OS_CHIBIOS + GFX_USE_OS_WIN32 + GFX_USE_OS_LINUX + GFX_USE_OS_OSX + GFX_USE_OS_RAW32 + GFX_USE_OS_FREERTOS + GFX_USE_OS_ECOS + GFX_USE_OS_RAWRTOS + GFX_USE_OS_ARDUINO + GFX_USE_OS_KEIL != 1 * TRUE
|
||||||
#error "GOS: More than one operation system has been defined as TRUE."
|
#error "GOS: More than one operation system has been defined as TRUE."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue