Browse Source

added deinit() routines for all modules (not implemented so far)

remotes/origin_old/ugfx_release_2.6
Joel Bodenmann 8 years ago
parent
commit
a11f7da536
  1. 11
      include/gfx.h
  2. 8
      src/gadc/gadc.c
  3. 9
      src/gaudin/gaudin.c
  4. 10
      src/gaudout/gaudout.c
  5. 9
      src/gdisp/gdisp.c
  6. 8
      src/gevent/gevent.c
  7. 58
      src/gfx.c
  8. 20
      src/ginput/ginput.c
  9. 9
      src/gmisc/gmisc.c
  10. 9
      src/gos/chibios.c
  11. 8
      src/gos/linux.c
  12. 8
      src/gos/osx.c
  13. 8
      src/gos/raw32.c
  14. 8
      src/gos/win32.c
  15. 8
      src/gtimer/gtimer.c
  16. 8
      src/gwin/gwidget.c
  17. 17
      src/gwin/gwin.c
  18. 8
      src/gwin/gwm.c

11
include/gfx.h

@ -204,8 +204,15 @@ extern "C" {
*/
void gfxInit(void);
/* Compatibility for old programs */
void DEPRECATED("Use gfxInit() instead") gdispInit(void);
/**
* @brief The one call to end it all
*
* @note This will deinitialise each sub-system that has been turned on.
* @note Do not call this without a previous @p gfxInit();
*
* @api
*/
void gfxDeinit(void);
#ifdef __cplusplus
}

8
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,11 @@ void _gadcInit(void) {
#endif
}
void _gadcDeinit(void)
{
/* ToDo */
}
static inline void StartADC(bool_t onNoHS) {
gfxSystemLock();
if (!(gflags & GADC_GFLG_ISACTIVE) || (onNoHS && !curlsdev))

9
src/gaudin/gaudin.c

@ -85,13 +85,18 @@ 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)
{
/* ToDo */
}
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)

10
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 */
/** @} */

9
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;

8
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)
{
/* ToDo */
}
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

58
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();
}

20
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 */
/** @} */

9
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 */

9
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;

8
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);
}

8
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);
}

8
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.

8
src/gos/win32.c

@ -17,7 +17,13 @@
static HANDLE SystemMutex;
void _gosInit(void) {
void _gosInit(void)
{
}
void _gosDeinit(void)
{
}

8
src/gtimer/gtimer.c

@ -118,11 +118,17 @@ static DECLARE_THREAD_FUNCTION(GTimerThreadHandler, arg) {
return 0;
}
void _gtimerInit(void) {
void _gtimerInit(void)
{
gfxSemInit(&waitsem, 0, 1);
gfxMutexInit(&mutex);
}
void _gtimerDeinit(void)
{
/* ToDo */
}
void gtimerInit(GTimer *pt) {
pt->flags = 0;
}

8
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;

17
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) {

8
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;

Loading…
Cancel
Save