MCP4725  1.0.0
MCP4725 library DAC for PICO rp2040
Classes | Macros | Enumerations
mcp4725.hpp File Reference

Library header file for MCP4725 PICO DAC library. More...

#include <stdio.h>
#include "pico/stdlib.h"
#include "hardware/i2c.h"
#include <cmath>

Go to the source code of this file.

Classes

class  MCP4725_PICO
 Class for MCP4725_PIC0 DAC. More...
 

Macros

#define MCP4725_I2C_DELAY   50000
 
#define MCP4725_ERROR   0xFFFF
 
#define MCP4725_EEPROM_WRITE_TIME   25
 
#define MCP4725_REFERENCE_VOLTAGE   3.3
 
#define MCP4725_RESOLUTION   12
 
#define MCP4725_STEPS   pow(2, (MCP4725_RESOLUTION))
 
#define MCP4725_MAX_VALUE   ((MCP4725_STEPS) - 1)
 

Enumerations

enum  MCP4725_I2C_Addr_e : uint8_t {
  MCP4725A0_Addr_A00 = 0x60 , MCP4725A0_Addr_A01 = 0x61 , MCP4725A1_Addr_A00 = 0x62 , MCP4725A1_Addr_A01 = 0x63 ,
  MCP4725A2_Addr_A00 = 0x64 , MCP4725A2_Addr_A01 = 0x65
}
 
enum  MCP4725_CmdType_e : uint8_t { MCP4725_FastMode = 0x00 , MCP4725_RegisterMode = 0x40 , MCP4725_EEPROM_Mode = 0x60 }
 
enum  MCP4725_PowerDownType_e : uint8_t { MCP4725_PowerDown_Off = 0x00 , MCP4725_PowerDown_1kOhm = 0x01 , MCP4725_PowerDown_100kOhm = 0x02 , MCP4725_PowerDown_500kOhm = 0x03 }
 
enum  MCP4725_ReadType_e : uint8_t { MCP4725_ReadSettings = 1 , MCP4725_ReadDACReg = 3 , MCP4725_ReadEEPROM = 5 }
 
enum  MCP4725_GeneralCallType_e : uint8_t { MCP4725_GeneralCallAddress = 0x00 , MCP4725_GeneralCallReset = 0x06 , MCP4725_GeneralCallWakeUp = 0x09 }
 

Detailed Description

Library header file for MCP4725 PICO DAC library.

Author
Gavin Lyons
Note
See URL for full details. https://github.com/gavinlyonsrepo/MCP4725_PICO

Macro Definition Documentation

◆ MCP4725_EEPROM_WRITE_TIME

#define MCP4725_EEPROM_WRITE_TIME   25

mSec Memory write time, maximum 50 mSec

◆ MCP4725_ERROR

#define MCP4725_ERROR   0xFFFF

returns this value if I2C bus error from some methods

◆ MCP4725_I2C_DELAY

#define MCP4725_I2C_DELAY   50000

uS delay , I2C timeout

◆ MCP4725_MAX_VALUE

#define MCP4725_MAX_VALUE   ((MCP4725_STEPS) - 1)

Max value = 4096 -1 , 0 to 4095

◆ MCP4725_REFERENCE_VOLTAGE

#define MCP4725_REFERENCE_VOLTAGE   3.3

supply-reference Voltage in volts

◆ MCP4725_RESOLUTION

#define MCP4725_RESOLUTION   12

resolution in bits , 12-bit

◆ MCP4725_STEPS

#define MCP4725_STEPS   pow(2, (MCP4725_RESOLUTION))

quantity of DAC steps 2^12-bits = 4096

Enumeration Type Documentation

◆ MCP4725_CmdType_e

enum MCP4725_CmdType_e : uint8_t

DAC register, command bits C2C1C0

Enumerator
MCP4725_FastMode 

Writes data to DAC register

MCP4725_RegisterMode 

Writes data & config bits to DAC register

MCP4725_EEPROM_Mode 

Writes data & config bits to DAC register & EEPROM

◆ MCP4725_GeneralCallType_e

enum MCP4725_GeneralCallType_e : uint8_t

DAC general call command datasheet 7.3

Enumerator
MCP4725_GeneralCallAddress 

General call address

MCP4725_GeneralCallReset 

General call reset command

MCP4725_GeneralCallWakeUp 

General call wake-up command

◆ MCP4725_I2C_Addr_e

enum MCP4725_I2C_Addr_e : uint8_t

8-bit i2c address.

Enumerator
MCP4725A0_Addr_A00 

MCP4725A0 with A0 = GND

MCP4725A0_Addr_A01 

MCP4725A0 with A0 = VCC

MCP4725A1_Addr_A00 

MCP4725A1 with A0 = GND

MCP4725A1_Addr_A01 

MCP4725A1 with A0 = VCC

MCP4725A2_Addr_A00 

MCP4725A2 with A0 = GND

MCP4725A2_Addr_A01 

MCP4725A2 with A0 = VCC

◆ MCP4725_PowerDownType_e

enum MCP4725_PowerDownType_e : uint8_t

DAC register, power down bits PD1 PD0 , BSY,POR,xx,xx,xx,PD1,PD0,xx

Enumerator
MCP4725_PowerDown_Off 

Power down off draws 0.40mA no load & 0.29mA max load

MCP4725_PowerDown_1kOhm 

Power down on, with 1.0 kOhm to GND, draws ~60nA

MCP4725_PowerDown_100kOhm 

Power down on, with 100 kOhm to GND

MCP4725_PowerDown_500kOhm 

Power down on, with 500 kOhm to GND

◆ MCP4725_ReadType_e

enum MCP4725_ReadType_e : uint8_t

DAC library read register type

Enumerator
MCP4725_ReadSettings 

Read 1 byte, Settings data

MCP4725_ReadDACReg 

Read 3 bytes, DAC register data

MCP4725_ReadEEPROM 

Read 5 bytes, EEPROM data