Browse Source

Adding support for NIOS-II platform

Joel Bodenmann 4 years ago
parent
commit
eaf0b19fb8
9 changed files with 123 additions and 2 deletions
  1. 1 0
      docs/releases.txt
  2. 1 0
      gfxconf.example.h
  3. 2 0
      src/gos/gos.h
  4. 1 0
      src/gos/gos.mk
  5. 1 0
      src/gos/gos_mk.c
  6. 64 0
      src/gos/gos_nios.c
  7. 44 0
      src/gos/gos_nios.h
  8. 7 0
      src/gos/gos_options.h
  9. 2 2
      src/gos/gos_rules.h

+ 1 - 0
docs/releases.txt

@@ -26,6 +26,7 @@ FIX:		Fixing issue in touchscreen calibration code
26 26
 FEATURE:	Added GFX_OS_PRE_INIT_FUNCTION for early hardware initialization
27 27
 FIX:		Fixing GTIMER for high clock rate devices
28 28
 FEATURE:	Added GFX_COMPILER_KEIL and GFX_COMPILER_ARMCC macros
29
+FEATURE:	Added support for NIOS-II platform
29 30
 
30 31
 
31 32
 *** Release 2.3 ***

+ 1 - 0
gfxconf.example.h

@@ -38,6 +38,7 @@
38 38
 //#define GFX_USE_OS_KEIL                              FALSE
39 39
 //#define GFX_USE_OS_CMSIS                             FALSE
40 40
 //#define GFX_USE_OS_RAW32                             FALSE
41
+//#define GFX_USE_OS_NIOS                              FALSE
41 42
 //    #define INTERRUPTS_OFF()                         optional_code
42 43
 //    #define INTERRUPTS_ON()                          optional_code
43 44
 

+ 2 - 0
src/gos/gos.h

@@ -478,6 +478,8 @@
478 478
  	#include "gos_cmsis.h"
479 479
 #elif GFX_USE_OS_KEIL
480 480
  	#include "gos_keil.h"
481
+#elif GFX_USE_OS_NIOS
482
+ 	#include "gos_nios.h"
481 483
 #else
482 484
 	#error "Your operating system is not supported yet"
483 485
 #endif

+ 1 - 0
src/gos/gos.mk

@@ -13,6 +13,7 @@ GFXSRC +=   $(GFXLIB)/src/gos/gos_chibios.c	\
13 13
 			$(GFXLIB)/src/gos/gos_rawrtos.c \
14 14
 			$(GFXLIB)/src/gos/gos_arduino.c \
15 15
 			$(GFXLIB)/src/gos/gos_cmsis.c \
16
+			$(GFXLIB)/src/gos/gos_nios.c \
16 17
 			$(GFXLIB)/src/gos/gos_x_threads.c \
17 18
 			$(GFXLIB)/src/gos/gos_x_heap.c
18 19
 

+ 1 - 0
src/gos/gos_mk.c

@@ -15,5 +15,6 @@
15 15
 #include "gos_rawrtos.c"
16 16
 #include "gos_win32.c"
17 17
 #include "gos_cmsis.c"
18
+#include "gos_nios.c"
18 19
 #include "gos_x_threads.c"
19 20
 #include "gos_x_heap.c"

+ 64 - 0
src/gos/gos_nios.c

@@ -0,0 +1,64 @@
1
+/*
2
+ * This file is subject to the terms of the GFX License. If a copy of
3
+ * the license was not distributed with this file, you can obtain one at:
4
+ *
5
+ *              http://ugfx.org/license.html
6
+ */
7
+
8
+#include "../../gfx.h"
9
+
10
+#if GFX_USE_OS_NIOS
11
+
12
+void _gosHeapInit(void);
13
+void _gosThreadsInit(void);
14
+
15
+/*********************************************************
16
+ * Initialise
17
+ *********************************************************/
18
+
19
+void _gosInit(void)
20
+{
21
+	// Set up the heap allocator
22
+	_gosHeapInit();
23
+
24
+	// Start the scheduler
25
+	_gosThreadsInit();
26
+}
27
+
28
+void _gosDeinit(void)
29
+{
30
+}
31
+
32
+void gfxHalt(const char *msg)
33
+{
34
+	volatile uint32_t dummy;
35
+
36
+	(void)msg;
37
+
38
+	while(1) {
39
+		dummy++;
40
+	}
41
+}
42
+
43
+void gfxExit(void) {
44
+	volatile uint32_t dummy;
45
+
46
+	while(1) {
47
+		dummy++;
48
+	}
49
+}
50
+#include <stdio.h>
51
+systemticks_t gfxSystemTicks(void)
52
+{
53
+	volatile alt_u32 ticks = alt_nticks();
54
+
55
+	printf("Ticks: %d\r\n", ticks);
56
+	return ticks;
57
+}
58
+
59
+systemticks_t gfxMillisecondsToTicks(delaytime_t ms)
60
+{
61
+	return ms;
62
+}
63
+
64
+#endif /* GFX_USE_OS_NIOS */

+ 44 - 0
src/gos/gos_nios.h

@@ -0,0 +1,44 @@
1
+/*
2
+ * This file is subject to the terms of the GFX License. If a copy of
3
+ * the license was not distributed with this file, you can obtain one at:
4
+ *
5
+ *              http://ugfx.org/license.html
6
+ */
7
+
8
+#ifndef _GOS_NIOS_H
9
+#define _GOS_NIOS_H
10
+
11
+#if GFX_USE_OS_NIOS
12
+
13
+#include <stdint.h>
14
+#include <stddef.h>
15
+#include <stdbool.h>
16
+#include <sys/alt_alarm.h>
17
+
18
+typedef alt_u32 systemticks_t;
19
+typedef alt_u32 delaytime_t;
20
+typedef unsigned char bool_t;
21
+
22
+#ifdef __cplusplus
23
+extern "C" {
24
+#endif
25
+
26
+void gfxHalt(const char* msg);
27
+void gfxExit(void);
28
+systemticks_t gfxSystemTicks(void);
29
+systemticks_t gfxMillisecondsToTicks(delaytime_t ms);
30
+
31
+#ifdef __cplusplus
32
+}
33
+#endif
34
+
35
+
36
+// Use the generic thread handling and heap handling
37
+#define GOS_NEED_X_THREADS	TRUE
38
+#define GOS_NEED_X_HEAP		TRUE
39
+
40
+#include "gos_x_threads.h"
41
+#include "gos_x_heap.h"
42
+
43
+#endif /* GFX_USE_OS_NIOS */
44
+#endif /* _GOS_NIOS_H */

+ 7 - 0
src/gos/gos_options.h

@@ -97,6 +97,13 @@
97 97
 	#ifndef GFX_USE_OS_KEIL
98 98
 		#define GFX_USE_OS_KEIL			FALSE
99 99
 	#endif
100
+	/**
101
+	 * @brief   Use NIOS-II
102
+	 * @details	Defaults to FALSE
103
+	 */
104
+	#ifndef GFX_USE_OS_NIOS
105
+		#define GFX_USE_OS_NIOS			FALSE
106
+	#endif
100 107
 /**
101 108
  * @}
102 109
  *

+ 2 - 2
src/gos/gos_rules.h

@@ -16,7 +16,7 @@
16 16
 #ifndef _GOS_RULES_H
17 17
 #define _GOS_RULES_H
18 18
 
19
-#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
19
+#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
20 20
 	#if GFX_DISPLAY_RULE_WARNINGS
21 21
 		#warning "GOS: No Operating System has been defined. ChibiOS (GFX_USE_OS_CHIBIOS) has been turned on for you."
22 22
 	#endif
@@ -24,7 +24,7 @@
24 24
 	#define GFX_USE_OS_CHIBIOS	TRUE
25 25
 #endif
26 26
 
27
-#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
27
+#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
28 28
 	#error "GOS: More than one operation system has been defined as TRUE."
29 29
 #endif
30 30