working dacexample

master
edwin 4 years ago
parent 1f802b9ecf
commit 146a254f40

@ -52,8 +52,8 @@ MCP4725::MCP4725()
} }
MCP4725::MCP4725(I2C* i2c) : MCP4725::MCP4725(I2C* i2c) :
//power_down_mode(pwrd_md::normal), power_down_mode(pwrd_md::normal),
//address(i2c_addr::addr_0x6), address(addr_0x60),
i2c(i2c), i2c(i2c),
dac_value(0), dac_value(0),
eeprom_value(0) eeprom_value(0)
@ -68,7 +68,7 @@ MCP4725::MCP4725(I2C* i2c) :
temp[4] = temp[1]; temp[4] = temp[1];
temp[5] = temp[2]; temp[5] = temp[2];
//i2c_write(address, temp, 6); i2c->writeBuffer(address, temp, 6);
} }
//MCP4725::~MCP4725() //MCP4725::~MCP4725()

@ -24,7 +24,7 @@ class MCP4725
addr_0x3 = addr_0x0 + 1, addr_0x3 = addr_0x0 + 1,
addr_0x4 = addr_0x0 + 1, addr_0x4 = addr_0x0 + 1,
addr_0x5 = addr_0x0 + 1, addr_0x5 = addr_0x0 + 1,
addr_0x6 = addr_0x0 + 1, addr_0x60 = 0x60,//addr_0x0 + 1,
addr_0x7 = addr_0x0 + 1 addr_0x7 = addr_0x0 + 1
}; };

@ -129,13 +129,24 @@ void foo(int baa)
void mcp4725_test() void mcp4725_test()
{ {
uint8_t i = 0;
std::cout << "mcp4725 dac test" << std::endl; std::cout << "mcp4725 dac test" << std::endl;
MCP4725 dac(&i2c); MCP4725 dac(&i2c);
dac = 0x0000; dac = 0xFFFF;
for(i = 5 ; i > 0; i--)
{
std::cout << "off" << std::endl;
dac = 0x0000;
usleep(2000000);
std::cout << "on" << std::endl;
dac = 0xFFFF;
usleep(2000000);
}
/* /*
MCP4725 dac(//MCP4725::pwrd_md::normal, MCP4725 dac(//MCP4725::pwrd_md::normal,
MCP4725::i2c_addr::addr_0x6, MCP4725::i2c_addr::addr_0x6,

Binary file not shown.
Loading…
Cancel
Save