ads1115  0.2.0
ADS1115::Config Struct Reference

#include "config.hpp"

Public Member Functions

 Config ()=default
 
 Config (const std::uint16_t bytes)
 
bool operator== (const Config &other) const =default
 
std::uint16_t to_bytes () const
 

Public Attributes

MUX mux = MUX::AIN0_AIN1
 
PGA pga = PGA::FS_2_048
 
MODE mode = MODE::SINGLE_CONV
 
DR data_rate = DR::SPS_128
 
COMP_MODE comp_mode = COMP_MODE::TRAD_COMP
 
COMP_POL comp_pol = COMP_POL::LOW
 
COMP_LAT comp_lat = COMP_LAT::NON_LATCHING
 
COMP_QUE comp_que = COMP_QUE::DISABLE_COMP
 

Detailed Description

The Config struct represents the config register of the ADS1115.

The config register of the ADS1115 is consists of 16 bit which configure the device. The members of this struct map to the configuration options described in the datasheet and can span more than one bit. A to_bytes() member function is provided to convert the struct to a std::uint16_t which can be writen to the config register of the ADS1115.

Definition at line 20 of file config.hpp.

Constructor & Destructor Documentation

◆ Config() [1/2]

ADS1115::Config::Config ( )
default

◆ Config() [2/2]

ADS1115::Config::Config ( const std::uint16_t  bytes)

Definition at line 11 of file config.cpp.

12  : mux(static_cast<MUX>(0x7000 & bytes)),
13  pga(static_cast<PGA>(0x0e00 & bytes)),
14  mode(static_cast<MODE>(0x0100 & bytes)),
15  data_rate(static_cast<DR>(0x00e0 & bytes)),
16  comp_mode(static_cast<COMP_MODE>(0x0010 & bytes)),
17  comp_pol(static_cast<COMP_POL>(0x0008 & bytes)),
18  comp_lat(static_cast<COMP_LAT>(0x0004 & bytes)),
19  comp_que(static_cast<COMP_QUE>(0x0003 & bytes))
20  {
21  }

Member Function Documentation

◆ operator==()

bool ADS1115::Config::operator== ( const Config other) const
default

◆ to_bytes()

std::uint16_t ADS1115::Config::to_bytes ( ) const

Converts the struct to a std::uint16_t which can be writen to the config register of the ADS1115.

Definition at line 23 of file config.cpp.

24  {
25  return static_cast<std::uint16_t>(mux) | static_cast<std::uint16_t>(pga) | static_cast<std::uint16_t>(mode)
26  | static_cast<std::uint16_t>(data_rate) | static_cast<std::uint16_t>(comp_mode)
27  | static_cast<std::uint16_t>(comp_pol) | static_cast<std::uint16_t>(comp_lat)
28  | static_cast<std::uint16_t>(comp_que);
29  }

References comp_lat, comp_mode, comp_pol, comp_que, data_rate, mode, mux, and pga.

Member Data Documentation

◆ comp_lat

COMP_LAT ADS1115::Config::comp_lat = COMP_LAT::NON_LATCHING

Definition at line 31 of file config.hpp.

Referenced by TEST(), and to_bytes().

◆ comp_mode

COMP_MODE ADS1115::Config::comp_mode = COMP_MODE::TRAD_COMP

Definition at line 29 of file config.hpp.

Referenced by TEST(), and to_bytes().

◆ comp_pol

COMP_POL ADS1115::Config::comp_pol = COMP_POL::LOW

Definition at line 30 of file config.hpp.

Referenced by TEST(), and to_bytes().

◆ comp_que

COMP_QUE ADS1115::Config::comp_que = COMP_QUE::DISABLE_COMP

Definition at line 32 of file config.hpp.

Referenced by TEST(), and to_bytes().

◆ data_rate

DR ADS1115::Config::data_rate = DR::SPS_128

Definition at line 28 of file config.hpp.

Referenced by TEST(), and to_bytes().

◆ mode

MODE ADS1115::Config::mode = MODE::SINGLE_CONV

Definition at line 27 of file config.hpp.

Referenced by TEST(), and to_bytes().

◆ mux

MUX ADS1115::Config::mux = MUX::AIN0_AIN1

Definition at line 25 of file config.hpp.

Referenced by TEST(), and to_bytes().

◆ pga

PGA ADS1115::Config::pga = PGA::FS_2_048

Definition at line 26 of file config.hpp.

Referenced by TEST(), and to_bytes().


The documentation for this struct was generated from the following files:
ADS1115::Config::comp_pol
COMP_POL comp_pol
Definition: config.hpp:30
ADS1115::Config::pga
PGA pga
Definition: config.hpp:26
ADS1115::Config::comp_lat
COMP_LAT comp_lat
Definition: config.hpp:31
ADS1115::Config::comp_que
COMP_QUE comp_que
Definition: config.hpp:32
ADS1115::PGA
PGA
Definition: parameters.hpp:58
ADS1115::COMP_MODE
COMP_MODE
Definition: parameters.hpp:105
ADS1115::Config::mux
MUX mux
Definition: config.hpp:25
ADS1115::MUX
MUX
Definition: parameters.hpp:43
ADS1115::MODE
MODE
Definition: parameters.hpp:75
ADS1115::COMP_QUE
COMP_QUE
Definition: parameters.hpp:140
ADS1115::COMP_POL
COMP_POL
Definition: parameters.hpp:116
ADS1115::DR
DR
Definition: parameters.hpp:84
ADS1115::Config::comp_mode
COMP_MODE comp_mode
Definition: config.hpp:29
ADS1115::Config::data_rate
DR data_rate
Definition: config.hpp:28
ADS1115::Config::mode
MODE mode
Definition: config.hpp:27
ADS1115::COMP_LAT
COMP_LAT
Definition: parameters.hpp:129