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.
Dependents: Orange_Ferrari_board_functional
Diff: dac.cpp
- Revision:
- 0:84a8bcfbdec9
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dac.cpp Mon Oct 07 22:58:19 2013 +0000 @@ -0,0 +1,26 @@ +#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; +}