@@ -65,7 +65,7 @@ bool SfeADS1219Driver::setConversionMode(const ads1219_conversion_mode_config_t
65
65
sfe_ads1219_reg_cfg_t config;
66
66
if (_theBus->readRegisterByte (kSfeADS1219RegConfigRead , config.byte ) != kSTkErrOk ) // Read the config register
67
67
return false ;
68
- config.cm = (uint8_t )mode; // Modify (only) the conversion mode
68
+ config.cm = (uint8_t )mode; // Modify (only) the conversion mode
69
69
return (_theBus->writeRegisterByte (kSfeADS1219RegConfigWrite , config.byte ) == kSTkErrOk ); // Write the config register
70
70
}
71
71
@@ -76,7 +76,7 @@ bool SfeADS1219Driver::setInputMultiplexer(const ads1219_input_multiplexer_confi
76
76
sfe_ads1219_reg_cfg_t config;
77
77
if (_theBus->readRegisterByte (kSfeADS1219RegConfigRead , config.byte ) != kSTkErrOk ) // Read the config register
78
78
return false ;
79
- config.mux = (uint8_t )mux; // Modify (only) the input multiplexer
79
+ config.mux = (uint8_t )mux; // Modify (only) the input multiplexer
80
80
return (_theBus->writeRegisterByte (kSfeADS1219RegConfigWrite , config.byte ) == kSTkErrOk ); // Write the config register
81
81
}
82
82
@@ -87,8 +87,8 @@ bool SfeADS1219Driver::setGain(const ads1219_gain_config_t gain)
87
87
sfe_ads1219_reg_cfg_t config;
88
88
if (_theBus->readRegisterByte (kSfeADS1219RegConfigRead , config.byte ) != kSTkErrOk ) // Read the config register
89
89
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
92
92
return (_theBus->writeRegisterByte (kSfeADS1219RegConfigWrite , config.byte ) == kSTkErrOk ); // Write the config register
93
93
}
94
94
@@ -99,7 +99,7 @@ bool SfeADS1219Driver::setDataRate(const ads1219_data_rate_config_t rate)
99
99
sfe_ads1219_reg_cfg_t config;
100
100
if (_theBus->readRegisterByte (kSfeADS1219RegConfigRead , config.byte ) != kSTkErrOk ) // Read the config register
101
101
return false ;
102
- config.dr = (uint8_t )rate; // Modify (only) the data rate
102
+ config.dr = (uint8_t )rate; // Modify (only) the data rate
103
103
return (_theBus->writeRegisterByte (kSfeADS1219RegConfigWrite , config.byte ) == kSTkErrOk ); // Write the config register
104
104
}
105
105
@@ -110,7 +110,7 @@ bool SfeADS1219Driver::setVoltageReference(const ads1219_vref_config_t vRef)
110
110
sfe_ads1219_reg_cfg_t config;
111
111
if (_theBus->readRegisterByte (kSfeADS1219RegConfigRead , config.byte ) != kSTkErrOk ) // Read the config register
112
112
return false ;
113
- config.vref = (uint8_t )vRef; // Modify (only) the voltage reference
113
+ config.vref = (uint8_t )vRef; // Modify (only) the voltage reference
114
114
return (_theBus->writeRegisterByte (kSfeADS1219RegConfigWrite , config.byte ) == kSTkErrOk ); // Write the config register
115
115
}
116
116
@@ -126,7 +126,8 @@ bool SfeADS1219Driver::readConversion()
126
126
if (result)
127
127
{
128
128
// Data is 3-bytes (24-bits), big-endian (MSB first).
129
- union {
129
+ union
130
+ {
130
131
int32_t i32 ;
131
132
uint32_t u32 ;
132
133
} iu32; // Use a union to avoid signed / unsigned ambiguity
@@ -174,18 +175,19 @@ bool SfeADS1219Driver::dataReady(void)
174
175
}
175
176
176
177
// / @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.
178
179
// / @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)
180
181
{
181
- return (_theBus->readRegisterByte (kSfeADS1219RegConfigRead , config-> byte ) == kSTkErrOk ); // Read the config register
182
+ return (_theBus->readRegisterByte (kSfeADS1219RegConfigRead , config. byte ) == kSTkErrOk ); // Read the config register
182
183
}
183
184
184
185
// / @brief Write a sfe_ads1219_reg_cfg_t struct into the ADS1219 Configuration Register.
185
186
// / @param config A sfe_ads1219_reg_cfg_t struct holding the register contents.
186
187
// / @return True if successful, false otherwise.
187
188
bool SfeADS1219Driver::setConfigurationRegister (sfe_ads1219_reg_cfg_t config)
188
189
{
190
+ _adcGain = config.gain ; // Update the local copy of the gain for voltage conversion
189
191
return (_theBus->writeRegisterByte (kSfeADS1219RegConfigWrite , config.byte ) == kSTkErrOk ); // Write the config register
190
192
}
191
193
0 commit comments