AD7124Library  1.0.3
Arduino library for the AD7124 ADC
ad7124.h
1 
16 #ifndef __AD7124_H__
17 #define __AD7124_H__
18 /* ========================================================================== */
19 #include "include/ad7124-private.h"
20 
24 namespace Ad7124 {
39  };
46  enum PowerMode {
47  LowPower = 0,
50  };
58  enum ClkSel {
63  };
68  enum IoutCurrent {
69  CurrentOff = 0,
76  };
81  enum IoutCh {
82  IoutCh0 = 0,
83  IoutCh1 = 1,
84  IoutCh2 = 4,
85  IoutCh3 = 5,
86  IoutCh4 = 10,
87  IoutCh5 = 11,
88  IoutCh6 = 14,
89  IoutCh7 = 15
90  };
95  enum InputSel {
96  AIN0Input = 0,
104  TEMPInput = 16,
118  };
124  enum PgaSel {
125  Pga1 = 0,
133  };
140  enum RefSel {
141  RefIn1 = 0,
145  };
155  };
161  enum FilterType {
167  };
179  };
180 }
181 
186 class Ad7124Chip {
187 
188  public:
194  int begin (int slave_select);
195 
200  int reset();
201 
205  int status();
206 
217  int setAdcControl (Ad7124::OperatingMode mode, Ad7124::PowerMode power_mode, bool ref_en = true, Ad7124::ClkSel clk_sel = Ad7124::InternalClk);
218 
224  int setMode (Ad7124::OperatingMode mode);
225 
235  int setChannel (uint8_t ch, uint8_t cfg, Ad7124::InputSel ainp, Ad7124::InputSel ainm, bool enable = false);
236 
243  int enableChannel (uint8_t ch, bool enable = true);
244 
250  int channelConfig (uint8_t ch);
251 
263  int setConfig (uint8_t cfg, Ad7124::RefSel ref, Ad7124::PgaSel pga, bool bipolar, Ad7124::BurnoutCurrent burnout = Ad7124::BurnoutOff);
264 
287  int setConfigFilter (uint8_t cfg, Ad7124::FilterType filter, Ad7124::PostFilterType postfilter, uint16_t fs, bool rej60, bool single);
288 
297  int setConfigOffset (uint8_t cfg, uint32_t value);
298 
309  int setConfigGain (uint8_t cfg, uint32_t value);
310 
318  long read (uint8_t ch);
319 
325  int startSingleConversion (uint8_t ch);
326 
332  int waitEndOfConversion (uint32_t timeout_ms);
333 
338  long getData();
339 
344  int currentChannel();
345 
351  int internalCalibration (uint8_t ch);
352 
361  static double toVoltage (long value, int gain, double vref, bool bipolar = true);
362 
366 #ifdef __DOXYGEN__
367  inline uint32_t timeout() const;
368 #else
369  inline uint32_t timeout() const {
370 
371  return d.timeout();
372  }
373 #endif
374 
378 #ifdef __DOXYGEN__
379  inline void setTimeout (uint32_t ms);
380 #else
381  inline void setTimeout (uint32_t ms) {
382  d.setTimeout (ms);
383  }
384 #endif
385 
391  long getRegister (Ad7124::RegisterId id);
392 
399  int setRegister (Ad7124::RegisterId id, long value);
400 
401 #ifndef __DOXYGEN__
402  protected:
403  int readRegister (Ad7124::RegisterId id);
404  int writeRegister (Ad7124::RegisterId id);
405 
406  private:
407  Ad7124Private d;
408  Ad7124Register reg[Ad7124::Reg_No];
409 #endif
410 };
411 
412 /* ========================================================================== */
413 #endif /* __AD7124_H__ */
IoutCh
Channel select bits for the excitation current for IOUT.
Definition: ad7124.h:81
PostFilterType
Post filter type select bits. When the filter bits are set to 1, the sinc 3 filter is followed by a p...
Definition: ad7124.h:174
FilterType
Filter type select bits. These bits select the filter type.
Definition: ad7124.h:161
InputSel
Analog input AIN input select.
Definition: ad7124.h:95
PgaSel
Gain select bits. These bits select the gain to use when converting on any channels using this config...
Definition: ad7124.h:124
ClkSel
These bits select the clock source for the ADC Either the on-chip 614.4 kHz clock can be used or an e...
Definition: ad7124.h:58
PowerMode
Power Mode Select These bits select the power mode. The current consumption and output data rate rang...
Definition: ad7124.h:46
IoutCurrent
These bits set the value of the excitation current for IOUT.
Definition: ad7124.h:68
ADC device.
Definition: ad7124.h:186
OperatingMode
Control the mode of operation for ADC.
Definition: ad7124.h:29
RefSel
Reference source select bits. These bits select the reference source to use when converting on any ch...
Definition: ad7124.h:140
BurnoutCurrent
These bits select the magnitude of the sensor burnout detect current source.
Definition: ad7124.h:150
General namespace.
Definition: ad7124.h:24