startet implementation of memberfunctions

master
edwin 4 years ago
parent e675de628f
commit 2161aee82a

@ -7,7 +7,16 @@ MCP4725::MCP4725(pwrd_md power_down_mode,
address(address),
i2c_write(i2c_write)
{
uint8_t temp[6];
temp[0] = 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(temp,6);
}
MCP4725::MCP4725(i2c_addr address,
@ -15,8 +24,17 @@ MCP4725::MCP4725(i2c_addr address,
power_down_mode(MCP4725::normal),
address(address),
i2c_write(i2c_write)
{
{
uint8_t temp[6];
temp[0] = 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(temp,6);
}
MCP4725::~MCP4725()

@ -1,6 +1,9 @@
#ifndef _MCP4725_HPP_
#define _MCP4725_HPP_
#include <stdint.h>
#include <functional>
class MCP4725
{
public:
@ -28,7 +31,7 @@ class MCP4725
//using std::functional<uint8_t(uint8_t, uint8_t)> i2c_read_n_t;
using std::functional<void(uint8_t,uint8_t)> i2c_write_n_t;
using std::functional<void(uint8_t*,uint8_t)> i2c_write_n_t;
MCP4725(pwrd_md power_down_mode,
i2c_addr address,
@ -53,10 +56,19 @@ class MCP4725
private:
enum commands_t
{
fast_mode = 0x00,
write_dac = 0x40,
write_dac_and_eeprom = 0x60
};
i2c_addr address;
pwrd_md power_down_mode;
i2c_write_n_t i2c_write;
uint16_t dac_value;
uint16_t eeprom_value;
};

Loading…
Cancel
Save