aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/gadc/gadc.c16
-rw-r--r--src/gaudin/gaudin.c12
-rw-r--r--src/gaudout/gaudout.c10
-rw-r--r--src/gdisp/gdisp.c9
-rw-r--r--src/gevent/gevent.c8
-rw-r--r--src/gfx.c58
-rw-r--r--src/ginput/ginput.c20
-rw-r--r--src/gmisc/gmisc.c9
-rw-r--r--src/gos/chibios.c9
-rw-r--r--src/gos/linux.c8
-rw-r--r--src/gos/osx.c8
-rw-r--r--src/gos/raw32.c8
-rw-r--r--src/gos/win32.c8
-rw-r--r--src/gtimer/gtimer.c17
-rw-r--r--src/gwin/gwidget.c8
-rw-r--r--src/gwin/gwin.c19
-rw-r--r--src/gwin/gwm.c8
17 files changed, 202 insertions, 33 deletions
diff --git a/src/gadc/gadc.c b/src/gadc/gadc.c
index e297ef7e..c9a4a31b 100644
--- a/src/gadc/gadc.c
+++ b/src/gadc/gadc.c
@@ -236,7 +236,8 @@ void GADC_ISR_ErrorI(ADCDriver *adcp, adcerror_t err) {
}
/* Our module initialiser */
-void _gadcInit(void) {
+void _gadcInit(void)
+{
gadc_lld_init();
gfxSemInit(&gadcsem, GADC_MAX_LOWSPEED_DEVICES, GADC_MAX_LOWSPEED_DEVICES);
gfxMutexInit(&gadcmutex);
@@ -246,6 +247,19 @@ void _gadcInit(void) {
#endif
}
+void _gadcDeinit(void)
+{
+ /* commented stuff is ToDo */
+
+ // gadc_lld_deinit();
+ gfxSemDestroy(&gadcsem);
+ gfxMutexDestroy(&gadcmutex);
+ gtimerDeinit(&LowSpeedGTimer);
+ #if GFX_USE_GEVENT
+ gtimerDeinit(&HighSpeedGTimer);
+ #endif
+}
+
static inline void StartADC(bool_t onNoHS) {
gfxSystemLock();
if (!(gflags & GADC_GFLG_ISACTIVE) || (onNoHS && !curlsdev))
diff --git a/src/gaudin/gaudin.c b/src/gaudin/gaudin.c
index a6e173ce..8a425a10 100644
--- a/src/gaudin/gaudin.c
+++ b/src/gaudin/gaudin.c
@@ -85,13 +85,21 @@ void GAUDIN_ISR_ErrorI(void) {
/* Ignore any errors for now */
}
-/* The module initialiser */
-void _gaudinInit(void) {
+void _gaudinInit(void)
+{
#if GFX_USE_GEVENT
gtimerInit(&AudGTimer);
#endif
}
+void _gaudinDeinit(void)
+{
+ // Commented stuff still ToDo
+ #if GFX_USE_GEVENT
+ gtimerDeinit(&AudGTimer);
+ #endif
+}
+
bool_t gaudinInit(uint16_t channel, uint32_t frequency, audin_sample_t *buffer, size_t bufcount, size_t samplesPerEvent) {
/* Check the channel is valid */
if (channel >= GAUDIN_NUM_CHANNELS || frequency > GAUDIN_MAX_SAMPLE_FREQUENCY)
diff --git a/src/gaudout/gaudout.c b/src/gaudout/gaudout.c
index e05fc360..56692453 100644
--- a/src/gaudout/gaudout.c
+++ b/src/gaudout/gaudout.c
@@ -18,6 +18,16 @@
#error "GAUDOUT: Not implemented yet"
+void _gaudoutInit(void)
+{
+ /* ToDo */
+}
+
+void _gaudoutDeinit(void)
+{
+ /* ToDo */
+}
+
#endif /* GFX_USE_GAUDOUT */
/** @} */
diff --git a/src/gdisp/gdisp.c b/src/gdisp/gdisp.c
index 13f2eda2..3031c455 100644
--- a/src/gdisp/gdisp.c
+++ b/src/gdisp/gdisp.c
@@ -566,8 +566,8 @@ static void line_clip(GDisplay *g) {
/* Driver exported functions. */
/*===========================================================================*/
-/* Our module initialiser */
-void _gdispInit(void) {
+void _gdispInit(void)
+{
GDisplay *g;
uint16_t i;
@@ -627,6 +627,11 @@ void _gdispInit(void) {
#endif
}
+void _gdispDeinit(void)
+{
+ /* ToDo */
+}
+
GDisplay *gdispGetDisplay(unsigned display) {
if (display >= GDISP_TOTAL_DISPLAYS)
return 0;
diff --git a/src/gevent/gevent.c b/src/gevent/gevent.c
index 6681fb53..779f63a0 100644
--- a/src/gevent/gevent.c
+++ b/src/gevent/gevent.c
@@ -46,10 +46,16 @@ static void deleteAssignments(GListener *pl, GSourceHandle gsh) {
}
}
-void _geventInit(void) {
+void _geventInit(void)
+{
gfxMutexInit(&geventMutex);
}
+void _geventDeinit(void)
+{
+ gfxMutexDestroy(&geventMutex);
+}
+
void geventListenerInit(GListener *pl) {
gfxSemInit(&pl->waitqueue, 0, MAX_SEMAPHORE_COUNT); // Next wait'er will block
gfxSemInit(&pl->eventlock, 1, 1); // Only one thread at a time looking at the event buffer
diff --git a/src/gfx.c b/src/gfx.c
index ff7b29cd..46003f09 100644
--- a/src/gfx.c
+++ b/src/gfx.c
@@ -15,47 +15,50 @@
#include "gfx.h"
-void DEPRECATED("Use gfxInit() instead") gdispInit() { gfxInit(); }
-
/* These init functions are defined by each module but not published */
extern void _gosInit(void);
+extern void _gosDeinit(void);
#if GFX_USE_GDISP
extern void _gdispInit(void);
+ extern void _gdispDeinit(void);
#endif
#if GFX_USE_GWIN
extern void _gwinInit(void);
+ extern void _gwinDeinit(void);
#endif
#if GFX_USE_GEVENT
extern void _geventInit(void);
+ extern void _geventDeinit(void);
#endif
#if GFX_USE_GTIMER
extern void _gtimerInit(void);
+ extern void _gtimerDeinit(void);
#endif
#if GFX_USE_GINPUT
extern void _ginputInit(void);
+ extern void _ginputDeinit(void);
#endif
#if GFX_USE_GADC
extern void _gadcInit(void);
+ extern void _gadcDeinit(void);
#endif
#if GFX_USE_GAUDIN
extern void _gaudinInit(void);
+ extern void _gaudinDeinit(void);
#endif
#if GFX_USE_GAUDOUT
extern void _gaudoutInit(void);
+ extern void _gaudoutDeinit(void);
#endif
#if GFX_USE_GMISC
extern void _gmiscInit(void);
+ extern void _gmiscDeinit(void);
#endif
-void gfxInit(void) {
- static bool_t initDone = FALSE;
-
- /* Ensure we only initialise once */
- if (initDone)
- return;
- initDone = TRUE;
+void gfxInit(void)
+{
+ // These must be initialised in the order of their dependancies
- /* These must be initialised in the order of their dependancies */
_gosInit();
#if GFX_USE_GMISC
_gmiscInit();
@@ -85,3 +88,38 @@ void gfxInit(void) {
_gaudoutInit();
#endif
}
+
+void gfxDeinit(void)
+{
+ // We deinitialise the opposit way as we initialised
+
+ #if GFX_USE_GAUDOUT
+ _gaudoutDeinit();
+ #endif
+ #if GFX_USE_GAUDIN
+ _gaoudinDeinit();
+ #endif
+ #if GFX_USE_GADC
+ _gadcDeinit();
+ #endif
+ #if GFX_USE_GINPUT
+ _ginputDeinit();
+ #endif
+ #if GFX_USE_GWIN
+ _gwinDeinit();
+ #endif
+ #if GFX_USE_GDISP
+ _gdispDeinit();
+ #endif
+ #if GFX_USE_GTIMER
+ _gtimerDeinit();
+ #endif
+ #if GFX_USE_GEVENT
+ _geventDeinit();
+ #endif
+ #if GFX_USE_GMISC
+ _gmiscInit();
+ #endif
+ _gosDeinit();
+}
+
diff --git a/src/ginput/ginput.c b/src/ginput/ginput.c
index 87c4a668..abd16cd8 100644
--- a/src/ginput/ginput.c
+++ b/src/ginput/ginput.c
@@ -16,11 +16,21 @@
#if GFX_USE_GINPUT
-/**
- * This should really call an init routine for each ginput sub-system.
- * Maybe we'll do this later.
- */
-void _ginputInit(void) {}
+void _ginputInit(void)
+{
+ /* ToDo */
+
+ /**
+ * This should really call an init routine for each ginput sub-system.
+ * Maybe we'll do this later.
+ */
+}
+
+void _ginputDeinit(void)
+{
+
+}
#endif /* GFX_USE_GINPUT */
/** @} */
+
diff --git a/src/gmisc/gmisc.c b/src/gmisc/gmisc.c
index 38da6bfa..654dd5e2 100644
--- a/src/gmisc/gmisc.c
+++ b/src/gmisc/gmisc.c
@@ -14,7 +14,14 @@
#if GFX_USE_GMISC
-void _gmiscInit(void) {
+void _gmiscInit(void)
+{
+
+}
+
+void _gmiscDeinit(void)
+{
+
}
#endif /* GFX_USE_GMISC */
diff --git a/src/gos/chibios.c b/src/gos/chibios.c
index 30a2b228..cf02b3e2 100644
--- a/src/gos/chibios.c
+++ b/src/gos/chibios.c
@@ -22,8 +22,8 @@
#error "GOS: CH_USE_SEMAPHORES must be defined in chconf.h"
#endif
-/* Our module initialiser */
-void _gosInit(void) {
+void _gosInit(void)
+{
/* Don't initialise if the user already has */
if (!chThdSelf()) {
halInit();
@@ -31,6 +31,11 @@ void _gosInit(void) {
}
}
+void _gosDeinit(void)
+{
+ /* ToDo */
+}
+
void *gfxRealloc(void *ptr, size_t oldsz, size_t newsz) {
void *np;
diff --git a/src/gos/linux.c b/src/gos/linux.c
index 97409364..9b4914d5 100644
--- a/src/gos/linux.c
+++ b/src/gos/linux.c
@@ -20,10 +20,16 @@
static gfxMutex SystemMutex;
-void _gosInit(void) {
+void _gosInit(void)
+{
gfxMutexInit(&SystemMutex);
}
+void _gosDeinit(void)
+{
+ /* ToDo */
+}
+
void gfxSystemLock(void) {
gfxMutexEnter(&SystemMutex);
}
diff --git a/src/gos/osx.c b/src/gos/osx.c
index a5560b4e..249147d1 100644
--- a/src/gos/osx.c
+++ b/src/gos/osx.c
@@ -37,10 +37,16 @@ void get_ticks(mach_timespec_t *mts){
}
-void _gosInit(void) {
+void _gosInit(void)
+{
gfxMutexInit(&SystemMutex);
}
+void _gosDeinit(void)
+{
+ /* ToDo */
+}
+
void gfxSystemLock(void) {
gfxMutexEnter(&SystemMutex);
}
diff --git a/src/gos/raw32.c b/src/gos/raw32.c
index 5e11064c..61d09761 100644
--- a/src/gos/raw32.c
+++ b/src/gos/raw32.c
@@ -26,7 +26,8 @@ static void _gosThreadsInit(void);
* Initialise
*********************************************************/
-void _gosInit(void) {
+void _gosInit(void)
+{
// Set up the heap allocator
_gosHeapInit();
@@ -34,6 +35,11 @@ void _gosInit(void) {
_gosThreadsInit();
}
+void _gosDeinit(void)
+{
+ /* ToDo */
+}
+
/*********************************************************
* For WIn32 emulation - automatically add the tick functions
* the user would normally have to provide for bare metal.
diff --git a/src/gos/win32.c b/src/gos/win32.c
index a05e5c30..3a3f2517 100644
--- a/src/gos/win32.c
+++ b/src/gos/win32.c
@@ -17,7 +17,13 @@
static HANDLE SystemMutex;
-void _gosInit(void) {
+void _gosInit(void)
+{
+
+}
+
+void _gosDeinit(void)
+{
}
diff --git a/src/gtimer/gtimer.c b/src/gtimer/gtimer.c
index de40e16c..3f772e39 100644
--- a/src/gtimer/gtimer.c
+++ b/src/gtimer/gtimer.c
@@ -118,15 +118,28 @@ static DECLARE_THREAD_FUNCTION(GTimerThreadHandler, arg) {
return 0;
}
-void _gtimerInit(void) {
+void _gtimerInit(void)
+{
gfxSemInit(&waitsem, 0, 1);
gfxMutexInit(&mutex);
}
-void gtimerInit(GTimer *pt) {
+void _gtimerDeinit(void)
+{
+ gfxSemDestroy(&waitsem);
+ gfxMutexDestroy(&mutex);
+}
+
+void gtimerInit(GTimer* pt)
+{
pt->flags = 0;
}
+void gtimerDeinit(GTimer* pt)
+{
+ (void)pt;
+}
+
void gtimerStart(GTimer *pt, GTimerFunction fn, void *param, bool_t periodic, delaytime_t millisec) {
gfxMutexEnter(&mutex);
diff --git a/src/gwin/gwidget.c b/src/gwin/gwidget.c
index 484b8c37..75a69667 100644
--- a/src/gwin/gwidget.c
+++ b/src/gwin/gwidget.c
@@ -224,11 +224,17 @@ static void gwidgetEvent(void *param, GEvent *pe) {
}
#endif
-void _gwidgetInit(void) {
+void _gwidgetInit(void)
+{
geventListenerInit(&gl);
geventRegisterCallback(&gl, gwidgetEvent, 0);
}
+void _gwidgetDeinit(void)
+{
+ /* ToDo */
+}
+
GHandle _gwidgetCreate(GDisplay *g, GWidgetObject *pgw, const GWidgetInit *pInit, const gwidgetVMT *vmt) {
if (!(pgw = (GWidgetObject *)_gwindowCreate(g, &pgw->g, &pInit->g, &vmt->g, GWIN_FLG_WIDGET|GWIN_FLG_ENABLED)))
return 0;
diff --git a/src/gwin/gwin.c b/src/gwin/gwin.c
index 11dcdaf1..485ccaaa 100644
--- a/src/gwin/gwin.c
+++ b/src/gwin/gwin.c
@@ -84,7 +84,8 @@ static color_t defaultBgColor = Black;
* Class Routines
*-----------------------------------------------*/
-void _gwinInit(void) {
+void _gwinInit(void)
+{
#if GWIN_NEED_WIDGET
extern void _gwidgetInit(void);
@@ -97,6 +98,20 @@ void _gwinInit(void) {
#endif
}
+void _gwinDeinit(void)
+{
+ #if GWIN_NEED_WIDGET
+ extern void _gwidgetDeinit(void);
+
+ _gwidgetDeinit();
+ #endif
+ #if GWIN_NEED_WINDOWMANAGER
+ extern void _gwmDeinit(void);
+
+ _gwmDeinit();
+ #endif
+}
+
// Internal routine for use by GWIN components only
// Initialise a window creating it dynamically if required.
GHandle _gwindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pInit, const gwinVMT *vmt, uint16_t flags) {
@@ -167,7 +182,9 @@ color_t gwinGetDefaultBgColor(void) {
GHandle gwinGWindowCreate(GDisplay *g, GWindowObject *pgw, const GWindowInit *pInit) {
if (!(pgw = _gwindowCreate(g, pgw, pInit, &basegwinVMT, 0)))
return 0;
+
gwinSetVisible(pgw, pInit->show);
+
return pgw;
}
diff --git a/src/gwin/gwm.c b/src/gwin/gwm.c
index f4dd8090..e7a71737 100644
--- a/src/gwin/gwm.c
+++ b/src/gwin/gwm.c
@@ -60,7 +60,8 @@ GWindowManager * _GWINwm;
* Window Routines
*-----------------------------------------------*/
-void _gwmInit(void) {
+void _gwmInit(void)
+{
gfxQueueASyncInit(&_GWINList);
_GWINwm = (GWindowManager *)&GNullWindowManager;
_GWINwm->vmt->Init();
@@ -70,6 +71,11 @@ void _gwmInit(void) {
#endif
}
+void _gwmDeinit(void)
+{
+ /* ToDo */
+}
+
void gwinSetWindowManager(struct GWindowManager *gwm) {
if (!gwm)
gwm = (GWindowManager *)&GNullWindowManager;