|
|
|
@ -1,11 +1,16 @@
|
|
|
|
|
#include "mcp4725.hpp"
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
MCP4725::MCP4725(pwrd_md power_down_mode,
|
|
|
|
|
i2c_addr address,
|
|
|
|
|
i2c_write_n_t i2c_write) :
|
|
|
|
|
I2C* i2c) :
|
|
|
|
|
power_down_mode(power_down_mode),
|
|
|
|
|
address(address),
|
|
|
|
|
i2c_write(i2c_write)
|
|
|
|
|
i2c(i2c),
|
|
|
|
|
dac_value(0),
|
|
|
|
|
eeprom_value(0)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
uint8_t temp[6];
|
|
|
|
|
|
|
|
|
@ -16,14 +21,17 @@ MCP4725::MCP4725(pwrd_md power_down_mode,
|
|
|
|
|
temp[4] = temp[1];
|
|
|
|
|
temp[5] = temp[2];
|
|
|
|
|
|
|
|
|
|
i2c_write(address, temp,6);
|
|
|
|
|
//i2c_write(address, temp,6);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MCP4725::MCP4725(i2c_addr address,
|
|
|
|
|
i2c_write_n_t i2c_write)
|
|
|
|
|
power_down_mode(MCP4725::normal),
|
|
|
|
|
I2C* i2c) :
|
|
|
|
|
power_down_mode(pwrd_md::normal),
|
|
|
|
|
address(address),
|
|
|
|
|
i2c_write(i2c_write)
|
|
|
|
|
i2c(i2c),
|
|
|
|
|
dac_value(0),
|
|
|
|
|
eeprom_value(0)
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
uint8_t temp[6];
|
|
|
|
|
|
|
|
|
@ -34,26 +42,57 @@ MCP4725::MCP4725(i2c_addr address,
|
|
|
|
|
temp[4] = temp[1];
|
|
|
|
|
temp[5] = temp[2];
|
|
|
|
|
|
|
|
|
|
i2c_write(address, temp, 6);
|
|
|
|
|
//i2c_write(address, temp, 6);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
MCP4725::~MCP4725()
|
|
|
|
|
MCP4725::MCP4725()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MCP4725::MCP4725(I2C* i2c) :
|
|
|
|
|
//power_down_mode(pwrd_md::normal),
|
|
|
|
|
//address(i2c_addr::addr_0x6),
|
|
|
|
|
i2c(i2c),
|
|
|
|
|
dac_value(0),
|
|
|
|
|
eeprom_value(0)
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
uint8_t temp[6];
|
|
|
|
|
|
|
|
|
|
temp[0] = cmd_write_dac_and_eeprom | (power_down_mode << 1);
|
|
|
|
|
temp[1] = static_cast<uint8_t>(dac_value >> 4);
|
|
|
|
|
temp[2] = static_cast<uint8_t>(dac_value << 4);
|
|
|
|
|
temp[3] = temp[0];
|
|
|
|
|
temp[4] = temp[1];
|
|
|
|
|
temp[5] = temp[2];
|
|
|
|
|
|
|
|
|
|
//i2c_write(address, temp, 6);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//MCP4725::~MCP4725()
|
|
|
|
|
//{
|
|
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
void MCP4725::operator=(uint16_t dac_value)
|
|
|
|
|
{
|
|
|
|
|
uint8_t temp[3];
|
|
|
|
|
this.dac_value = dac_value;
|
|
|
|
|
this->dac_value = dac_value;
|
|
|
|
|
|
|
|
|
|
temp[0] = cmd_write_dac | (power_down_mode << 1);
|
|
|
|
|
temp[1] = static_cast<uint8_t>(dac_value >> 4);
|
|
|
|
|
temp[2] = static_cast<uint8_t>(dac_value << 4);
|
|
|
|
|
|
|
|
|
|
i2c_write(address, temp, 3);
|
|
|
|
|
|
|
|
|
|
i2c->writeBuffer(address, temp, 3);
|
|
|
|
|
|
|
|
|
|
//i2c_write(address, temp, 3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
|
|
void MCP4725::operator==(uint16_t dac_and_eeprom_value)
|
|
|
|
|
{
|
|
|
|
|
uint8_t temp[6];
|
|
|
|
@ -61,6 +100,14 @@ void MCP4725::operator==(uint16_t dac_and_eeprom_value)
|
|
|
|
|
eeprom_value = dac_value;
|
|
|
|
|
|
|
|
|
|
temp[0] = cmd_write_dac_and_eeprom | (power_down_mode << 1);
|
|
|
|
|
temp[1] = static_cast<uint8_t>(dac_and_eeprom_value >> 4);
|
|
|
|
|
temp[2] = static_cast<uint8_t>(dac_and_eeprom_value << 4);
|
|
|
|
|
temp[3] = temp[0];
|
|
|
|
|
temp[4] = temp[1];
|
|
|
|
|
temp[5] = temp[2];
|
|
|
|
|
|
|
|
|
|
//i2c_write(address, temp, 6);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MCP4725::write_dac(uint16_t dac_value)
|
|
|
|
@ -73,4 +120,4 @@ void MCP4725::write_dac_and_eeprom(uint16_t dac_and_eeprom_value)
|
|
|
|
|
&this == dac_and_eeprom_value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|