boards: shields: Add Adafruit MCP4728 DAC shield The product photo is from https://learn.adafruit.com/assets/86699 Tested with the command mentioned in the index.rst file. Compile testing of the overlay file is done via the DAC sample. Signed-off-by: Jonas Berg <jonas.s.t.berg@gmail.com>
diff --git a/boards/shields/adafruit_mcp4728/Kconfig.shield b/boards/shields/adafruit_mcp4728/Kconfig.shield new file mode 100644 index 0000000..f805e93 --- /dev/null +++ b/boards/shields/adafruit_mcp4728/Kconfig.shield
@@ -0,0 +1,5 @@ +# Copyright (c) 2025 Jonas Berg +# SPDX-License-Identifier: Apache-2.0 + +config SHIELD_ADAFRUIT_MCP4728 + def_bool $(shields_list_contains,adafruit_mcp4728)
diff --git a/boards/shields/adafruit_mcp4728/adafruit_mcp4728.overlay b/boards/shields/adafruit_mcp4728/adafruit_mcp4728.overlay new file mode 100644 index 0000000..9ed1d1f --- /dev/null +++ b/boards/shields/adafruit_mcp4728/adafruit_mcp4728.overlay
@@ -0,0 +1,26 @@ +/* + * Copyright (c) 2025 Jonas Berg + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/ { + zephyr,user { + dac = <&dac_adafruit_mcp4728>; + dac-channel-id = <0>; + dac-resolution = <12>; + }; +}; + +&zephyr_i2c { + status = "okay"; + + dac_adafruit_mcp4728: dac@60 { + status = "okay"; + compatible = "microchip,mcp4728"; + reg = <0x60>; + #io-channel-cells = <1>; + voltage-reference = <01 01 01 01>; /* Internal reference (2.048V) */ + power-down-mode = <00 00 00 00>; /* Normal mode */ + }; +};
diff --git a/boards/shields/adafruit_mcp4728/doc/adafruit_mcp4728.webp b/boards/shields/adafruit_mcp4728/doc/adafruit_mcp4728.webp new file mode 100644 index 0000000..6fa325a --- /dev/null +++ b/boards/shields/adafruit_mcp4728/doc/adafruit_mcp4728.webp Binary files differ
diff --git a/boards/shields/adafruit_mcp4728/doc/index.rst b/boards/shields/adafruit_mcp4728/doc/index.rst new file mode 100644 index 0000000..4e628f1 --- /dev/null +++ b/boards/shields/adafruit_mcp4728/doc/index.rst
@@ -0,0 +1,75 @@ +.. _adafruit_mcp4728: + +Adafruit MCP4728 Quad DAC Shield +################################ + +Overview +******** + +The `Adafruit MCP4728 Quad DAC Shield`_ features a `Microchip 12-Bit Quad Output DAC`_ and +two STEMMA QT connectors. It has four output channels and an internal voltage reference. + +.. figure:: adafruit_mcp4728.webp + :align: center + :alt: Adafruit MCP4728 DAC Shield + + Adafruit MCP4728 DAC Shield (Credit: Adafruit) + + +Requirements +************ + +This shield can be used with boards which provide an I2C connector, for +example STEMMA QT or Qwiic connectors. +The target board must define a ``zephyr_i2c`` node label. +See :ref:`shields` for more details. + + +Pin Assignments +=============== + ++--------------+-------------------------------------------------+ +| Shield Pin | Function | ++==============+=================================================+ +| SCL | MCP4728 I2C SCL | ++--------------+-------------------------------------------------+ +| SDA | MCP4728 I2C SDA | ++--------------+-------------------------------------------------+ +| LDAC | MCP4728 load DAC input | ++--------------+-------------------------------------------------+ +| RDY | MCP4728 ready. Low when busy with EEPROM write. | ++--------------+-------------------------------------------------+ +| VA - VD | MCP4728 output channels | ++--------------+-------------------------------------------------+ + +When using this shield via the STEMMA QT connector, the supply voltage is 3.3 Volt, so the +maximum internal voltage reference that can be used is 2.048 Volt. + +The LDAC pin is pulled down on the shield, forcing an updated output voltage as soon as +the input register has been written. + +See :dtcompatible:`microchip,mcp4728` for documentation on how to adjust the +devicetree file, for example to adjust the voltage reference, gain or power-down mode. + + +Programming +*********** + +Set ``--shield adafruit_mcp4728`` when you invoke ``west build``. For example +when running the :zephyr:code-sample:`dac` sample: + +.. zephyr-app-commands:: + :zephyr-app: samples/drivers/dac + :board: adafruit_feather_adalogger_rp2040 + :shield: adafruit_mcp4728 + :goals: build flash + +Connect a voltmeter to the shield output ``VA`` and observe how the voltage changes. +To run the sample for another output channel, modify the value for the ``dac-channel-id`` +attribute in the .overlay file for this shield. + +.. _Adafruit MCP4728 Quad DAC Shield: + https://learn.adafruit.com/adafruit-mcp4728-i2c-quad-dac + +.. _Microchip 12-Bit Quad Output DAC: + https://www.microchip.com/en-us/product/mcp4728
diff --git a/boards/shields/adafruit_mcp4728/shield.yml b/boards/shields/adafruit_mcp4728/shield.yml new file mode 100644 index 0000000..5216529 --- /dev/null +++ b/boards/shields/adafruit_mcp4728/shield.yml
@@ -0,0 +1,10 @@ +# SPDX-License-Identifier: Apache-2.0 +# +# Copyright (c) 2025, Jonas Berg + +shield: + name: adafruit_mcp4728 + full_name: Adafruit MCP4728 DAC Shield + vendor: adafruit + supported_features: + - dac
diff --git a/samples/drivers/dac/sample.yaml b/samples/drivers/dac/sample.yaml index 384ea16..6b02b3c 100644 --- a/samples/drivers/dac/sample.yaml +++ b/samples/drivers/dac/sample.yaml
@@ -16,5 +16,7 @@ sample.drivers.dac.shields: platform_allow: - adafruit_feather_rp2040/rp2040 + - adafruit_feather_adalogger_rp2040/rp2040 extra_args: - platform:adafruit_feather_rp2040/rp2040:SHIELD="adafruit_ad5693r" + - platform:adafruit_feather_adalogger_rp2040/rp2040:SHIELD="adafruit_mcp4728"