last

Dependencies:   Buffer INA2xx PID mbed

Committer:
jotaemesousa
Date:
Tue Oct 11 21:11:01 2022 +0000
Revision:
1:aaa70b16382f
Parent:
0:94b4516b2f32
last;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jotaemesousa 0:94b4516b2f32 1 #include "mbed.h"
jotaemesousa 0:94b4516b2f32 2
jotaemesousa 0:94b4516b2f32 3 #define MCP4725_ADDR 0xC0
jotaemesousa 0:94b4516b2f32 4 #define MCP4726_CMD_WRITEDAC (0x40) // Writes data to the DAC
jotaemesousa 0:94b4516b2f32 5 #define MCP4726_CMD_WRITEDACEEPROM (0x60) // Writes data to the DAC and the EEPROM (persisting the assigned value after reset)
jotaemesousa 0:94b4516b2f32 6
jotaemesousa 0:94b4516b2f32 7 bool mcp4725_setVoltage(I2C *i2c, uint16_t value, bool eeprom)
jotaemesousa 0:94b4516b2f32 8 {
jotaemesousa 0:94b4516b2f32 9 uint8_t i2c_read_data[3];
jotaemesousa 0:94b4516b2f32 10 i2c_read_data[0] = eeprom ? MCP4726_CMD_WRITEDACEEPROM : MCP4726_CMD_WRITEDAC;
jotaemesousa 0:94b4516b2f32 11 i2c_read_data[1] = value >> 4;
jotaemesousa 0:94b4516b2f32 12 i2c_read_data[2] = (value & 0x0F) << 4;
jotaemesousa 0:94b4516b2f32 13 return i2c->write(MCP4725_ADDR, (const char *)i2c_read_data, 3);
jotaemesousa 0:94b4516b2f32 14 }