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