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.
Diff: power_up.cpp
- Revision:
- 0:c928c2d8bd02
- Child:
- 1:acf14b6dd1be
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/power_up.cpp Wed May 02 01:34:55 2012 +0000 @@ -0,0 +1,87 @@ +#include "power_up.h" +using namespace std; + +#define ADDR 0x98 //change to 94 or 98 if doesn't work +#define POWER_UP_TIME 1 + +I2C i2c(p9, p10); //sda, scl +DigitalOut ADDR0(p6); //ADDR0 in DAC +//Serial pc(USBTX, USBRX);//tx, rx => for debugging purposes +DigitalOut power_indicator (LED1); +DigitalOut power_error_indicator (LED4); +DigitalOut LDAC_BAR(p7); +DigitalOut CLR_BAR(p5); + +void power(const int A, char CA, char MSDB, char LSDB) { + int state; + char data[3]; + data[0]=CA; + data[1]=MSDB; + data[2]=LSDB; + debugPower(); + power_error_indicator = 1; + //pc.printf ("%X\n", A); + while (i2c.write(A,data,3,false)) { + } + power_error_indicator = 0; +} + +void powerUp() { + power(ADDR,0x31,0x8B,0xA0) ; //update channel B 1.8V DVDD2 + wait(POWER_UP_TIME); + power(ADDR,0x37,0x4D,0x90) ; //update channel H 1V AVDD + wait(POWER_UP_TIME); + power(ADDR,0x35,0x26,0xC0) ; //update channel F 0.5V AVDD2 + wait(POWER_UP_TIME); + power(ADDR,0x34,0x4D,0x90) ; //update channel E 1V WRAPPERVD + wait(POWER_UP_TIME); + power(ADDR,0x32,0x4D,0x90) ; //update channel C 1V COREVDD + wait(POWER_UP_TIME); + power(ADDR,0x30,0x4D,0x90) ; //update channel A 1V SRAMVDD + wait(POWER_UP_TIME); + power(ADDR,0x36,0x4D,0x90) ; //update channel G 1V SENSEVDD + wait(POWER_UP_TIME); + power_indicator = 1; + power(ADDR,0x33,0xFF,0xF0) ; //update channel D 3.3V DVDD + wait(POWER_UP_TIME); +} +void powerDown() { + power(ADDR,0x33,0x00,0x00) ; //update channel D 3.3V DVDD + wait(POWER_UP_TIME); + power_indicator = 0; + power(ADDR,0x37,0x00,0x00) ; //update channel H 1V AVDD + wait(POWER_UP_TIME); + power(ADDR,0x35,0x00,0x00) ; //update channel F 0.5V AVDD2 + wait(POWER_UP_TIME); + power(ADDR,0x34,0x00,0x00) ; //update channel E 1V WRAPPERVD + wait(POWER_UP_TIME); + power(ADDR,0x32,0x00,0x00) ; //update channel C 1V COREVDD + wait(POWER_UP_TIME); + power(ADDR,0x30,0x00,0x00) ; //update channel A 1V SRAMVDD + wait(POWER_UP_TIME); + power(ADDR,0x36,0x00,0x00) ; //update channel G 1V SENSEVDD + wait(POWER_UP_TIME); + power(ADDR,0x31,0x00,0x00) ; //update channel B 1.8V DVDD2 + wait(POWER_UP_TIME); +} + +void powerReset() { + power_indicator = 0; + CLR_BAR = 0; + ADDR0 = 0; + LDAC_BAR = 0; + CLR_BAR = 1; +} + +void debugPower() { + char data[3]; + data[0]=0x31; + data[1]=0x8B; + data[2]=0xA0; + int A = 0; + for (A = 0; A<=0xFF; A++) { + if (i2c.write(A,data,3,false)==0) { + //pc.printf ("%X\n", A); + } + } +} \ No newline at end of file