This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new dd8c234ad82 drivers/analog: add MCP45XX potentiometer support
dd8c234ad82 is described below

commit dd8c234ad822d41f50d83ea64f9d4ab3251bc257
Author: Daniel P. Carvalho <[email protected]>
AuthorDate: Mon Oct 19 21:25:49 2026 -0300

    drivers/analog: add MCP45XX potentiometer support
    
    Add a lower-half driver for the Microchip MCP454X, MCP456X, MCP464X and
    MCP466X 7/8-bit single/dual I2C digital potentiometers (DS22107B), on
    top of the common potentiometer interface.
    
    The wipers are read, written and moved with the native increment and
    decrement commands, sent as one continuous transfer.  A wiper can be
    forced into shutdown through the TCON register.  POTIOC_STORE_WIPER and
    POTIOC_RECALL_WIPER use the nonvolatile wiper register that is loaded at
    power-up (slot 0): the store waits for the EEPROM write cycle, checks it
    by reading the register back, and reports -EROFS when the EEPROM is
    write protected or the wiper is locked, since the device ignores those
    writes silently.
    
    Tested on a MCP4561 on an STM32G4: wiper write and read at both ends of
    the range, the limits, move with saturation, and store and recall,
    including the stored value after a reset.  The other devices follow the
    datasheet and were not tested.
    
    Assisted-by: Claude Code:claude-sonnet-5-5
    Signed-off-by: Daniel P. Carvalho <[email protected]>
---
 .../os/drivers/character/analog/pot/index.rst      |   7 +
 drivers/analog/CMakeLists.txt                      |   4 +
 drivers/analog/Kconfig                             |  14 +
 drivers/analog/Make.defs                           |   4 +
 drivers/analog/mcp45xx.c                           | 563 +++++++++++++++++++++
 include/nuttx/analog/pot.h                         |  39 ++
 6 files changed, 631 insertions(+)

diff --git a/Documentation/os/drivers/character/analog/pot/index.rst 
b/Documentation/os/drivers/character/analog/pot/index.rst
index 829626ef178..06def3e3323 100644
--- a/Documentation/os/drivers/character/analog/pot/index.rst
+++ b/Documentation/os/drivers/character/analog/pot/index.rst
@@ -60,4 +60,11 @@ Chip       Bus   Notes
 MCP445X    I2C   Quad wiper, 257 taps. Terminal control via the
                  ``ANIOC_MCP445X_*`` ioctls, see
                  ``include/nuttx/analog/mcp445x.h``.
+MCP45XX    I2C   MCP4541, MCP4561, MCP4641 and MCP4661: 7/8-bit
+                 (129/257 taps), one or two wipers, with a nonvolatile
+                 wiper register. ``POTIOC_STORE_WIPER`` and
+                 ``POTIOC_RECALL_WIPER`` use slot 0, the register that
+                 is loaded at power-up. A store returns ``-EROFS`` when
+                 the EEPROM is write protected or the wiper is locked.
+                 Tested on the MCP4561 only.
 ========== ===== ====================================================
diff --git a/drivers/analog/CMakeLists.txt b/drivers/analog/CMakeLists.txt
index cd7d57922e7..db546fdeb7f 100644
--- a/drivers/analog/CMakeLists.txt
+++ b/drivers/analog/CMakeLists.txt
@@ -76,6 +76,10 @@ if(CONFIG_POT)
     list(APPEND SRCS mcp445x.c)
   endif()
 
+  if(CONFIG_POT_MCP45XX)
+    list(APPEND SRCS mcp45xx.c)
+  endif()
+
 endif()
 
 # Check for ADC devices
diff --git a/drivers/analog/Kconfig b/drivers/analog/Kconfig
index 88235d8d17b..d593c16361b 100644
--- a/drivers/analog/Kconfig
+++ b/drivers/analog/Kconfig
@@ -507,6 +507,20 @@ config POT_MCP445X_I2C_FREQUENCY
        default 400000
        depends on POT_MCP445X
 
+config POT_MCP45XX
+       bool "MCP45XX support"
+       default n
+       select I2C
+       ---help---
+               Enable driver support for the Microchip MCP454X, MCP456X, 
MCP464X
+               and MCP466X 7/8-bit single/dual digital potentiometers with
+               nonvolatile wiper memory.
+
+config POT_MCP45XX_I2C_FREQUENCY
+       int "MCP45XX I2C frequency"
+       default 400000
+       depends on POT_MCP45XX
+
 endif # POT
 
 config OPAMP
diff --git a/drivers/analog/Make.defs b/drivers/analog/Make.defs
index c81ca57cb06..662dde52739 100644
--- a/drivers/analog/Make.defs
+++ b/drivers/analog/Make.defs
@@ -88,6 +88,10 @@ ifeq ($(CONFIG_POT_MCP445X),y)
   CSRCS += mcp445x.c
 endif
 
+ifeq ($(CONFIG_POT_MCP45XX),y)
+  CSRCS += mcp45xx.c
+endif
+
 endif
 
 # Check for ADC devices
diff --git a/drivers/analog/mcp45xx.c b/drivers/analog/mcp45xx.c
new file mode 100644
index 00000000000..bba362e459a
--- /dev/null
+++ b/drivers/analog/mcp45xx.c
@@ -0,0 +1,563 @@
+/****************************************************************************
+ * drivers/analog/mcp45xx.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/* Driver for the Microchip MCP454X/MCP456X/MCP464X/MCP466X family: 7/8-bit,
+ * single/dual, I2C digital potentiometers with a nonvolatile wiper
+ * (DS22107B).
+ */
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <stdint.h>
+#include <stdbool.h>
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+
+#include <nuttx/debug.h>
+#include <nuttx/kmalloc.h>
+#include <nuttx/signal.h>
+#include <nuttx/analog/pot.h>
+#include <nuttx/i2c/i2c_master.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Command byte: AD3:AD0 | C1:C0 | D9:D8 */
+
+#define MCP45XX_REG_SHIFT     (4)
+#define MCP45XX_CMD_WRITE     (0x0 << 2)
+#define MCP45XX_CMD_INCR      (0x1 << 2)
+#define MCP45XX_CMD_DECR      (0x2 << 2)
+#define MCP45XX_CMD_READ      (0x3 << 2)
+#define MCP45XX_DATA_MASK     (0x3ff)
+
+/* Memory map */
+
+#define MCP45XX_REG_VWIPER(n)  (n)       /* Volatile wiper n */
+#define MCP45XX_REG_NVWIPER(n) (2 + (n)) /* Nonvolatile wiper n */
+#define MCP45XX_REG_TCON       (0x04)    /* Volatile terminal control */
+#define MCP45XX_REG_STATUS     (0x05)    /* Status */
+
+/* TCON: R0HW is bit 3 and R1HW is bit 7.  Clearing it forces the wiper
+ * into the shutdown configuration.
+ */
+
+#define MCP45XX_TCON_HW(n)    (1 << (3 + 4 * (n)))
+
+/* STATUS bits */
+
+#define MCP45XX_STATUS_WP      (1 << 0)         /* EEPROM write protected */
+#define MCP45XX_STATUS_WL(n)   (1 << (1 + (n))) /* Wiper n locked */
+#define MCP45XX_STATUS_EEWA    (1 << 3)         /* EEPROM write active */
+
+/* Wiper full scale: 128 resistors (7-bit) or 256 resistors (8-bit) */
+
+#define MCP45XX_MAX_7BIT      (0x80)
+#define MCP45XX_MAX_8BIT      (0x100)
+
+/* The EEPROM write cycle takes 5 ms typical, 10 ms maximum (tWC) */
+
+#define MCP45XX_TWC_POLL_US   (1000)
+#define MCP45XX_TWC_POLLS     (20)
+
+/* Number of INCR/DECR commands sent in one continuous I2C transfer */
+
+#define MCP45XX_MOVE_CHUNK    (16)
+
+/* The only nonvolatile slot is the wiper register restored at power-up */
+
+#define MCP45XX_SLOT_WIPER    (0)
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct mcp45xx_dev_s
+{
+  FAR struct i2c_master_s *i2c;  /* I2C interface */
+  struct i2c_config_s config;    /* I2C frequency and address */
+};
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+/* I2C Helpers */
+
+static int  mcp45xx_reg_write(FAR struct mcp45xx_dev_s *priv, uint8_t reg,
+                              uint16_t val);
+static int  mcp45xx_reg_read(FAR struct mcp45xx_dev_s *priv, uint8_t reg,
+                             FAR uint16_t *val);
+static int  mcp45xx_wait_write(FAR struct mcp45xx_dev_s *priv);
+
+/* Potentiometer methods */
+
+static int  mcp45xx_setup(FAR struct pot_dev_s *dev);
+static void mcp45xx_shutdown(FAR struct pot_dev_s *dev);
+static int  mcp45xx_setwiper(FAR struct pot_dev_s *dev, uint8_t wiper,
+                             uint32_t val);
+static int  mcp45xx_getwiper(FAR struct pot_dev_s *dev, uint8_t wiper,
+                             FAR uint32_t *val);
+static int  mcp45xx_move(FAR struct pot_dev_s *dev, uint8_t wiper,
+                         int32_t steps);
+static int  mcp45xx_enable(FAR struct pot_dev_s *dev, uint8_t wiper,
+                           bool enable);
+static int  mcp45xx_store(FAR struct pot_dev_s *dev, uint8_t wiper,
+                          uint8_t slot);
+static int  mcp45xx_recall(FAR struct pot_dev_s *dev, uint8_t wiper,
+                           uint8_t slot);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static const struct pot_ops_s g_potops =
+{
+  mcp45xx_setup,        /* po_setup */
+  mcp45xx_shutdown,     /* po_shutdown */
+  mcp45xx_setwiper,     /* po_setwiper */
+  mcp45xx_getwiper,     /* po_getwiper */
+  mcp45xx_move,         /* po_move */
+  mcp45xx_enable,       /* po_enable */
+  mcp45xx_store,        /* po_store */
+  mcp45xx_recall,       /* po_recall */
+  NULL                  /* po_ioctl */
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: mcp45xx_reg_write
+ *
+ * Description:
+ *   Write a 9-bit value to a register.  A write to a nonvolatile location
+ *   starts the EEPROM write cycle when the transfer ends.
+ *
+ ****************************************************************************/
+
+static int mcp45xx_reg_write(FAR struct mcp45xx_dev_s *priv, uint8_t reg,
+                             uint16_t val)
+{
+  uint8_t buffer[2];
+
+  buffer[0] = (reg << MCP45XX_REG_SHIFT) | MCP45XX_CMD_WRITE |
+              ((val >> 8) & 0x03);
+  buffer[1] = val;
+
+  return i2c_write(priv->i2c, &priv->config, buffer, 2);
+}
+
+/****************************************************************************
+ * Name: mcp45xx_reg_read
+ *
+ * Description:
+ *   Read a register.  The device answers with 10 data bits in two bytes.
+ *
+ ****************************************************************************/
+
+static int mcp45xx_reg_read(FAR struct mcp45xx_dev_s *priv, uint8_t reg,
+                            FAR uint16_t *val)
+{
+  uint8_t cmd;
+  uint8_t buffer[2];
+  int     ret;
+
+  cmd = (reg << MCP45XX_REG_SHIFT) | MCP45XX_CMD_READ;
+
+  ret = i2c_writeread(priv->i2c, &priv->config, &cmd, 1, buffer, 2);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
+  *val = ((uint16_t)buffer[0] << 8 | buffer[1]) & MCP45XX_DATA_MASK;
+  return OK;
+}
+
+/****************************************************************************
+ * Name: mcp45xx_wait_write
+ *
+ * Description:
+ *   Wait for the EEPROM write cycle to end by polling STATUS.EEWA.  The
+ *   STATUS register is volatile and can be read during the cycle.
+ *
+ ****************************************************************************/
+
+static int mcp45xx_wait_write(FAR struct mcp45xx_dev_s *priv)
+{
+  uint16_t status;
+  int      i;
+  int      ret;
+
+  for (i = 0; i < MCP45XX_TWC_POLLS; i++)
+    {
+      ret = mcp45xx_reg_read(priv, MCP45XX_REG_STATUS, &status);
+      if (ret < 0)
+        {
+          return ret;
+        }
+
+      if ((status & MCP45XX_STATUS_EEWA) == 0)
+        {
+          return OK;
+        }
+
+      nxsig_usleep(MCP45XX_TWC_POLL_US);
+    }
+
+  return -ETIMEDOUT;
+}
+
+/****************************************************************************
+ * Name: mcp45xx_setup
+ *
+ * Description:
+ *   Configure the potentiometer.  This method is called the first time
+ *   that the potentiometer device is opened.
+ *
+ ****************************************************************************/
+
+static int mcp45xx_setup(FAR struct pot_dev_s *dev)
+{
+  return OK;
+}
+
+/****************************************************************************
+ * Name: mcp45xx_shutdown
+ *
+ * Description:
+ *   Disable the potentiometer.  This method is called when the
+ *   potentiometer device is closed.
+ *
+ ****************************************************************************/
+
+static void mcp45xx_shutdown(FAR struct pot_dev_s *dev)
+{
+}
+
+/****************************************************************************
+ * Name: mcp45xx_setwiper
+ *
+ * Description:
+ *   Set the volatile wiper value.
+ *
+ ****************************************************************************/
+
+static int mcp45xx_setwiper(FAR struct pot_dev_s *dev, uint8_t wiper,
+                            uint32_t val)
+{
+  FAR struct mcp45xx_dev_s *priv = dev->pd_priv;
+
+  return mcp45xx_reg_write(priv, MCP45XX_REG_VWIPER(wiper), val);
+}
+
+/****************************************************************************
+ * Name: mcp45xx_getwiper
+ *
+ * Description:
+ *   Get the volatile wiper value.
+ *
+ ****************************************************************************/
+
+static int mcp45xx_getwiper(FAR struct pot_dev_s *dev, uint8_t wiper,
+                            FAR uint32_t *val)
+{
+  FAR struct mcp45xx_dev_s *priv = dev->pd_priv;
+  uint16_t                  regval;
+  int                       ret;
+
+  ret = mcp45xx_reg_read(priv, MCP45XX_REG_VWIPER(wiper), &regval);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
+  *val = regval;
+  return OK;
+}
+
+/****************************************************************************
+ * Name: mcp45xx_move
+ *
+ * Description:
+ *   Move a wiper with the native INCR/DECR commands, sent as continuous
+ *   commands in one transfer.  The device stops at full scale and at zero.
+ *
+ ****************************************************************************/
+
+static int mcp45xx_move(FAR struct pot_dev_s *dev, uint8_t wiper,
+                        int32_t steps)
+{
+  FAR struct mcp45xx_dev_s *priv = dev->pd_priv;
+  uint8_t                   buffer[MCP45XX_MOVE_CHUNK];
+  uint8_t                   cmd;
+  uint32_t                  n;
+  uint32_t                  len;
+  int                       ret = OK;
+
+  cmd = (MCP45XX_REG_VWIPER(wiper) << MCP45XX_REG_SHIFT) |
+        (steps < 0 ? MCP45XX_CMD_DECR : MCP45XX_CMD_INCR);
+  n   = steps < 0 ? -(uint32_t)steps : (uint32_t)steps;
+
+  /* More steps than the full scale cannot change the result */
+
+  if (n > dev->pd_max)
+    {
+      n = dev->pd_max;
+    }
+
+  memset(buffer, cmd, sizeof(buffer));
+
+  while (n > 0 && ret == OK)
+    {
+      len = n > sizeof(buffer) ? sizeof(buffer) : n;
+      ret = i2c_write(priv->i2c, &priv->config, buffer, len);
+      n  -= len;
+    }
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: mcp45xx_enable
+ *
+ * Description:
+ *   Enable a wiper, or force it into the shutdown configuration (terminal
+ *   A open and the wiper connected to terminal B) with the TCON HW bit.
+ *
+ ****************************************************************************/
+
+static int mcp45xx_enable(FAR struct pot_dev_s *dev, uint8_t wiper,
+                          bool enable)
+{
+  FAR struct mcp45xx_dev_s *priv = dev->pd_priv;
+  uint16_t                  tcon;
+  int                       ret;
+
+  ret = mcp45xx_reg_read(priv, MCP45XX_REG_TCON, &tcon);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
+  if (enable)
+    {
+      tcon |= MCP45XX_TCON_HW(wiper);
+    }
+  else
+    {
+      tcon &= ~MCP45XX_TCON_HW(wiper);
+    }
+
+  return mcp45xx_reg_write(priv, MCP45XX_REG_TCON, tcon);
+}
+
+/****************************************************************************
+ * Name: mcp45xx_store
+ *
+ * Description:
+ *   Copy the volatile wiper to its nonvolatile register, which is loaded
+ *   into the volatile one at power-up.  Slot 0 is the only slot.  The
+ *   write is checked, because a write-protected or locked wiper ignores it
+ *   without an error.
+ *
+ ****************************************************************************/
+
+static int mcp45xx_store(FAR struct pot_dev_s *dev, uint8_t wiper,
+                         uint8_t slot)
+{
+  FAR struct mcp45xx_dev_s *priv = dev->pd_priv;
+  uint16_t                  status;
+  uint16_t                  val;
+  uint16_t                  stored;
+  int                       ret;
+
+  if (slot != MCP45XX_SLOT_WIPER)
+    {
+      return -EINVAL;
+    }
+
+  ret = mcp45xx_reg_read(priv, MCP45XX_REG_STATUS, &status);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
+  if ((status & (MCP45XX_STATUS_WP | MCP45XX_STATUS_WL(wiper))) != 0)
+    {
+      return -EROFS;
+    }
+
+  ret = mcp45xx_reg_read(priv, MCP45XX_REG_VWIPER(wiper), &val);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
+  ret = mcp45xx_reg_write(priv, MCP45XX_REG_NVWIPER(wiper), val);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
+  ret = mcp45xx_wait_write(priv);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
+  ret = mcp45xx_reg_read(priv, MCP45XX_REG_NVWIPER(wiper), &stored);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
+  return stored == val ? OK : -EIO;
+}
+
+/****************************************************************************
+ * Name: mcp45xx_recall
+ *
+ * Description:
+ *   Load the volatile wiper from its nonvolatile register.  Slot 0 is the
+ *   only slot.
+ *
+ ****************************************************************************/
+
+static int mcp45xx_recall(FAR struct pot_dev_s *dev, uint8_t wiper,
+                          uint8_t slot)
+{
+  FAR struct mcp45xx_dev_s *priv = dev->pd_priv;
+  uint16_t                  val;
+  int                       ret;
+
+  if (slot != MCP45XX_SLOT_WIPER)
+    {
+      return -EINVAL;
+    }
+
+  ret = mcp45xx_reg_read(priv, MCP45XX_REG_NVWIPER(wiper), &val);
+  if (ret < 0)
+    {
+      return ret;
+    }
+
+  return mcp45xx_reg_write(priv, MCP45XX_REG_VWIPER(wiper), val);
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: mcp45xx_initialize
+ *
+ * Description:
+ *   Initialize a MCP454X/MCP456X/MCP464X/MCP466X potentiometer.
+ *
+ * Input Parameters:
+ *   i2c  - An instance of the I2C interface to communicate with the device
+ *   addr - The 7-bit I2C address of the device
+ *   chip - The device type
+ *   rab  - Terminal A-B resistance in ohms, 0 if unknown
+ *
+ * Returned Value:
+ *   Valid device structure reference on success; a NULL on failure
+ *
+ ****************************************************************************/
+
+FAR struct pot_dev_s *mcp45xx_initialize(FAR struct i2c_master_s *i2c,
+                                         uint8_t addr,
+                                         enum mcp45xx_chip_e chip,
+                                         uint32_t rab)
+{
+  FAR struct mcp45xx_dev_s *priv;
+  FAR struct pot_dev_s *potdev;
+
+  /* Sanity check */
+
+  DEBUGASSERT(i2c != NULL);
+
+  priv = kmm_malloc(sizeof(struct mcp45xx_dev_s));
+  if (priv == NULL)
+    {
+      aerr("ERROR: Failed to allocate mcp45xx_dev_s instance\n");
+      return NULL;
+    }
+
+  potdev = kmm_zalloc(sizeof(struct pot_dev_s));
+  if (potdev == NULL)
+    {
+      aerr("ERROR: Failed to allocate pot_dev_s instance\n");
+      kmm_free(priv);
+      return NULL;
+    }
+
+  switch (chip)
+    {
+      case MCP45XX_MCP4541:
+        potdev->pd_nwipers = 1;
+        potdev->pd_max     = MCP45XX_MAX_7BIT;
+        break;
+
+      case MCP45XX_MCP4561:
+        potdev->pd_nwipers = 1;
+        potdev->pd_max     = MCP45XX_MAX_8BIT;
+        break;
+
+      case MCP45XX_MCP4641:
+        potdev->pd_nwipers = 2;
+        potdev->pd_max     = MCP45XX_MAX_7BIT;
+        break;
+
+      case MCP45XX_MCP4661:
+        potdev->pd_nwipers = 2;
+        potdev->pd_max     = MCP45XX_MAX_8BIT;
+        break;
+
+      default:
+        aerr("ERROR: Unknown chip %d\n", chip);
+        kmm_free(potdev);
+        kmm_free(priv);
+        return NULL;
+    }
+
+  potdev->pd_rab  = rab;
+  potdev->pd_ops  = &g_potops;
+  potdev->pd_priv = priv;
+
+  priv->i2c              = i2c;
+  priv->config.frequency = CONFIG_POT_MCP45XX_I2C_FREQUENCY;
+  priv->config.address   = addr;
+  priv->config.addrlen   = 7;
+
+  return potdev;
+}
diff --git a/include/nuttx/analog/pot.h b/include/nuttx/analog/pot.h
index 8b623255e23..447e1003513 100644
--- a/include/nuttx/analog/pot.h
+++ b/include/nuttx/analog/pot.h
@@ -189,6 +189,18 @@ struct pot_dev_s
                                             * logic */
 };
 
+/* MCP454X/MCP456X/MCP464X/MCP466X device types */
+
+#ifdef CONFIG_POT_MCP45XX
+enum mcp45xx_chip_e
+{
+  MCP45XX_MCP4541,  /* 1 wiper, 7-bit, nonvolatile */
+  MCP45XX_MCP4561,  /* 1 wiper, 8-bit, nonvolatile */
+  MCP45XX_MCP4641,  /* 2 wipers, 7-bit, nonvolatile */
+  MCP45XX_MCP4661   /* 2 wipers, 8-bit, nonvolatile */
+};
+#endif
+
 /****************************************************************************
  * Public Function Prototypes
  ****************************************************************************/
@@ -237,6 +249,33 @@ FAR struct pot_dev_s *mcp445x_initialize(FAR struct 
i2c_master_s *i2c,
                                          uint8_t addr, uint32_t rab);
 #endif
 
+#ifdef CONFIG_POT_MCP45XX
+/****************************************************************************
+ * Name: mcp45xx_initialize
+ *
+ * Description:
+ *   Initialize a MCP454X/MCP456X/MCP464X/MCP466X potentiometer.  The
+ *   potentiometer and rheostat versions of a device share the same
+ *   registers.
+ *
+ * Input Parameters:
+ *   i2c  - An instance of the I2C interface to communicate with the device
+ *   addr - The 7-bit I2C address of the device
+ *   chip - The device type
+ *   rab  - Terminal A-B resistance in ohms, 0 if unknown
+ *
+ * Returned Value:
+ *   Valid device structure reference on success; a NULL on failure
+ *
+ ****************************************************************************/
+
+struct i2c_master_s;
+FAR struct pot_dev_s *mcp45xx_initialize(FAR struct i2c_master_s *i2c,
+                                         uint8_t addr,
+                                         enum mcp45xx_chip_e chip,
+                                         uint32_t rab);
+#endif
+
 #if defined(__cplusplus)
 }
 #endif

Reply via email to