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: ad5933.cpp
- Revision:
- 3:b844dd14179c
- Parent:
- 2:93dd1ebfedea
- Child:
- 4:1ecb56465953
--- a/ad5933.cpp Mon May 11 13:27:26 2015 +0000
+++ b/ad5933.cpp Mon May 11 13:48:59 2015 +0000
@@ -174,9 +174,7 @@
reset();
setControlReg(INIT_FREQ);
- wait_ms(100);
- if(getRegister(0x8F) != 0x04)
- return false;
+ wait_ms(250);
setControlReg(INIT_SWEEP);
wait_ms(5);
@@ -207,7 +205,30 @@
output = gotoAdressPointer(0x82);
output &= readBlock(data, 4);
- real = data[0] | data[1] << 8;
- imaginary = data[2] | data[3] << 8;
+ real = data[0] << 8 | data[1];
+ imaginary = data[2] << 8 | data[3];
return output;
}
+
+float AD5933::getTemperature()
+{
+ int i = 0;
+ uint8_t data[2];
+
+ while((getRegister(0x8F) != 0x01) && i < 10) {
+ wait_ms(5);
+ i++;
+ }
+ if(i == 10)
+ return false;
+
+ gotoAdressPointer(0x92);
+ readBlock(data, 2);
+
+ if((data[0] >> 6) & 1) {
+ //negative temperature
+ return (((data[0] << 8 | data[1]) - 16384)/32.0) ;
+ } else {
+ return ((data[0] << 8 | data[1])/32.0) ;
+ }
+}