Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Buffer INA2xx PID mbed
mcp4725.h
00001 #include "mbed.h" 00002 00003 #define MCP4725_ADDR 0xC0 00004 #define MCP4726_CMD_WRITEDAC (0x40) // Writes data to the DAC 00005 #define MCP4726_CMD_WRITEDACEEPROM (0x60) // Writes data to the DAC and the EEPROM (persisting the assigned value after reset) 00006 00007 bool mcp4725_setVoltage(I2C *i2c, uint16_t value, bool eeprom) 00008 { 00009 uint8_t i2c_read_data[3]; 00010 i2c_read_data[0] = eeprom ? MCP4726_CMD_WRITEDACEEPROM : MCP4726_CMD_WRITEDAC; 00011 i2c_read_data[1] = value >> 4; 00012 i2c_read_data[2] = (value & 0x0F) << 4; 00013 return i2c->write(MCP4725_ADDR, (const char *)i2c_read_data, 3); 00014 }
Generated on Tue Oct 11 2022 21:11:11 by
