10 #ifndef __MCP4725_DAC_H
11 #define __MCP4725_DAC_H
15 #include "pico/stdlib.h"
16 #include "hardware/i2c.h"
22 typedef enum : uint8_t
33 typedef enum : uint8_t
41 typedef enum : uint8_t
50 typedef enum : uint8_t
58 typedef enum : uint8_t
68 #define MCP4725_I2C_DELAY 50000
69 #define MCP4725_ERROR 0xFFFF
70 #define MCP4725_EEPROM_WRITE_TIME 25
73 #define MCP4725_REFERENCE_VOLTAGE 3.3
74 #define MCP4725_RESOLUTION 12
75 #define MCP4725_STEPS pow(2, (MCP4725_RESOLUTION))
76 #define MCP4725_MAX_VALUE ((MCP4725_STEPS) - 1)
119 uint16_t _CLKSpeed = 100;
120 bool _serialDebug =
false;
123 uint16_t _bitsPerVolt;
124 bool _safetyCheck =
true;
126 bool getEEPROMBusyFlag(
void);
Class for MCP4725_PIC0 DAC.
Definition: mcp4725.hpp:83
uint16_t getStoredInputCode(void)
Read DAC inputCode from EEPROM.
Definition: mcp4725.cpp:181
float getVoltage(void)
get DAC inputCode from DAC register & convert to volts
Definition: mcp4725.cpp:168
uint16_t getInputCode(void)
get current DAC InputCode from DAC register
Definition: mcp4725.cpp:152
void setSafetyCheckFlag(bool onOff)
Setter for safety Check flag.
Definition: mcp4725.cpp:411
void setReferenceVoltage(float value)
Sets the reference voltage.
Definition: mcp4725.cpp:83
bool setVoltage(float voltage, MCP4725_CmdType_e=MCP4725_FastMode, MCP4725_PowerDownType_e=MCP4725_PowerDown_Off)
Set voltage out based on voltage input in volts.
Definition: mcp4725.cpp:124
bool getSafetyCheckFlag(void)
Gets the safety Check flag value.
Definition: mcp4725.cpp:417
bool begin(MCP4725_I2C_Addr_e addr, i2c_inst_t *type, uint16_t speed, uint8_t SDA, uint8_t SCLK)
Init & config i2c.
Definition: mcp4725.cpp:28
float getReferenceVoltage(void)
Gets the reference voltage.
Definition: mcp4725.cpp:97
uint16_t getStoredPowerType(void)
Get stored power type from EEPROM.
Definition: mcp4725.cpp:231
bool setInputCode(uint16_t inputCode, MCP4725_CmdType_e=MCP4725_FastMode, MCP4725_PowerDownType_e=MCP4725_PowerDown_Off)
Set voltage out based on DAC input code.
Definition: mcp4725.cpp:106
float getStoredVoltage(void)
Read stored DAC InputCode from EEPROM & convert to voltage.
Definition: mcp4725.cpp:197
bool getSerialDebugFlag(void)
Gets the serial Debug flag value.
Definition: mcp4725.cpp:405
void setSerialDebugFlag(bool onOff)
Setter for serial debug flag.
Definition: mcp4725.cpp:399
uint16_t getPowerType(void)
Get current power type from DAC register.
Definition: mcp4725.cpp:212
void deinitI2C()
Switch off the I2C interface and return I2C GPIO to default state.
Definition: mcp4725.cpp:51
bool GeneralCall(MCP4725_GeneralCallType_e)
General Call, name from datasheet section 7.3.
Definition: mcp4725.cpp:430
bool isConnected()
Checks if DAC is connected.
Definition: mcp4725.cpp:62
MCP4725_PICO(float refV=MCP4725_REFERENCE_VOLTAGE)
Constructor for class MCP4725_PIC0.
Definition: mcp4725.cpp:14
MCP4725_ReadType_e
Definition: mcp4725.hpp:51
@ MCP4725_ReadEEPROM
Definition: mcp4725.hpp:54
@ MCP4725_ReadDACReg
Definition: mcp4725.hpp:53
@ MCP4725_ReadSettings
Definition: mcp4725.hpp:52
MCP4725_GeneralCallType_e
Definition: mcp4725.hpp:59
@ MCP4725_GeneralCallWakeUp
Definition: mcp4725.hpp:62
@ MCP4725_GeneralCallAddress
Definition: mcp4725.hpp:60
@ MCP4725_GeneralCallReset
Definition: mcp4725.hpp:61
MCP4725_CmdType_e
Definition: mcp4725.hpp:34
@ MCP4725_EEPROM_Mode
Definition: mcp4725.hpp:37
@ MCP4725_FastMode
Definition: mcp4725.hpp:35
@ MCP4725_RegisterMode
Definition: mcp4725.hpp:36
#define MCP4725_REFERENCE_VOLTAGE
Definition: mcp4725.hpp:73
MCP4725_PowerDownType_e
Definition: mcp4725.hpp:42
@ MCP4725_PowerDown_Off
Definition: mcp4725.hpp:43
@ MCP4725_PowerDown_1kOhm
Definition: mcp4725.hpp:44
@ MCP4725_PowerDown_100kOhm
Definition: mcp4725.hpp:45
@ MCP4725_PowerDown_500kOhm
Definition: mcp4725.hpp:46
MCP4725_I2C_Addr_e
Definition: mcp4725.hpp:23
@ MCP4725A1_Addr_A01
Definition: mcp4725.hpp:27
@ MCP4725A0_Addr_A01
Definition: mcp4725.hpp:25
@ MCP4725A0_Addr_A00
Definition: mcp4725.hpp:24
@ MCP4725A2_Addr_A00
Definition: mcp4725.hpp:28
@ MCP4725A2_Addr_A01
Definition: mcp4725.hpp:29
@ MCP4725A1_Addr_A00
Definition: mcp4725.hpp:26