SDK

kdrv

The chip drivers of the Kode Dot: one per part, what each one hides, how the register tables work, and which page documents each chip.

What it is

kdrv is the layer that knows the chips. Each driver speaks to one part: it knows its address, its registers and its traps, and nothing about when the part should be used. That decision belongs to the part's owner, an Active Object in kaos. A driver is the only place in the SDK where a part number appears, so swapping a chip touches one file and the board description.

A driver page in this section is the whole story of a part: what the chip is, how the Kode Dot wires it, its registers, and how the driver is built over them. The Kode Dot pages (device/overview) say what a part does for your app; these pages say how it works underneath.

How it is connected

flowchart TB
ao["kaos<br/>the owner AO"] -- "function call" --> drv["kdrv<br/>the driver"]
subgraph below["Below the driver"]
  khal["khal"]
  kbsp["kbsp"]
  idf["ESP-IDF components"]
end
drv -- "khal_i2c, khal_gpio, ..." --> khal
drv -. "addresses, pins" .-> kbsp
drv -- "esp_lcd, esp_hosted, ..." --> idf
class ao ao
Where kdrv sits

Calls in and out

A driver is called by exactly one Active Object, the part's owner, and calls down into khal for the shared services: the I2C bus, GPIO, time. Its address and pins come from kbsp as named constants; a driver never writes a pin number itself. Where Espressif or the chip vendor publishes a component, kdrv wraps it instead of rewriting it: the CO5300 panel through esp_lcd_co5300, the ES8311 codec through esp_codec_dev, the radio link through esp_hosted. Those versions are pinned exactly in the layer's idf_component.yml, because the numbers the drivers check were measured against them.

Public headers speak kode_status_t. No esp_err_t, no ESP-IDF type crosses a kdrv header, which is what keeps ESP-IDF out of every layer above.

Register maps

Register maps are tables. For the parts with a register map worth reading (the BQ25896, the CW2217, the TCA6408A, the CST820, the ES8311, the AW86233, the ST25R3916B, the ESP32-C5's status and the microSD card), every field the datasheet names is one row: register, bit position, width, scale, range, and whether it is writable.

Layout

Each module has include/ for its public header and src/ for its code. Every include/ is on the include path, so code writes #include "kdrv_bq25896.h" and never names the folder.

The parts

Every module of the layer, the chip or job it covers, and the page that documents it.

ModuleChip or jobPage
powerBQ25896 charger and power pathsdk/kdrv/bq25896
powerCW2217 fuel gaugesdk/kdrv/cw2217
tca6408aTCA6408A I/O expandersdk/kdrv/tca6408a
ledKTD2026 RGB LED driversdk/kdrv/ktd2026
buttonsThe D-pad and the side buttonssdk/kdrv/buttons
clocksThe 40 MHz and 32.768 kHz crystalssdk/kdrv/clocks
displayCO5300 AMOLED panel over MIPI-DSIsdk/kdrv/co5300
cst820CST820 touch controllersdk/kdrv/cst820
audioES8311 codec, speaker amplifier and microphonesdk/kdrv/es8311
motionQMI8658A IMUsdk/kdrv/qmi8658a
motionQMC5883P magnetometersdk/kdrv/qmc5883p
motionAW86233 haptic driver and its motorsdk/kdrv/aw86233
radioESP32-C5 radio coprocessor and its linksdk/kdrv/c5
radioWi-Fi, Bluetooth and the network stack over the linksdk/kdrv/radio
nfcST25R3916B NFC reader and card emulationsdk/kdrv/st25r3916
rfidThe 125 kHz front endsdk/kdrv/rfid
irInfrared, served by the ESP32-C5sdk/kdrv/ir
storagemicroSD slot and the internal FATsdk/kdrv/storage
appsThe apps region of the flash and the image formatsdk/kdrv/apps
mirrorHardware JPEG and the screen mirrorsdk/kdrv/mirror
ov5640, stationThe E5 station's camera on J3, its relays, its ADC and the pads loop, built with KODE_TEST_DOTsdk/kaos/test-dot

In the SDK