Loading...
Searching...
No Matches
#include <stdbool.h>
#include <stdint.h>
#include "kernel_defines.h"
#include "periph/dac.h"
#include "periph/gpio.h"
#include "periph/i2c.h"
+ Include dependency graph for mcp47xx.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  mcp47xx_params_t
 MCP47xx device configuration parameters. More...
 
struct  mcp47xx_t
 MCP47xx device data structure type. More...
 
struct  mcp47xx_saul_dac_params_t
 MCP47xx configuration structure for mapping DAC channels to SAUL. More...
 

Enumerations

enum  mcp47xx_error_codes_t { MCP47XX_OK , MCP47XX_ERROR_I2C , MCP47XX_ERROR_NOT_AVAIL }
 MCP47xx driver error codes. More...
 
enum  mcp47xx_variant_t {
  MCP4706 , MCP4716 , MCP4725 , MCP4726 ,
  MCP4728
}
 Supported MCP47xx variants. More...
 
enum  mcp47xx_gain_t { MCP47XX_GAIN_1X = 0 , MCP47XX_GAIN_2X = 1 }
 MCP47xx gain configuration type. More...
 
enum  mcp47xx_vref_t { MCP47XX_VREF_VDD = 0 , MCP47XX_VREF_INT = 1 , MCP47XX_VREF_PIN = 2 , MCP47XX_VREF_BUF = 3 }
 MCP47xx V_REF configuration type. More...
 
enum  mcp47xx_pd_mode_t { MCP47XX_NORMAL = 0 , MCP47XX_PD_SMALL = 1 , MCP47XX_PD_MEDIUM = 2 , MCP47XX_PD_LARGE = 3 }
 MCP47xx Power-down mode selection type. More...
 

Functions

int mcp47xx_init (mcp47xx_t *dev, const mcp47xx_params_t *params)
 Initialize the MCP47xx DAC.
 
int mcp47xx_dac_init (mcp47xx_t *dev, uint8_t chn)
 Initialize a MCP47xx DAC channel.
 
void mcp47xx_dac_set (mcp47xx_t *dev, uint8_t chn, uint16_t value)
 Write a value to a MCP47xx DAC channel.
 
void mcp47xx_dac_get (mcp47xx_t *dev, uint8_t chn, uint16_t *value)
 Get the current value of a MCP47xx DAC channel.
 
void mcp47xx_dac_poweron (mcp47xx_t *dev, uint8_t chn)
 Enables the MCP47xx DAC device.
 
void mcp47xx_dac_poweroff (mcp47xx_t *dev, uint8_t chn)
 Disables the MCP47xx DAC device.
 
uint8_t mcp47xx_dac_channels (mcp47xx_t *dev)
 Returns the number of channels of MCP47xx DAC device.
 

MCP47xx I2C slave addresses

MCP47xx I2C slave addresses are defined as an offset to a base address, which depends on the expander used.

The address offset is in the range of 0 to 7.

#define MCP47XX_BASE_ADDR   (0x60)
 MCP47xx I2C slave base address.
 

MCP47xx Channel number

#define MCP4706_CHN_NUM   (1)
 MCP4706 has 1 channel.
 
#define MCP4716_CHN_NUM   (1)
 MCP4716 has 1 channel.
 
#define MCP4725_CHN_NUM   (1)
 MCP4725 has 1 channel.
 
#define MCP4726_CHN_NUM   (1)
 MCP4726 has 1 channel.
 
#define MCP4728_CHN_NUM   (4)
 MCP4728 has 4 channels.
 
#define MCP47XX_CHN_NUM_MAX   (4)
 maximum number of channels