ds3502 - Driver for nonvolatile digital potentiometer DS3502

group ds3502

ESP-IDF driver for nonvolatile digital potentiometer DS3502.

Copyright (C) 2021 Ruslan V. Uss unclerus@gmail.com

MIT Licensed as described in the file LICENSE

Defines

DS3502_ADDR_0
DS3502_ADDR_1
DS3502_ADDR_2
DS3502_ADDR_3
DS3502_MAX

Maximal wiper position value.

Functions

esp_err_t ds3502_init_desc(i2c_dev_t *dev, uint8_t addr, i2c_port_t port, gpio_num_t sda_gpio, gpio_num_t scl_gpio)

Initialize device descriptor.

Parameters
  • dev – Device descriptor

  • addr – Device address, DS3502_ADDR_...

  • port – I2C port number

  • sda_gpio – GPIO pin number for SDA

  • scl_gpio – GPIO pin number for SCL

Returns

ESP_OK on success

esp_err_t ds3502_free_desc(i2c_dev_t *dev)

Free device descriptor.

Parameters

dev – Device descriptor

Returns

ESP_OK on success

esp_err_t ds3502_init(i2c_dev_t *dev)

Initialize device.

Parameters

dev – Device descriptor

Returns

ESP_OK on success

esp_err_t ds3502_get(i2c_dev_t *dev, uint8_t *pos)

Get wiper position.

Parameters
  • dev – Device descriptor

  • [out] pos – Position, 0..DS3502_MAX_WIPER

Returns

ESP_OK on success

esp_err_t ds3502_set(i2c_dev_t *dev, uint8_t pos, bool save)

Set wiper position.

Parameters
  • dev – Device descriptor

  • pos – Wiper position, 0..DS3502_MAX_WIPER

  • save – Save position to nonvolatile memory

Returns

ESP_OK on success