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
unsigned gdriverGetDriverInstanceNumber |
( |
GDriver * |
driver | ) |
|
Get the instance number for a device.
- Returns
- The instance number or (unsigned)-1 if it fails.
- Parameters
-
[in] | driver | The 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] | type | The type of driver to find |
[in] | instance | The instance (0..n) to find |
Definition at line 98 of file gdriver.c.
Get the next driver for a type of device.
- Returns
- The runtime driver structure or NULL if there are no more.
- Parameters
-
[in] | type | The type of driver to find |
[in] | driver | The 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] | type | The type of driver to find |
Definition at line 114 of file gdriver.c.
Register a new driver instance.
- Returns
- The runtime driver structure or NULL if it fails.
- Parameters
-
[in] | vmt | The driver's vmt |
[in] | param | An 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] | driver | The driver instance's runtime structure |
Definition at line 69 of file gdriver.c.
References gfxFree().
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.
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.