Added DAC support to PCF8591 driver
This commit is contained in:
parent
715bc8148c
commit
60b671ea44
3 changed files with 54 additions and 23 deletions
|
|
@ -1,14 +1,16 @@
|
|||
/**
|
||||
* Driver for 8-bit analog-to-digital conversion and
|
||||
* Driver for 8-bit analog-to-digital conversion and
|
||||
* an 8-bit digital-to-analog conversion PCF8591
|
||||
*
|
||||
* Part of esp-open-rtos
|
||||
* Copyright (C) 2017 Pham Ngoc Thanh <pnt239@gmail.com>
|
||||
* 2017 Ruslan V. Uss <unclerus@gmail.com>
|
||||
* BSD Licensed as described in the file LICENSE
|
||||
*/
|
||||
#ifndef _EXTRAS_PCF8591_H_
|
||||
#define _EXTRAS_PCF8591_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <i2c/i2c.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
@ -16,25 +18,33 @@ extern "C"
|
|||
{
|
||||
#endif
|
||||
|
||||
/**
|
||||
* CAUTION: PLEASE SET I2C_FREQUENCY_400K IS 'false' IN 'i2c.h' FILE
|
||||
*/
|
||||
|
||||
#define PCF8591_DEFAULT_ADDRESS 0x48
|
||||
|
||||
void pcf8591_init(void); //FIXME : library incomplete ?
|
||||
/**
|
||||
* Analog inputs configuration, see datasheet
|
||||
*/
|
||||
typedef enum {
|
||||
PCF8591_IC_4_SINGLES = 0, //!< Four single-ended inputs
|
||||
PCF8591_IC_DIFF, //!< Three differential inputs
|
||||
PCF8591_IC_2_SINGLES_DIFF, //!< Two single-ended and differnetial mixed
|
||||
PCF8591_IC_2_DIFFS //!< Two differential inputs
|
||||
} pcf8591_input_conf_t;
|
||||
|
||||
/**
|
||||
* Read input value of an analog pin.
|
||||
* @param[in] addr Pointer to device
|
||||
* @param[in] analog_pin pin number:
|
||||
* 0 - AIN0
|
||||
* 1 - AIN1
|
||||
* 2 - AIN2
|
||||
* 3 - AIN3
|
||||
* @param[in] dev Pointer to device
|
||||
* @param[in] conf Analog inputs configuration
|
||||
* @param[in] channel Analog channel
|
||||
* @return analog value
|
||||
*/
|
||||
uint8_t pcf8591_read(i2c_dev_t* dev, uint8_t analog_pin);
|
||||
uint8_t pcf8591_read(i2c_dev_t *dev, pcf8591_input_conf_t conf, uint8_t channel);
|
||||
|
||||
/**
|
||||
* Write value to analog output
|
||||
* @param[in] dev Pointer to device
|
||||
* @param[in] value DAC value
|
||||
*/
|
||||
void pcf8591_write(i2c_dev_t *dev, uint8_t value);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue