µGFX  2.9
version 2.9
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 GFXON 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 (gU16 type, unsigned instance)
 Get the driver for a particular instance of a type of device. More...
 
unsigned gdriverInstanceCount (gU16 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 (gU16 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 ConstGDriverVMT
 A definition that allows getting addresses of GDriverVMT structures to put into a list. More...
 

Function Documentation

◆ gdriverGetDriverInstanceNumber()

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.

◆ gdriverGetInstance()

GDriver* gdriverGetInstance ( gU16  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.

◆ gdriverGetNext()

GDriver* gdriverGetNext ( gU16  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.

◆ gdriverInstanceCount()

unsigned gdriverInstanceCount ( gU16  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.

◆ gdriverRegister()

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().

◆ gdriverUnRegister()

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

◆ ConstGDriverVMT

typedef const struct GDriverVMT ConstGDriverVMT

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 };
This could be one single typedef. However, some major compilers complain about duplicate const specifiers even though this is perfectly valid standard C. As this problem has become worse over time we opt for splitting this into two separate typedefs to prevent these compilers from throwing warnings. The single typedef would look like this: typedef const struct GDriverVMT const GDriverVMTList[1];

Definition at line 1 of file gdriver.h.

◆ GDriver

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.

◆ GDriverVMT

typedef struct GDriverVMT GDriverVMT

All driver VMT's start with this structure.