Device-driver toolkit
A toolkit to write better device drivers, faster.
This book aims to guide you to write your own device drivers using the device-driver toolkit. For runtime docs, visit docs.rs.
Device-driver uses a small custom language named DDSL (device driver specification language) as its input. It’s made so creating drivers is direct, easy and to-the-point.
Example of a DDSL register:
register SYNT {
address: 0x05,
reset: 0x42162762,
fields: fieldset _ {
size-bytes: 4,
byte-order: BE,
/// Set the charge pump current according to the XTAL frequency
/// (see Table 37. Table 34).
field PLL_CP_ISEL 31:29 -> uint,
/// Synthesizer band select. This parameter selects the out-of loop
/// divide factor of the synthesizer:
/// - false: 4, band select factor for high band
/// - true: 8, band select factor for middle band
/// (see Section 5.3.1 RF channel frequency settings).
field BS 28 -> bool,
/// The PLL programmable divider
/// (see Section 5.3.1 RF channel frequent settings).
field SYNT 27:0 -> uint
}
}
Note
The name
device-driverconsists of two parts:
driver: Code to enable the use of hardware.device: A chip or peripheral you can talk to over a bus.Examples of good targets for using this toolkit:
- An I2C accelerometer
- A SPI radio transceiver
- A screen/display with parallel bus
The driver is usable in any no-std context and can be made to work with the
embedded-halcrate or any custom interfaces.
Book overview:
The book contains documentation for multiple versions. Go to the version you’re using and continue to read there. If you’re new, then the most recent version is recommended.
The book has sections on usage, tutorials and language specs.
The addendums contain useful background information.
Caution
It’s hard to keep a book like this up-to-date with reality. Small errors might creep in despite my best effort. If you do find something out of place, missing or simply wrong, please open an issue or PR, even if it’s just for a typo! I’d really appreciate it and helps out everyone.
Known drivers using the toolkit:
It’s nice to have examples:
V2:
V1:
- S2-LP radio
- Nordic nPM1300 Power Management IC
- iqs323 inductive/capacitive sensing controller
- AXP192 Power Management IC
- ONSEMI FUSB302B USB-PD PHY
- iC-Haus iC-MD 48bit quadrature counter
- STMicroelectronics LIS2DE12 3-axis accelerometer
- ISSI IS25LP128F 128Mbit SPI NOR Flash
- ON Semiconductor CAT25040 4kbit SPI EEPROM
- TI BQ27441 Battery Fuel Gauge IC
- TI BQ25887 2-Cell Battery Charger IC
- TI ADC Bus Expanders
Feel free to add to this list!