zephyr/doc/drivers/drivers.rst
Daniel Leung ce2e4ebdf1 device: add macro to assign driver_api at compile time
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>
2016-04-15 22:06:09 +00:00

44 lines
1.3 KiB
ReStructuredText
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

.. _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.