diff --git a/docs/releases.txt b/docs/releases.txt index e2221c2e..1aee190f 100644 --- a/docs/releases.txt +++ b/docs/releases.txt @@ -26,6 +26,7 @@ FIX: Fixing issue in touchscreen calibration code FEATURE: Added GFX_OS_PRE_INIT_FUNCTION for early hardware initialization FIX: Fixing GTIMER for high clock rate devices FEATURE: Added GFX_COMPILER_KEIL and GFX_COMPILER_ARMCC macros +FEATURE: Added support for NIOS-II platform *** Release 2.3 *** diff --git a/gfxconf.example.h b/gfxconf.example.h index 36b4cda4..046b77ed 100644 --- a/gfxconf.example.h +++ b/gfxconf.example.h @@ -38,6 +38,7 @@ //#define GFX_USE_OS_KEIL FALSE //#define GFX_USE_OS_CMSIS FALSE //#define GFX_USE_OS_RAW32 FALSE +//#define GFX_USE_OS_NIOS FALSE // #define INTERRUPTS_OFF() optional_code // #define INTERRUPTS_ON() optional_code diff --git a/src/gos/gos.h b/src/gos/gos.h index 445e4b3a..c3cdca50 100644 --- a/src/gos/gos.h +++ b/src/gos/gos.h @@ -478,6 +478,8 @@ #include "gos_cmsis.h" #elif GFX_USE_OS_KEIL #include "gos_keil.h" +#elif GFX_USE_OS_NIOS + #include "gos_nios.h" #else #error "Your operating system is not supported yet" #endif diff --git a/src/gos/gos.mk b/src/gos/gos.mk index 048e687f..80d832d9 100644 --- a/src/gos/gos.mk +++ b/src/gos/gos.mk @@ -13,6 +13,7 @@ GFXSRC += $(GFXLIB)/src/gos/gos_chibios.c \ $(GFXLIB)/src/gos/gos_rawrtos.c \ $(GFXLIB)/src/gos/gos_arduino.c \ $(GFXLIB)/src/gos/gos_cmsis.c \ + $(GFXLIB)/src/gos/gos_nios.c \ $(GFXLIB)/src/gos/gos_x_threads.c \ $(GFXLIB)/src/gos/gos_x_heap.c diff --git a/src/gos/gos_mk.c b/src/gos/gos_mk.c index 49d6efb9..c1c566f7 100644 --- a/src/gos/gos_mk.c +++ b/src/gos/gos_mk.c @@ -15,5 +15,6 @@ #include "gos_rawrtos.c" #include "gos_win32.c" #include "gos_cmsis.c" +#include "gos_nios.c" #include "gos_x_threads.c" #include "gos_x_heap.c" diff --git a/src/gos/gos_nios.c b/src/gos/gos_nios.c new file mode 100644 index 00000000..36e3b19b --- /dev/null +++ b/src/gos/gos_nios.c @@ -0,0 +1,64 @@ +/* + * 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_NIOS + +void _gosHeapInit(void); +void _gosThreadsInit(void); + +/********************************************************* + * Initialise + *********************************************************/ + +void _gosInit(void) +{ + // Set up the heap allocator + _gosHeapInit(); + + // Start the scheduler + _gosThreadsInit(); +} + +void _gosDeinit(void) +{ +} + +void gfxHalt(const char *msg) +{ + volatile uint32_t dummy; + + (void)msg; + + while(1) { + dummy++; + } +} + +void gfxExit(void) { + volatile uint32_t dummy; + + while(1) { + dummy++; + } +} +#include +systemticks_t gfxSystemTicks(void) +{ + volatile alt_u32 ticks = alt_nticks(); + + printf("Ticks: %d\r\n", ticks); + return ticks; +} + +systemticks_t gfxMillisecondsToTicks(delaytime_t ms) +{ + return ms; +} + +#endif /* GFX_USE_OS_NIOS */ diff --git a/src/gos/gos_nios.h b/src/gos/gos_nios.h new file mode 100644 index 00000000..4aadc45d --- /dev/null +++ b/src/gos/gos_nios.h @@ -0,0 +1,44 @@ +/* + * 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 + */ + +#ifndef _GOS_NIOS_H +#define _GOS_NIOS_H + +#if GFX_USE_OS_NIOS + +#include +#include +#include +#include + +typedef alt_u32 systemticks_t; +typedef alt_u32 delaytime_t; +typedef unsigned char bool_t; + +#ifdef __cplusplus +extern "C" { +#endif + +void gfxHalt(const char* msg); +void gfxExit(void); +systemticks_t gfxSystemTicks(void); +systemticks_t gfxMillisecondsToTicks(delaytime_t ms); + +#ifdef __cplusplus +} +#endif + + +// Use the generic thread handling and heap handling +#define GOS_NEED_X_THREADS TRUE +#define GOS_NEED_X_HEAP TRUE + +#include "gos_x_threads.h" +#include "gos_x_heap.h" + +#endif /* GFX_USE_OS_NIOS */ +#endif /* _GOS_NIOS_H */ diff --git a/src/gos/gos_options.h b/src/gos/gos_options.h index 8a724e12..4b33f5ac 100644 --- a/src/gos/gos_options.h +++ b/src/gos/gos_options.h @@ -97,6 +97,13 @@ #ifndef GFX_USE_OS_KEIL #define GFX_USE_OS_KEIL FALSE #endif + /** + * @brief Use NIOS-II + * @details Defaults to FALSE + */ + #ifndef GFX_USE_OS_NIOS + #define GFX_USE_OS_NIOS FALSE + #endif /** * @} * diff --git a/src/gos/gos_rules.h b/src/gos/gos_rules.h index 0f0f6596..b0184eb0 100644 --- a/src/gos/gos_rules.h +++ b/src/gos/gos_rules.h @@ -16,7 +16,7 @@ #ifndef _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_KEIL +#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_KEIL && !GFX_USE_OS_NIOS #if GFX_DISPLAY_RULE_WARNINGS #warning "GOS: No Operating System has been defined. ChibiOS (GFX_USE_OS_CHIBIOS) has been turned on for you." #endif @@ -24,7 +24,7 @@ #define GFX_USE_OS_CHIBIOS TRUE #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_KEIL != 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_KEIL + GFX_USE_OS_NIOS != 1 * TRUE #error "GOS: More than one operation system has been defined as TRUE." #endif