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.
Fork of DDRO_Farrari by
dac.cpp
- Committer:
- josewang
- Date:
- 2014-02-25
- Revision:
- 10:95e9932f7990
- Parent:
- 0:84a8bcfbdec9
File content as of revision 10:95e9932f7990:
#include "dac.h"
using namespace std;
void power_chan(char i2caddr, char chan, float voltage)
{
char data[3];
// voltage = 3.3 * Code / 4096
// Code = voltage * 4096 / 3.3 = voltage * 1241
unsigned int full_code = 1241 * voltage;
char MSDB, LSDB;
LSDB = full_code % 0x10;
MSDB = full_code / 0x10;
data[0]=chan;
data[1]=MSDB;
data[2]=LSDB;
power_error_indicator = 1;
//pc.printf ("%X\r\n", A);
while (dac_i2c.write(i2caddr,data,3,false)) {
}
power_error_indicator = 0;
}
