mirror of
https://github.com/zephyrproject-rtos/zephyr
synced 2025-09-08 22:32:40 +00:00
This adds the DEVICE_AND_API_INIT() macro to take in a parameter to assign to device->driver_api. This eliminates the need to assign to driver_api during runtime device initialization. This provides an alternative way to declare devices. This should save a few bytes in ROM for those devices that will never fail initialization (in other words, never need to manipulate driver_api pointer at all). Also clean up the documentation a bit to remove duplicated block of information. Change-Id: I6abed1abe75db2e8babfcf1ecf590491132a5543 Signed-off-by: Daniel Leung <daniel.leung@intel.com>
44 lines
1.3 KiB
ReStructuredText
44 lines
1.3 KiB
ReStructuredText
.. _device_drivers:
|
||
|
||
Device Drivers and Device Model
|
||
###############################
|
||
|
||
Introduction
|
||
************
|
||
The Zephyr device model provides a consistent device model for configuring the
|
||
drivers that are part of the platform/system. The device model is responsible
|
||
for initializing all the drivers configured into the system.
|
||
|
||
Each type of driver (UART, SPI, I2C) is supported by a generic type API.
|
||
|
||
In this model the driver fills in the pointer to the structure containing the
|
||
function pointers to its API functions during driver initialization. These
|
||
structures are placed into the RAM section in initialization level order.
|
||
|
||
|
||
.. include:: synchronous_call.rst
|
||
|
||
Driver APIs
|
||
***********
|
||
|
||
The following APIs for device drivers are provided by :file:`device.h`. The APIs
|
||
are intended for use in device drivers only and should not be used in
|
||
applications.
|
||
|
||
:c:func:`DEVICE_INIT()`
|
||
create device object and set it up for boot time initialization.
|
||
|
||
:c:func:`DEVICE_AND_API_INIT()`
|
||
Create device object and set it up for boot time initialization.
|
||
This also takes a pointer to driver API struct for link time
|
||
pointer assignment.
|
||
|
||
:c:func:`DEVICE_NAME_GET()`
|
||
Expands to the full name of a global device object.
|
||
|
||
:c:func:`DEVICE_GET()`
|
||
Obtain a pointer to a device object by name.
|
||
|
||
:c:func:`DEVICE_DECLARE()`
|
||
Declare a device object.
|