diff options
author | inmarket <andrewh@inmarket.com.au> | 2014-09-25 17:43:43 +1000 |
---|---|---|
committer | inmarket <andrewh@inmarket.com.au> | 2014-09-25 17:43:43 +1000 |
commit | 33200c1a9787254532394e6877ec403ed4b89db8 (patch) | |
tree | 7ad6eaeb85bba47bf99ebbbb048d94b2df43fa81 /src/gdriver/gdriver_gdriver.c | |
parent | 6b9ff5de2a2ddf1056e00b7590f936779c56b517 (diff) | |
download | uGFX-33200c1a9787254532394e6877ec403ed4b89db8.tar.gz uGFX-33200c1a9787254532394e6877ec403ed4b89db8.tar.bz2 uGFX-33200c1a9787254532394e6877ec403ed4b89db8.zip |
Additional GDriver call
Diffstat (limited to 'src/gdriver/gdriver_gdriver.c')
-rw-r--r-- | src/gdriver/gdriver_gdriver.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/gdriver/gdriver_gdriver.c b/src/gdriver/gdriver_gdriver.c index 0a53aaf7..3c17fca0 100644 --- a/src/gdriver/gdriver_gdriver.c +++ b/src/gdriver/gdriver_gdriver.c @@ -11,19 +11,13 @@ #include "sys_defs.h" +#include <string.h> // For memset + // Define the tables to hold the driver instances. static GDriver *dhead; // The system initialization. void _gdriverInit(void) { - - // Drivers not loaded yet - // GINPUT_NEED_MOUSE - // GINPUT_NEED_DIAL - // GINPUT_NEED_TOGGLE - // GINPUT_NEED_KEYBOARD - // GINPUT_NEED_STRING - // GFX_USE_GBLOCK } // The system de-initialization. @@ -51,7 +45,7 @@ GDriver *gdriverRegister(const GDriverVMT *vmt) { pd = gfxAlloc(vmt->objsize); if (!pd) return 0; - pd->driverchain = 0; + memset(pd, 0, vmt->objsize); pd->vmt = vmt; if (vmt->init && !vmt->init(pd, dinstance, sinstance)) { gfxFree(pd); @@ -136,4 +130,19 @@ GDriver *gdriverGetNext(uint16_t type, GDriver *driver) { return driver; } +unsigned gdriverGetDriverInstanceNumber(GDriver *driver) { + GDriver *pd; + unsigned instance; + + // Loop to find the system instance + instance = 0; + for(pd = dhead; pd; pd = pd->driverchain) { + if (pd == driver) + return instance; + if (pd->vmt->type == driver->vmt->type) + instance++; + } + return (unsigned)-1; +} + #endif /* GFX_USE_GDRIVER */ |