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: mbed
Revision 0:3acd5371fbc4, committed 2015-06-19
- Comitter:
- vgregl
- Date:
- Fri Jun 19 18:17:12 2015 +0000
- Commit message:
- Gregl-Tomi?i?
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 3acd5371fbc4 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jun 19 18:17:12 2015 +0000 @@ -0,0 +1,44 @@ +#include "mbed.h" +PwmOut buzzer(p22); +I2C MSP430G(p9, p10); //sda, sc1 +Serial pc(USBTX, USBRX); //tx, rx +const int addr1 = 0x90; +const int addr2 = 0x92; +char config_t[2]; // transmitt buffer +char temp1_read[2]; // read buffer +char temp2_read[2]; // read buffer +float temp1; +float temp2; +int main() +{ + + while(1) { + config_t[0] = 0xC0; //config slave to int temp + config_t[1] = 0x00; // config data byte1, BOut + MSP430G.write(addr1, config_t, 2); + wait_us(20); + MSP430G.read(addr1, temp1_read, 2); //read the two-byte temp data + float temp1 = temp1_read[0]+temp1_read[1]*256; + pc.printf("Temp1 = %.1f degC\n\r", temp1/10); // print on screen + config_t[0] = 0xC0; //config slave to int temp + config_t[1] = 0x55; // config data byte1, BOut + MSP430G.write(addr2, config_t, 2); + wait_us(20); + MSP430G.read(addr2, temp2_read, 2); //read the two-byte temp data + float temp2 = temp2_read[0]+temp2_read[1]*256; + pc.printf("Temp2 = %.1f degC\n\r", temp2/10); // print on screen + wait(1); + if (temp1 >= 40 ){ + config_t[0] = 0xC0; //config slave to int temp + config_t[1] = 0xff; // config data byte1, BOut + MSP430G.write(addr1, config_t, 2); + wait_us(20); + MSP430G.read(addr1, temp1_read, 2); //read the two-byte temp data + } + else { + config_t[0] = 0xC0; //config slave to int temp + config_t[1] = 0xff; // config data byte1, BOut + MSP430G.write(addr1, config_t, 2); + wait_us(20); + MSP430G.read(addr1, temp1_read, 2); //read the two-byte temp data + } \ No newline at end of file
diff -r 000000000000 -r 3acd5371fbc4 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Jun 19 18:17:12 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/7cff1c4259d7 \ No newline at end of file