Ciaran Doyle
/
i2c
i2c
Revision 0:519691976fbc, committed 2020-07-18
- Comitter:
- qaz
- Date:
- Sat Jul 18 08:23:26 2020 +0000
- Commit message:
- dasfd
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 519691976fbc main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Jul 18 08:23:26 2020 +0000 @@ -0,0 +1,24 @@ +#include "mbed.h" + +// Read temperatures from Grid-EYE +// note i2c stuff does not need a special ,h file + +I2C i2c(PTE0, PTE1); + +const int addr = 0x90; + +int main() { + char cmd[2]; + while (1) { + cmd[0] = 0x01; + cmd[1] = 0x00; + i2c.write(addr, cmd, 2); + wait(0.5); + cmd[0] = 0x00; + i2c.write(addr, cmd, 1); + i2c.read(addr, cmd, 2); + + float tmp = (float((cmd[0]<<8)|cmd[1]) / 256.0); + printf("Temp = %.2f\n", tmp); + } +} \ No newline at end of file
diff -r 000000000000 -r 519691976fbc mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Jul 18 08:23:26 2020 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/e7ca05fa8600 \ No newline at end of file