pcf8591 - Driver for 8-bit ADC and an 8-bit DAC PCF8591

group pcf8591

ESP-IDF driver for 8-bit analog-to-digital conversion and an 8-bit digital-to-analog conversion PCF8591.

Ported from esp-open-rtos

Copyright (C) 2017 Pham Ngoc Thanh pnt239@gmail.com

Copyright (C) 2017, 2018 Ruslan V. Uss

unclerus@gmail.com

BSD Licensed as described in the file LICENSE

Defines

PCF8591_DEFAULT_ADDRESS

Enums

enum pcf8591_input_conf_t

Analog inputs configuration, see datasheet.

Values:

enumerator PCF8591_IC_4_SINGLES

Four single-ended inputs.

enumerator PCF8591_IC_DIFF

Three differential inputs.

enumerator PCF8591_IC_2_SINGLES_DIFF

Two single-ended and differnetial mixed.

enumerator PCF8591_IC_2_DIFFS

Two differential inputs.

Functions

esp_err_t pcf8591_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 descriptior.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

  • addr: I2C device address

  • port: I2C port number

  • sda_gpio: GPIO pin for SDA

  • scl_gpio: GPIO pin for SCL

esp_err_t pcf8591_free_desc(i2c_dev_t *dev)

Free device descriptor.

Return

ESP_OK on success

Parameters
  • dev: Device descriptor

esp_err_t pcf8591_read(i2c_dev_t *dev, pcf8591_input_conf_t conf, uint8_t channel, uint8_t *value)

Read input value of an analog pin.

Return

ESP_OK on success

Parameters
  • [in] dev: Device descriptor

  • [in] conf: Analog inputs configuration

  • [in] channel: Analog channel

  • [out] value: Analog value

esp_err_t pcf8591_write(i2c_dev_t *dev, uint8_t value)

Write value to analog output.

Return

ESP_OK on success

Parameters
  • [in] dev: Device descriptor

  • [in] value: DAC value