MCP4725
1.0.0
MCP4725 library DAC for PICO rp2040
|
Class for MCP4725_PIC0 DAC. More...
#include <mcp4725.hpp>
Public Member Functions | |
MCP4725_PICO (float refV=MCP4725_REFERENCE_VOLTAGE) | |
Constructor for class MCP4725_PIC0. More... | |
bool | begin (MCP4725_I2C_Addr_e addr, i2c_inst_t *type, uint16_t speed, uint8_t SDA, uint8_t SCLK) |
Init & config i2c. More... | |
bool | isConnected () |
Checks if DAC is connected. More... | |
bool | GeneralCall (MCP4725_GeneralCallType_e) |
General Call, name from datasheet section 7.3. More... | |
void | deinitI2C () |
Switch off the I2C interface and return I2C GPIO to default state. | |
void | setReferenceVoltage (float value) |
Sets the reference voltage. More... | |
float | getReferenceVoltage (void) |
Gets the reference voltage. More... | |
bool | setInputCode (uint16_t inputCode, MCP4725_CmdType_e=MCP4725_FastMode, MCP4725_PowerDownType_e=MCP4725_PowerDown_Off) |
Set voltage out based on DAC input code. More... | |
uint16_t | getInputCode (void) |
get current DAC InputCode from DAC register More... | |
bool | setVoltage (float voltage, MCP4725_CmdType_e=MCP4725_FastMode, MCP4725_PowerDownType_e=MCP4725_PowerDown_Off) |
Set voltage out based on voltage input in volts. More... | |
float | getVoltage (void) |
get DAC inputCode from DAC register & convert to volts More... | |
uint16_t | getStoredInputCode (void) |
Read DAC inputCode from EEPROM. More... | |
float | getStoredVoltage (void) |
Read stored DAC InputCode from EEPROM & convert to voltage. More... | |
uint16_t | getPowerType (void) |
Get current power type from DAC register. More... | |
uint16_t | getStoredPowerType (void) |
Get stored power type from EEPROM. More... | |
void | setSerialDebugFlag (bool onOff) |
Setter for serial debug flag. More... | |
bool | getSerialDebugFlag (void) |
Gets the serial Debug flag value. More... | |
void | setSafetyCheckFlag (bool onOff) |
Setter for safety Check flag. More... | |
bool | getSafetyCheckFlag (void) |
Gets the safety Check flag value. More... | |
Class for MCP4725_PIC0 DAC.
MCP4725_PICO::MCP4725_PICO | ( | float | refV = MCP4725_REFERENCE_VOLTAGE | ) |
Constructor for class MCP4725_PIC0.
refV | The the reference voltage to be set in Volts. |
bool MCP4725_PICO::begin | ( | MCP4725_I2C_Addr_e | addr, |
i2c_inst_t * | i2c_type, | ||
uint16_t | CLKspeed, | ||
uint8_t | SDApin, | ||
uint8_t | SCLKpin | ||
) |
Init & config i2c.
addr | I2C address 8 bit address 0x6?. |
i2c_type | I2C instance of port, IC20 or I2C1. |
CLKspeed | I2C Bus Clock speed in Kbit/s. see 7.1 datasheet |
SDApin | I2C Data GPIO |
SCLKpin | I2C Clock GPIO |
bool MCP4725_PICO::GeneralCall | ( | MCP4725_GeneralCallType_e | typeCall | ) |
General Call, name from datasheet section 7.3.
typeCall | Reset or wakeup see MCP4725_GeneralCallType_e. |
uint16_t MCP4725_PICO::getInputCode | ( | void | ) |
get current DAC InputCode from DAC register
uint16_t MCP4725_PICO::getPowerType | ( | void | ) |
Get current power type from DAC register.
float MCP4725_PICO::getReferenceVoltage | ( | void | ) |
Gets the reference voltage.
bool MCP4725_PICO::getSafetyCheckFlag | ( | void | ) |
Gets the safety Check flag value.
bool MCP4725_PICO::getSerialDebugFlag | ( | void | ) |
Gets the serial Debug flag value.
uint16_t MCP4725_PICO::getStoredInputCode | ( | void | ) |
Read DAC inputCode from EEPROM.
uint16_t MCP4725_PICO::getStoredPowerType | ( | void | ) |
Get stored power type from EEPROM.
float MCP4725_PICO::getStoredVoltage | ( | void | ) |
Read stored DAC InputCode from EEPROM & convert to voltage.
float MCP4725_PICO::getVoltage | ( | void | ) |
get DAC inputCode from DAC register & convert to volts
bool MCP4725_PICO::isConnected | ( | ) |
Checks if DAC is connected.
bool MCP4725_PICO::setInputCode | ( | uint16_t | InputCode, |
MCP4725_CmdType_e | mode = MCP4725_FastMode , |
||
MCP4725_PowerDownType_e | powerType = MCP4725_PowerDown_Off |
||
) |
Set voltage out based on DAC input code.
InputCode | 0 to MCP4725_MAX_VALUE. |
mode | MCP4725DAC mode, see enum MCP4725_CmdType_e. |
powerType | MCP4725DAC power type, see enum MCP4725_PowerType_e |
void MCP4725_PICO::setReferenceVoltage | ( | float | voltage | ) |
Sets the reference voltage.
voltage | the reference voltage to be set, called from constructor. |
void MCP4725_PICO::setSafetyCheckFlag | ( | bool | onOff | ) |
Setter for safety Check flag.
onOff | Turns or or off the safety check flag |
void MCP4725_PICO::setSerialDebugFlag | ( | bool | onOff | ) |
Setter for serial debug flag.
onOff | Turns or or off the serial debug flag |
bool MCP4725_PICO::setVoltage | ( | float | voltage, |
MCP4725_CmdType_e | mode = MCP4725_FastMode , |
||
MCP4725_PowerDownType_e | powerType = MCP4725_PowerDown_Off |
||
) |
Set voltage out based on voltage input in volts.
voltage | 0 to_MCP4725_REFERENCE_VOLTAGE, voltage out |
mode | MCP4725DAC mode, see enum MCP4725_CmdType_e. |
powerType | MCP4725DAC power type, see enum MCP4725_PowerType_e |