version 2.8
GDRIVER

Detailed Description

Module to support registering and unregistering of drivers.

GDRIVER provides a generalized way of defining and registering drivers.

Note
There are many different types of drivers and GDRIVER can handle any type of driver defined by the uGFX system.
GDRIVER supports multiple drivers for one type of device. eg a SSD1289 LCD driver simultaneously with a framebuffer driver.
GDRIVER supports multiple instances of a single driver. eg 2 SSD1289 LCD's.
If there is only a single device of a particular type it will automatically register that device (it only needs to be included in the build, no special configuration is required)
This module gdriver.h file is NOT included in the general gfx.h file. Instead it is included in each driver type's driver API.
Precondition
GFX_USE_GDRIVER must be set to TRUE in your gfxconf.h

Data Structures

struct  GDriver
 All runtime driver structures start with this structure. More...
 
struct  GDriverVMT
 All driver VMT's start with this structure. More...
 

Functions

GDrivergdriverRegister (const GDriverVMT *vmt, void *param)
 Register a new driver instance. More...
 
void gdriverUnRegister (GDriver *driver)
 UnRegister a driver instance. More...
 
GDrivergdriverGetInstance (uint16_t type, unsigned instance)
 Get the driver for a particular instance of a type of device. More...
 
unsigned gdriverInstanceCount (uint16_t type)
 Get the count of instances of a type of device. More...
 
unsigned gdriverGetDriverInstanceNumber (GDriver *driver)
 Get the instance number for a device. More...
 
GDrivergdriverGetNext (uint16_t type, GDriver *driver)
 Get the next driver for a type of device. More...
 

Typedefs

typedef struct GDriver GDriver
 All runtime driver structures start with this structure. More...
 
typedef struct GDriverVMT GDriverVMT
 All driver VMT's start with this structure. More...
 
typedef const struct GDriverVMT const GDriverVMTList[1]
 A definition that allows getting addresses of GDriverVMT structures to put into a list. More...
 

Function Documentation

unsigned gdriverGetDriverInstanceNumber ( GDriver driver)

Get the instance number for a device.

Returns
The instance number or (unsigned)-1 if it fails.
Parameters
[in]driverThe driver to find the instance number for

Definition at line 136 of file gdriver.c.

GDriver* gdriverGetInstance ( uint16_t  type,
unsigned  instance 
)

Get the driver for a particular instance of a type of device.

Returns
The runtime driver structure or NULL if it fails.
Parameters
[in]typeThe type of driver to find
[in]instanceThe instance (0..n) to find

Definition at line 98 of file gdriver.c.

GDriver* gdriverGetNext ( uint16_t  type,
GDriver driver 
)

Get the next driver for a type of device.

Returns
The runtime driver structure or NULL if there are no more.
Parameters
[in]typeThe type of driver to find
[in]driverThe last driver returned or NULL to start again

Definition at line 127 of file gdriver.c.

unsigned gdriverInstanceCount ( uint16_t  type)

Get the count of instances of a type of device.

Returns
The instance count.
Note
Valid instance numbers are then 0 .. count-1
Parameters
[in]typeThe type of driver to find

Definition at line 114 of file gdriver.c.

GDriver* gdriverRegister ( const GDriverVMT vmt,
void *  param 
)

Register a new driver instance.

Returns
The runtime driver structure or NULL if it fails.
Parameters
[in]vmtThe driver's vmt
[in]paramAn arbitrary paramater passed to the driver init routine.

Definition at line 31 of file gdriver.c.

References gfxAlloc(), and gfxFree().

void gdriverUnRegister ( GDriver driver)

UnRegister a driver instance.

Parameters
[in]driverThe driver instance's runtime structure

Definition at line 69 of file gdriver.c.

References gfxFree().

Typedef Documentation

typedef struct GDriver GDriver

All runtime driver structures start with this structure.

Note
This structure (and any additional structure memory) is allocated dynamically by the system for each driver instance.
typedef struct GDriverVMT GDriverVMT

All driver VMT's start with this structure.

typedef const struct GDriverVMT const GDriverVMTList[1]

A definition that allows getting addresses of GDriverVMT structures to put into a list.

Note
eg. const MyDriverVMTtype a[1] = {{...}}; const MyDriverVMTtype b[1] = {{...}}; ... #define DRIVER_LIST a, b extern GDriverVMTList DRIVER_LIST; // Now treated as single element arrays of GDriverVMT const GDriverVMT const * mylist = { DRIVER_LIST };

Definition at line 90 of file gdriver.h.