Vadim Kimlaychuk / AD5933

Files at this revision

API Documentation at this revision

Comitter:
vadimk
Date:
Sun Aug 22 10:39:50 2021 +0300
Parent:
7:0e8dabae876c
Commit message:
real/imaginary values are signed integers

Changed in this revision

ad5933.cpp Show annotated file Show diff for this revision Revisions of this file
ad5933.h Show annotated file Show diff for this revision Revisions of this file
diff -r 0e8dabae876c -r 20576c73ba85 ad5933.cpp
--- a/ad5933.cpp	Fri Aug 20 23:27:15 2021 +0300
+++ b/ad5933.cpp	Sun Aug 22 10:39:50 2021 +0300
@@ -16,6 +16,7 @@
 
 #include "ad5933.h"
 #include "mbed.h"
+#include <cstdint>
 
 // Define Command bytes
 #define INIT_FREQ  0x10     // initialise startfreq
@@ -222,8 +223,8 @@
     gotoAdressPointer(0x94);
     readBlock(data, 4);
 
-    real = data[0] << 8 | data[1];
-    imaginary = data[2] << 8 | data[3];
+    real = (int16_t) (data[0] << 8 | data[1]);
+    imaginary = (int16_t) (data[2] << 8 | data[3]);
     return status;
 }
 
diff -r 0e8dabae876c -r 20576c73ba85 ad5933.h
--- a/ad5933.h	Fri Aug 20 23:27:15 2021 +0300
+++ b/ad5933.h	Sun Aug 22 10:39:50 2021 +0300
@@ -113,10 +113,10 @@
     bool initFrequencySweepParam(unsigned int startFreq, unsigned int stepFreq, unsigned int nrOfSteps, unsigned int nrOfCycles, bool PGA, int RangeNr);
 
     /// real part of impedance (uncalibrated)
-    unsigned int real;
+    int real;
 
     /// imaginary part of impedance (uncalibrated)
-    unsigned int imaginary;
+    int imaginary;
 
 private:
     I2C sCom;