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
◆ gdriverGetDriverInstanceNumber()
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.
◆ 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] | type | The type of driver to find |
[in] | instance | The instance (0..n) to find |
Definition at line 98 of file gdriver.c.
◆ gdriverGetNext()
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.
◆ 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] | type | The type of driver to find |
Definition at line 114 of file gdriver.c.
◆ gdriverRegister()
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().
◆ gdriverUnRegister()
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().
◆ 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
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
All driver VMT's start with this structure.