This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF5340 - DAC driver in Zephyr

Hi,
to develop a device driver in Zephyr for TI DAC80501, a 16-bit DAC, I2C interface,
I have to
1. add the dts child node under the i2c controller node

  $i2c1 {
       dac80501@48 {
           compatible = "ti,dac80501";
           reg = <0x48>;
       };
  };
2. find a devicetree binding corresponding to the node's compatible property
3. write the driver in zephyr/drivers/adc/
Could anybody help me following through 2. and 3.
Thank you
  • Thank you, I definitely agree with your remark.
    My device is a DAC, then putting the driver into <zephyr>/drivers/dac is more appropriate.
    Hereinafter the complete process
    1) Under <zephyr>/drivers/dac/ add files
     dac_dacx0501.c
     dac_dacx0501.h
     Kconfig.dacx0501
    2) In <zephyr>/drivers/dac/CMakeLists.txt add the line
     zephyr_library_sources_ifdef(CONFIG_DAC_DACX0501    dac_dacx0501.c)
    3) In <zephyr>/drivers/dac/Kconfig add the line
     source "drivers/dac/Kconfig.dacx0501"
    4) In dac_dacx0501.c implement the I2C read/write functions
     int dacx501_reg_read()  to read a register
     int dacx501_reg_write() to overwrite a register
     int dacx501_init()  to initialize the driver and the device
     int dacx501_channel_setup() the standard API to open a DAC channel (I have only one)
     int dacx501_write_value() the standard API to write a value to DAC
    As for the application side <src>/main.c
    5) Include
     #include <include/device.h>
     #include <dac.h>
    6) Retrieve the device structure for a the DAC driver by name using
     struct device* device_get_binding()
    7) Create the structure for specifying the configuration of the DAC channel
     struct dac_channel_cfg
    8) Use it to configure the DAC channel with
     int dac_channel_setup()
    9) Finally you are able to write data to the DAC using
     int dac_write_value()
    Gabriele
Related