Adding Zephyr port

release/v2.9
Joel Bodenmann 2017-09-20 19:47:46 +02:00
parent 3e13911432
commit 2943011ccb
9 changed files with 154 additions and 3 deletions

View File

@ -50,6 +50,7 @@ FIX: Fixed resetting a timer on gwinImage objects when using animated GIFs
FEATURE: Added gwinTextEditSendKey() and gwinTextEditSendSpecialKey() FEATURE: Added gwinTextEditSendKey() and gwinTextEditSendSpecialKey()
FEATURE: Implemented the JPG image decoder FEATURE: Implemented the JPG image decoder
FEATURE: Added SSD1322 driver FEATURE: Added SSD1322 driver
FEATURE: Added support for Zephyr operating system
*** Release 2.7 *** *** Release 2.7 ***

View File

@ -40,6 +40,7 @@
//#define GFX_USE_OS_CMSIS FALSE //#define GFX_USE_OS_CMSIS FALSE
//#define GFX_USE_OS_CMSIS2 FALSE //#define GFX_USE_OS_CMSIS2 FALSE
//#define GFX_USE_OS_RAW32 FALSE //#define GFX_USE_OS_RAW32 FALSE
//#define GFX_USE_OS_ZEPHYR FALSE
//#define GFX_USE_OS_NIOS FALSE //#define GFX_USE_OS_NIOS FALSE
//#define GFX_USE_OS_QT FALSE //#define GFX_USE_OS_QT FALSE
// #define INTERRUPTS_OFF() optional_code // #define INTERRUPTS_OFF() optional_code

View File

@ -484,6 +484,8 @@
#include "gos_rtx5.h" #include "gos_rtx5.h"
#elif GFX_USE_OS_NIOS #elif GFX_USE_OS_NIOS
#include "gos_nios.h" #include "gos_nios.h"
#elif GFX_USE_OS_ZEPHYR
#include "gos_zephyr.h"
#elif GFX_USE_OS_QT #elif GFX_USE_OS_QT
#include "gos_qt.h" #include "gos_qt.h"
#else #else

View File

@ -14,6 +14,6 @@ GFXSRC += $(GFXLIB)/src/gos/gos_chibios.c \
$(GFXLIB)/src/gos/gos_arduino.c \ $(GFXLIB)/src/gos/gos_arduino.c \
$(GFXLIB)/src/gos/gos_cmsis.c \ $(GFXLIB)/src/gos/gos_cmsis.c \
$(GFXLIB)/src/gos/gos_nios.c \ $(GFXLIB)/src/gos/gos_nios.c \
$(GFXLIB)/src/gos/gos_zephyr.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

View File

@ -17,5 +17,6 @@
#include "gos_cmsis.c" #include "gos_cmsis.c"
#include "gos_cmsis2.c" #include "gos_cmsis2.c"
#include "gos_nios.c" #include "gos_nios.c"
#include "gos_zephyr.c"
#include "gos_x_threads.c" #include "gos_x_threads.c"
#include "gos_x_heap.c" #include "gos_x_heap.c"

View File

@ -118,6 +118,13 @@
#ifndef GFX_USE_OS_NIOS #ifndef GFX_USE_OS_NIOS
#define GFX_USE_OS_NIOS FALSE #define GFX_USE_OS_NIOS FALSE
#endif #endif
/**
* @brief Use Zephyr
* @details Defaults to FALSE
*/
#ifndef GFX_USE_OS_ZEPHYR
#define GFX_USE_OS_ZEPHYR FALSE
#endif
/** /**
* @brief Use Qt * @brief Use Qt
* @details Defaults to FALSE * @details Defaults to FALSE

View File

@ -16,11 +16,11 @@
#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 && !GFX_USE_OS_CMSIS && !GFX_USE_OS_CMSIS2 && !GFX_USE_OS_KEIL && !GFX_USE_OS_RTX5 && !GFX_USE_OS_NIOS && !GFX_USE_OS_QT #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_CMSIS && !GFX_USE_OS_CMSIS2 && !GFX_USE_OS_KEIL && !GFX_USE_OS_RTX5 && !GFX_USE_OS_NIOS && !GFX_USE_OS_ZEPHYR && !GFX_USE_OS_QT
#error "GOS: No operating system has been defined." #error "GOS: No operating system has been defined."
#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 + GFX_USE_OS_CMSIS + GFX_USE_OS_CMSIS2 + GFX_USE_OS_KEIL + GFX_USE_OS_RTX5 + GFX_USE_OS_NIOS + GFX_USE_OS_QT != 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_CMSIS + GFX_USE_OS_CMSIS2 + GFX_USE_OS_KEIL + GFX_USE_OS_RTX5 + GFX_USE_OS_NIOS + GFX_USE_OS_ZEPHYR + GFX_USE_OS_QT != 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
@ -28,6 +28,10 @@
#error "GOS: GFX_FREERTOS_USE_TRACE is only available for the FreeRTOS port." #error "GOS: GFX_FREERTOS_USE_TRACE is only available for the FreeRTOS port."
#endif #endif
#if GFX_USE_OS_ZEPHYR && !defined(CONFIG_HEAP_MEM_POOL_SIZE)
#error "GOS: CONFIG_HEAP_MEM_POOL_SIZE must be defined to use the Zephyr port."
#endif
#if GFX_EMULATE_MALLOC #if GFX_EMULATE_MALLOC
#if GFX_USE_OS_WIN32 || GFX_USE_OS_LINUX || GFX_USE_OS_OSX || GFX_USE_OS_ECOS || \ #if GFX_USE_OS_WIN32 || GFX_USE_OS_LINUX || GFX_USE_OS_OSX || GFX_USE_OS_ECOS || \
(GFX_OS_HEAP_SIZE == 0 && (GFX_USE_OS_RAW32 || GFX_USE_OS_ARDUINO || GFX_USE_OS_CMSIS || GFX_USE_OS_CMSIS2 || GFX_USE_OS_KEIL || GFX_USE_OS_RTX5)) (GFX_OS_HEAP_SIZE == 0 && (GFX_USE_OS_RAW32 || GFX_USE_OS_ARDUINO || GFX_USE_OS_CMSIS || GFX_USE_OS_CMSIS2 || GFX_USE_OS_KEIL || GFX_USE_OS_RTX5))

View File

@ -0,0 +1,18 @@
/*
* 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"
#if GFX_USE_OS_ZEPHYR
systemticks_t gfxSystemTicks(void)
{
s32_t ms = k_uptime_get_32();
return CONFIG_SYS_CLOCK_TICKS_PER_SEC*ms/1000;
}
#endif // GFX_USE_OS_ZEPHYR

View File

@ -0,0 +1,117 @@
/*
* 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_zepyhr.h
* @brief GOS - Operating System Support header file for Zephyr RTOS.
* Zephyr SDK 0.9.1
*/
#ifndef _GOS_ZEPHYR_H
#define _GOS_ZEPHYR_H
#if GFX_USE_OS_ZEPHYR
// #include <stdbool.h>
// #include <stdint.h>
#include <zephyr.h>
/*===========================================================================*/
/* Type definitions */
/*===========================================================================*/
typedef bool bool_t;
typedef s8_t int8_t;
typedef u8_t uint8_t;
typedef s16_t int16_t;
typedef u16_t uint16_t;
typedef s32_t int32_t;
typedef u32_t uint32_t;
// typedef unsigned long size_t;
typedef s32_t delaytime_t;
typedef u32_t systemticks_t;
typedef u32_t semcount_t;
typedef void threadreturn_t;
typedef int threadpriority_t;
#define DECLARE_THREAD_FUNCTION(fnName, param)\
threadreturn_t fnName(void* param, void* p2, void* p3)
#define DECLARE_THREAD_STACK(name, sz)\
K_THREAD_STACK_DEFINE(name, sz)
#define THREAD_RETURN(retval) return
// #define FALSE 0
// #define TRUE 1
#define TIME_IMMEDIATE K_NO_WAIT
#define TIME_INFINITE K_FOREVER
#define MAX_SEMAPHORE_COUNT ((semcount_t)(((unsigned long)((semcount_t)(-1))) >> 1))
#define LOW_PRIORITY CONFIG_NUM_PREEMPT_PRIORITIES-1
#define NORMAL_PRIORITY 1
#define HIGH_PRIORITY 0
typedef struct k_sem gfxSem;
typedef struct k_mutex gfxMutex;
typedef k_tid_t gfxThreadHandle;
/*===========================================================================*/
/* Function declarations. */
/*===========================================================================*/
#ifdef __cplusplus
extern "C" {
#endif
#define gfxHalt(msg) do{}while(0)
#define gfxExit() do{}while(0)
// Don't forget to set CONFIG_HEAP_MEM_POOL_SIZE
#define gfxAlloc(sz) k_malloc(sz)
#define gfxFree(ptr) k_free(ptr)
#define gfxRealloc(ptr, oldsz, newsz) do{}while(0)
#define gfxYield() k_yield()
#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();
#define gfxSystemLock() k_sched_lock()
#define gfxSystemUnlock() k_sched_unlock()
#define gfxMutexInit(pmutex) k_mutex_init(pmutex)
#define gfxMutexDestroy(pmutex) do{}while(0)
#define gfxMutexEnter(pmutex) k_mutex_lock(pmutex, K_FOREVER)
#define gfxMutexExit(pmutex) k_mutex_unlock(pmutex)
#define gfxSemInit(psem, val, limit) k_sem_init(psem, val, limit)
#define gfxSemDestroy(psem) do{}while(0)
#define gfxSemWait(psem, ms) (k_sem_take(psem, ms) == 0) ? TRUE : FALSE
#define gfxSemWaitI(psem) (k_sem_take(psem, K_NO_WAIT) == 0) ? TRUE : FALSE
#define gfxSemSignal(psem) k_sem_give(psem)
#define gfxSemSignalI(psem) k_sem_give(psem)
#define gfxSemCounter(psem) k_sem_count_get(psem)
#define gfxSemCounterI(psem) k_sem_count_get(psem)
#define gfxThreadCreate(stackarea, stacksz, prio, fn, param)\
k_thread_spawn(stackarea, stacksz, fn, param, NULL, NULL, prio, 0, K_NO_WAIT)
#define gfxThreadWait(thread) 0
#define gfxThreadMe() k_current_get()
#define gfxThreadClose(thread) k_thread_abort(thread)
#ifdef __cplusplus
}
#endif
#endif /* GFX_USE_OS_ZEPHYR */
#endif /* _GOS_H */
/** @} */