| 
    Data acquisition with the AD7705 on the raspberry PI
    
   | 
 
 
 
 
   21 #include <sys/ioctl.h> 
   22 #include <linux/types.h> 
   23 #include <linux/spi/spidev.h> 
  159     const uint8_t mode = SPI_CPHA | SPI_CPOL;
 
  160     const int drdy_GPIO = 22;
 
  161     const uint32_t speed = 500000;
 
  162     const uint16_t delay = 0;
 
  163     const uint8_t bpw   = 8;
 
  164     static constexpr 
float ADC_REF = 2.5;
 
  166     std::thread* daqThread = 
nullptr;
 
  171     int spi_transfer(
int fd, uint8_t* tx, uint8_t* rx, 
int n);
 
  172     void writeReset(
int fd);
 
  173     void writeReg(
int fd, uint8_t v);
 
  174     uint8_t readReg(
int fd);
 
  175     int16_t readData(
int fd);
 
  178         inline float pgaGain() {
 
  179         return (
float)(1 << ad7705settings.
pgaGain);
 
  182     inline uint8_t commReg() {
 
  183         return ((uint8_t)(ad7705settings.
channel));
 
  186     static int getSysfsIRQfd(
int gpio);
 
  187     static int fdPoll(
int gpio_fd, 
int timeout);
 
  188     static void gpio_unexport(
int gpio);
 
  
 
This class reads data from the AD7705 in the background (separate thread) and calls a callback functi...
Definition: AD7705Comm.h:121
 
void registerCallback(AD7705callback *cb)
Registers the callback which is called whenever there is a sample.
 
Callback for new samples which needs to be implemented by the main program.
Definition: AD7705Comm.h:36
 
void start()
Starts the data acquisition.
 
AIN channel
Requested input channel (0 or 1)
Definition: AD7705Comm.h:100
 
virtual void hasSample(float sample)=0
Called after a sample has arrived.
 
PGAGains pgaGain
Requested gain.
Definition: AD7705Comm.h:87
 
void unRegisterCallback()
Unregisters the callback to the callback interface.
 
~AD7705Comm()
Destructor which makes sure the data acquisition has stopped.
 
Contains all settings for the data acquisition.
Definition: AD7705Comm.h:49
 
SamplingRates samplingRate
Sampling rate requested.
Definition: AD7705Comm.h:68
 
void stop()
Stops the data acquistion.
 
PGAGains
Gains of the PGA.
Definition: AD7705Comm.h:73
 
std::string spiDevice
The SPI device in /dev used.
Definition: AD7705Comm.h:53
 
AD7705Comm(AD7705settings settings)
Constructor.
 
AIN
Channel indices.
Definition: AD7705Comm.h:92
 
Modes
Unipolar or bipolar mode.
Definition: AD7705Comm.h:105
 
SamplingRates
Sampling rates.
Definition: AD7705Comm.h:58
 
Modes mode
Unipolar or biploar.
Definition: AD7705Comm.h:113