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.
AD7730.h
00001 #ifndef AD7730_H 00002 #define AD7730_H 00003 00004 #include "mbed.h" 00005 00006 class AD7730{ 00007 00008 public: 00009 AD7730(PinName mosi, PinName miso, PinName sclk, PinName ready, PinName cs); 00010 ~AD7730(void); 00011 00012 int readRegistry(int registry); 00013 int writeRegistry(int registry, int value); 00014 int initialize(void); 00015 int systemLowCal(double wgt); 00016 int systemHighCal(double wgt, double fullScale); 00017 int read(); 00018 int startConversion(bool wait); 00019 void setFilter(int SF, bool chop, int filter2); 00020 void setFilterSF(int SF); 00021 void setFilterMode(int mode); 00022 void setFilterChop(int enabled); 00023 void reset(bool fullReset); 00024 int adjustDAC(int direction); 00025 void start(void); 00026 void stop(void); 00027 bool isReady(void); 00028 double getHz(void); 00029 00030 00031 private: 00032 00033 SPI _spi; 00034 DigitalOut _cs; 00035 DigitalIn _readyDig; 00036 DigitalOut _LED3; 00037 InterruptIn *_interruptReady; 00038 PinName _readyPin; 00039 double _fullScaleWeight; 00040 double _minWeight; 00041 double _maxWeight; 00042 int _readBuffer[100]; 00043 int _bufferCount; 00044 int _lastValue; 00045 bool _continous; 00046 int _frequency; 00047 Timer _tmr; 00048 00049 //Registry value constants 00050 static const int STATUS_REG = 0; 00051 static const int DATA_REG = 1; 00052 static const int MODE_REG = 2; 00053 static const int FILTER_REG = 3; 00054 static const int DAC_REG = 4; 00055 static const int OFFSET_REG = 5; 00056 static const int GAIN_REG = 6; 00057 static const int TEST_REG = 7; 00058 00059 //define empty spi command 00060 static const int EMPTY_SPI = 0xFF; 00061 00062 //internal registries 00063 int _mode; 00064 int _filter; 00065 int _dac; 00066 int _offset; 00067 int _gain; 00068 00069 00070 //timing variables 00071 Timer _exeTmr; 00072 int _exeTime; 00073 00074 //error variables 00075 int _exeError; 00076 00077 //private functions 00078 int internalZeroCal(void); 00079 int internalFullCal(void); 00080 void interruptRead(void); 00081 00082 00083 }; 00084 00085 #endif
Generated on Tue Jul 19 2022 00:40:35 by
1.7.2