@@ -65,7 +65,7 @@ bool SfeADS1219Driver::setConversionMode(const ads1219_conversion_mode_config_t
6565 sfe_ads1219_reg_cfg_t config;
6666 if (_theBus->readRegisterByte (kSfeADS1219RegConfigRead , config.byte ) != kSTkErrOk ) // Read the config register
6767 return false ;
68- config.cm = (uint8_t )mode; // Modify (only) the conversion mode
68+ config.cm = (uint8_t )mode; // Modify (only) the conversion mode
6969 return (_theBus->writeRegisterByte (kSfeADS1219RegConfigWrite , config.byte ) == kSTkErrOk ); // Write the config register
7070}
7171
@@ -76,7 +76,7 @@ bool SfeADS1219Driver::setInputMultiplexer(const ads1219_input_multiplexer_confi
7676 sfe_ads1219_reg_cfg_t config;
7777 if (_theBus->readRegisterByte (kSfeADS1219RegConfigRead , config.byte ) != kSTkErrOk ) // Read the config register
7878 return false ;
79- config.mux = (uint8_t )mux; // Modify (only) the input multiplexer
79+ config.mux = (uint8_t )mux; // Modify (only) the input multiplexer
8080 return (_theBus->writeRegisterByte (kSfeADS1219RegConfigWrite , config.byte ) == kSTkErrOk ); // Write the config register
8181}
8282
@@ -87,8 +87,8 @@ bool SfeADS1219Driver::setGain(const ads1219_gain_config_t gain)
8787 sfe_ads1219_reg_cfg_t config;
8888 if (_theBus->readRegisterByte (kSfeADS1219RegConfigRead , config.byte ) != kSTkErrOk ) // Read the config register
8989 return false ;
90- config.gain = (uint8_t )gain; // Modify (only) the gain
91- _adcGain = gain; // Update the local copy of the gain for voltage conversion
90+ config.gain = (uint8_t )gain; // Modify (only) the gain
91+ _adcGain = gain; // Update the local copy of the gain for voltage conversion
9292 return (_theBus->writeRegisterByte (kSfeADS1219RegConfigWrite , config.byte ) == kSTkErrOk ); // Write the config register
9393}
9494
@@ -99,7 +99,7 @@ bool SfeADS1219Driver::setDataRate(const ads1219_data_rate_config_t rate)
9999 sfe_ads1219_reg_cfg_t config;
100100 if (_theBus->readRegisterByte (kSfeADS1219RegConfigRead , config.byte ) != kSTkErrOk ) // Read the config register
101101 return false ;
102- config.dr = (uint8_t )rate; // Modify (only) the data rate
102+ config.dr = (uint8_t )rate; // Modify (only) the data rate
103103 return (_theBus->writeRegisterByte (kSfeADS1219RegConfigWrite , config.byte ) == kSTkErrOk ); // Write the config register
104104}
105105
@@ -110,7 +110,7 @@ bool SfeADS1219Driver::setVoltageReference(const ads1219_vref_config_t vRef)
110110 sfe_ads1219_reg_cfg_t config;
111111 if (_theBus->readRegisterByte (kSfeADS1219RegConfigRead , config.byte ) != kSTkErrOk ) // Read the config register
112112 return false ;
113- config.vref = (uint8_t )vRef; // Modify (only) the voltage reference
113+ config.vref = (uint8_t )vRef; // Modify (only) the voltage reference
114114 return (_theBus->writeRegisterByte (kSfeADS1219RegConfigWrite , config.byte ) == kSTkErrOk ); // Write the config register
115115}
116116
@@ -126,7 +126,8 @@ bool SfeADS1219Driver::readConversion()
126126 if (result)
127127 {
128128 // Data is 3-bytes (24-bits), big-endian (MSB first).
129- union {
129+ union
130+ {
130131 int32_t i32 ;
131132 uint32_t u32 ;
132133 } iu32; // Use a union to avoid signed / unsigned ambiguity
@@ -174,18 +175,19 @@ bool SfeADS1219Driver::dataReady(void)
174175}
175176
176177// / @brief Read the ADS1219 Configuration Register into a sfe_ads1219_reg_cfg_t struct.
177- // / @param config Pointer to the sfe_ads1219_reg_cfg_t struct to hold the register contents.
178+ // / @param config Reference of a sfe_ads1219_reg_cfg_t struct to hold the register contents.
178179// / @return True if successful, false otherwise.
179- bool SfeADS1219Driver::getConfigurationRegister (sfe_ads1219_reg_cfg_t * config)
180+ bool SfeADS1219Driver::getConfigurationRegister (sfe_ads1219_reg_cfg_t & config)
180181{
181- return (_theBus->readRegisterByte (kSfeADS1219RegConfigRead , config-> byte ) == kSTkErrOk ); // Read the config register
182+ return (_theBus->readRegisterByte (kSfeADS1219RegConfigRead , config. byte ) == kSTkErrOk ); // Read the config register
182183}
183184
184185// / @brief Write a sfe_ads1219_reg_cfg_t struct into the ADS1219 Configuration Register.
185186// / @param config A sfe_ads1219_reg_cfg_t struct holding the register contents.
186187// / @return True if successful, false otherwise.
187188bool SfeADS1219Driver::setConfigurationRegister (sfe_ads1219_reg_cfg_t config)
188189{
190+ _adcGain = config.gain ; // Update the local copy of the gain for voltage conversion
189191 return (_theBus->writeRegisterByte (kSfeADS1219RegConfigWrite , config.byte ) == kSTkErrOk ); // Write the config register
190192}
191193
0 commit comments