190 bool busyWait_ =
false, int16_t tempDivider_ = 100);
205 bool init()
override;
303 void readChannel(int8_t nextChannel, int8_t prevChannel);
308 void readChannel(int8_t channel);
310 int8_t findNextEnabledChannel(int8_t startChannel);
316 bool configCheck =
false;
325 uint8_t lastConfigIndex = 0;
328 const uint16_t tempDivider;
330 uint16_t sampleCounter = 0;
333 const float PGA_LSB_SIZE[6] = {0.187, 0.125, 0.0625,
334 0.03125, 0.015625, 0.0078125};
337 const int CONV_TIME[8] = {125000, 62500, 31250, 15625,
338 7813, 4000, 2106, 1163};
340 static constexpr float TEMP_LSB_SIZE = 0.03125;
341 static constexpr uint16_t TEMP_CONFIG = 0xF281;
347 static constexpr uint16_t CONFIG_MASK = 0xFE7F;
TemperatureData getTemperature()
Returns the last temperature value.
TemperatureData readTemperatureAndWait()
Reads on the fly the temperature.
int getConversionTime(int8_t channel)
Returns the conversion time in us for the specified channel.
ADS1118Data getVoltage(ADS1118Mux mux)
Returns the last read voltage value for the specified channel.
static constexpr int8_t NUM_OF_CHANNELS
void enableConfigCheck()
Enables the configuration check after it's writing to the device.
@ FSR_0_512
FSR is ±0.512 V.
@ FSR_0_256
FSR is ±0.256 V.
@ FSR_1_024
FSR is ±1.024 V.
@ FSR_4_096
FSR is ±4.096 V.
@ FSR_2_048
FSR is ±2.048 V (default)
@ FSR_6_144
FSR is ±6.144 V.
ADS1118(SPIBusInterface &bus, miosix::GpioPin cs, ADS1118Config config_, SPIBusConfig spiConfig=getDefaultSPIConfig())
Construct a new ADS1118 object specifying spi bus, spi config and cs pin as well as device configurat...
void disableConfigCheck()
Disables the configuration check after it's writing to the device.
void enablePullUpResistor()
@ MUX_AIN0_AIN3
AINp is AIN0 and AINn is AIN3.
@ MUX_AIN1_GND
AINp is AIN1 and AINn is GND.
@ MUX_AIN3_GND
AINp is AIN3 and AINn is GND.
@ MUX_AIN2_GND
AINp is AIN2 and AINn is GND.
@ MUX_AIN1_AIN3
AINp is AIN1 and AINn is AIN3.
@ MUX_AIN0_AIN1
AINp is AIN0 and AINn is AIN1 (default)
@ MUX_AIN0_GND
AINp is AIN0 and AINn is GND.
@ MUX_AIN2_AIN3
AINp is AIN2 and AINn is AIN3.
@ PULL_UP_DIS
Pullup resistor disabled on DOUT pin.
@ PULL_UP_EN
Pullup resistor enabled on DOUT pin (default)
@ CONTINUOUS_CONV_MODE
Continuous-conversion mode.
@ SINGLE_SHOT_MODE
Power-down and single-shot mode (default)
ADS1118Data sampleImpl() override
Reads the previously configured channel while writing the next enabled configuration.
void disablePullUpResistor()
static constexpr uint8_t VALID_OPERATION
Indicates a valid configuration.
bool selfTest() override
Writes the temperature configuration and check if it is read back correctly.
void enableInput(ADS1118Mux mux)
Enables the sapling of a specific mux configuration with the main configuration specified in the cons...
void disableInput(ADS1118Mux mux)
static const ADS1118Config ADS1118_DEFAULT_CONFIG
Default configuration.
bool init() override
Initialize the configuration.
ADS1118Data readInputAndWait(ADS1118Mux mux)
Reads on the fly the specified input.
@ DR_128
128 SPS (default)
@ TEMP_SENSOR_MODE
Temperature sensor mode.
@ ADC_MODE
ADC mode (default)
void disableTemperature()
static SPIBusConfig getDefaultSPIConfig()
static constexpr int8_t TEMP_CHANNEL
Temperature channel number.
static constexpr int8_t INVALID_CHANNEL
Interface for low level access of a SPI bus as a master.
Base sensor class with has to be extended by any sensor driver.
This file includes all the types the logdecoder script will decode.
SPI Bus configuration for a specific slave.
Contains information about a single SPI slave device.
Structure of configuration word.
ADS1118PullUp pullUp
Pullup enable.
ADS1118DataRate rate
Data rate.
ADS1118Mode mode
Device operating mode.
ADS1118Pga pga
Programmable gain amplifier configuration.
struct Boardcore::ADS1118::ADS1118Config::@0 bits
Includes all the configuration bits.
uint8_t singleShot
Single-shot conversion start.
ADS1118TempMode tempMode
Temperature sensor mode.
struct Boardcore::ADS1118::ADS1118Config::@1 byte
Includes the msb and lsb bytes.
uint8_t reserved
Reserved, doesn't matter.
uint8_t noOp
No operation.
uint16_t word
Representation in word (16-bits) format.
ADS1118Mux mux
Input multiplexer configuration.