This sample project contains a driver component named da7219
for an audio hardware codec device (Dialog da7219) connected to an I2C bus with device address 0x1A
. The driver interacts with the device hardware using the fuchsia.hardware.i2c
protocol, and exposes the Codec FIDL protocol (fuchsia.hardware.audio/Codec
) for other components to consume.
The i2c_controller
driver component emulates an I2C bus controller, creating the child device nodes to the sensor device and responding to I2C protocol commands received from the child devices.
To build the da7219
driver and related components, run the following commands:
tools/bazel build --config=fuchsia_x64 //src/da7219/controller:pkg tools/bazel build --config=fuchsia_x64 //src/da7219/driver:pkg
Use the following commands to load the driver components on Qemu:
Load the i2c_controller
driver component to create a virtual I2C device node:
tools/bazel run --config=fuchsia_x64 //src/da7219/controller:pkg.component
Load the da7219
driver component to bind to the device node and begin sending requests:
tools/bazel run --config=fuchsia_x64 //src/da7219/driver:pkg.component
Open the device log viewer:
tools/ffx log --filter i2c_controller --filter da7219
You should see the da7219
driver log that it is started after the driver has successfully bound.
[da7219,driver][I]: [da7219.cc:139] Started
//src/da7219/controller
— Source code of the i2c_controller
driver component.//src/da7219/driver/
— Source code of the da7219
driver component.