-
Fork of AD7730 by
Revision 1:82872c4221fc, committed 2015-03-17
- Comitter:
- frada
- Date:
- Tue Mar 17 12:13:39 2015 +0000
- Parent:
- 0:c584a588c24f
- Commit message:
- -
Changed in this revision
AD7730.cpp | Show annotated file Show diff for this revision Revisions of this file |
AD7730.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r c584a588c24f -r 82872c4221fc AD7730.cpp --- a/AD7730.cpp Fri Dec 16 20:31:01 2011 +0000 +++ b/AD7730.cpp Tue Mar 17 12:13:39 2015 +0000 @@ -25,7 +25,6 @@ _dac = readRegistry(DAC_REG); _offset = readRegistry(OFFSET_REG); _gain = readRegistry(GAIN_REG); - //set chip select high _cs = 1; @@ -33,9 +32,6 @@ internalFullCal(); internalZeroCal(); - //turn off LED3 - _LED3 = false; - _continous = false; _bufferCount = 0; @@ -357,7 +353,7 @@ double avg = 0; double value = 0; for(int i=0; i<20; i++){ - value = (double)read(); + value = (double)read(false); avg += value; } @@ -420,7 +416,7 @@ /************************************************************************************************************************/ //function to do a single read with conversion /************************************************************************************************************************/ -int AD7730::read(){ +int AD7730::read(bool _wait){ if(_continous){ //chip is running in continous conversion mode @@ -428,7 +424,7 @@ } else { //a new conversion must be started - startConversion(true); + startConversion(_wait); return readRegistry(DATA_REG); } }
diff -r c584a588c24f -r 82872c4221fc AD7730.h --- a/AD7730.h Fri Dec 16 20:31:01 2011 +0000 +++ b/AD7730.h Tue Mar 17 12:13:39 2015 +0000 @@ -3,6 +3,15 @@ #include "mbed.h" +#define STATUS_REG 0x00 +#define DATA_REG 0x01 +#define MODE_REG 0x02 +#define FILTER_REG 0x03 +#define DAC_REG 0x04 +#define OFFSET_REG 0x05 +#define GAIN_REG 0x06 +#define TEST_REG 0x07 + class AD7730{ public: @@ -14,7 +23,7 @@ int initialize(void); int systemLowCal(double wgt); int systemHighCal(double wgt, double fullScale); - int read(); + int read(bool _wait); int startConversion(bool wait); void setFilter(int SF, bool chop, int filter2); void setFilterSF(int SF); @@ -45,17 +54,7 @@ bool _continous; int _frequency; Timer _tmr; - - //Registry value constants - static const int STATUS_REG = 0; - static const int DATA_REG = 1; - static const int MODE_REG = 2; - static const int FILTER_REG = 3; - static const int DAC_REG = 4; - static const int OFFSET_REG = 5; - static const int GAIN_REG = 6; - static const int TEST_REG = 7; - + //define empty spi command static const int EMPTY_SPI = 0xFF; @@ -77,9 +76,7 @@ //private functions int internalZeroCal(void); int internalFullCal(void); - void interruptRead(void); - - + void interruptRead(void); }; #endif