Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions boards/shields/adafruit_mcp4728/Kconfig.shield
Original file line number Diff line number Diff line change
@@ -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)
26 changes: 26 additions & 0 deletions boards/shields/adafruit_mcp4728/adafruit_mcp4728.overlay
Original file line number Diff line number Diff line change
@@ -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 */
};
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
75 changes: 75 additions & 0 deletions boards/shields/adafruit_mcp4728/doc/index.rst
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions boards/shields/adafruit_mcp4728/shield.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions samples/drivers/dac/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ tests:
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"