@@ -82,7 +82,7 @@ bool SfeADS1219Driver::setInputMultiplexer(const ads1219_input_multiplexer_confi
8282
8383// / @brief Configure the gain.
8484// / @return True if successful, false otherwise.
85- bool setGain (const ads1219_gain_config_t gain)
85+ bool SfeADS1219Driver:: setGain (const ads1219_gain_config_t gain)
8686{
8787 sfe_ads1219_reg_cfg_t config;
8888 if (_theBus->readRegisterByte (kSfeADS1219RegConfigRead , config.byte ) != kSTkErrOk ) // Read the config register
@@ -94,7 +94,7 @@ bool setGain(const ads1219_gain_config_t gain)
9494
9595// / @brief Configure the data rate (samples per second).
9696// / @return True if successful, false otherwise.
97- bool setDataRate (const ads1219_data_rate_config_t rate)
97+ bool SfeADS1219Driver:: setDataRate (const ads1219_data_rate_config_t rate)
9898{
9999 sfe_ads1219_reg_cfg_t config;
100100 if (_theBus->readRegisterByte (kSfeADS1219RegConfigRead , config.byte ) != kSTkErrOk ) // Read the config register
@@ -105,7 +105,7 @@ bool setDataRate(const ads1219_data_rate_config_t rate)
105105
106106// / @brief Configure the voltage reference.
107107// / @return True if successful, false otherwise.
108- bool setVoltageReference (const ads1219_vref_config_t vRef)
108+ bool SfeADS1219Driver:: setVoltageReference (const ads1219_vref_config_t vRef)
109109{
110110 sfe_ads1219_reg_cfg_t config;
111111 if (_theBus->readRegisterByte (kSfeADS1219RegConfigRead , config.byte ) != kSTkErrOk ) // Read the config register
@@ -120,7 +120,9 @@ bool setVoltageReference(const ads1219_vref_config_t vRef)
120120bool SfeADS1219Driver::readConversion ()
121121{
122122 uint8_t rawBytes[3 ];
123- bool result = (_theBus->readRegisterRegion (kSfeADS1219CommandReadData , (uint8_t *)rawBytes, 3 ) == 3 );
123+ size_t readBytes;
124+ bool result = (_theBus->readRegisterRegion (kSfeADS1219CommandReadData , (uint8_t *)rawBytes, 3 , readBytes) == kSTkErrOk );
125+ result = result && (readBytes == 3 ); // Check three bytes were returned
124126 if (result)
125127 {
126128 // Data is 3-bytes (24-bits), big-endian (MSB first).
@@ -166,6 +168,24 @@ bool SfeADS1219Driver::dataReady(void)
166168 return (result && (status.drdy == 1 ));
167169}
168170
171+ // / @brief Read the ADS1219 Configuration Register into a sfe_ads1219_reg_cfg_t struct.
172+ // / @param config Pointer to the sfe_ads1219_reg_cfg_t struct to hold the register contents.
173+ // / @return True if successful, false otherwise.
174+ bool SfeADS1219Driver::getConfigurationRegister (sfe_ads1219_reg_cfg_t *config)
175+ {
176+ return (_theBus->readRegisterByte (kSfeADS1219RegConfigRead , config->byte ) == kSTkErrOk ); // Read the config register
177+ }
178+
179+ // / @brief Write a sfe_ads1219_reg_cfg_t struct into the ADS1219 Configuration Register.
180+ // / @param config A sfe_ads1219_reg_cfg_t struct holding the register contents.
181+ // / @return True if successful, false otherwise.
182+ bool SfeADS1219Driver::setConfigurationRegister (sfe_ads1219_reg_cfg_t config)
183+ {
184+ return (_theBus->writeRegisterByte (kSfeADS1219RegConfigWrite , config.byte ) == kSTkErrOk ); // Write the config register
185+ }
186+
187+ // / @brief PRIVATE: update the local pointer to the I2C bus.
188+ // / @param theBus Pointer to the bus object.
169189void SfeADS1219Driver::setCommunicationBus (sfeTkArdI2C *theBus)
170190{
171191 _theBus = theBus;
0 commit comments