zephyr:device_drivers
This is an old revision of the document!
Zephyr Device Drivers
Brief
A custom driver will probably involve:
| Driver C source code | The structure does not seem to be unified. Most drivers are stored in a flat structure under zephyr/drivers/<type>/<type>_<device>.c/h but some, at least sensors, are stored in a tree structure: zephyr/drivers/sensor/<mfr>/<device>/<device>.c/h or similar. It's seemingly random.. |
| KConfig source file | Placed together with the C source, declaring the CONFIG_* that CMakeLists.txt will listen for |
| CMakeLists.txt entry | Either a zephyr_library_sources_ifdef(CONFIG_MY_AWESOME_DRIVER my_awesome_driver.c) or a add_subdirectory_ifdef(CONFIG_MY_AWESOME_DRIVER my_awesome_driver) depending on file structure in the drivers folder |
| Device tree binding file | zephyr/dts/bindings/<feature>/<compatible>.yaml |
| Possibly som API header | zephyr/include/zephyr/drivers/<type>/<device>.h if not using any of Zephyrs generic API |
| Preferrably some sample code | Somehow sorted under zephyr/samples/ |
Using it will involve
| Device tree entry | in a device tree overlay file, the line compatible: my,awesome-driver will tell Zephyr what C driver to use and what device tree binding to use when validating the entry |
| KConfig config | An entry in you projects settings along the lines CONFIG_MY_AWESOME_DRIVER=y |
zephyr/device_drivers.1751469662.txt.gz · Last modified: 2025/07/02 15:21 by utedass
