@@ -96,8 +96,10 @@ int AD7173Class::get_current_data_channel(register_t &channel) {
9696 /* get ADC status register */
9797 byte value[1 ];
9898 this ->get_register (STATUS_REG, value, 1 );
99+
99100 /* assign to return channel register value */
100101 channel = (register_t ) (value[0 ] & 0x0F );
102+
101103 /* return error code */
102104 return 0 ;
103105}
@@ -110,10 +112,10 @@ int AD7173Class::set_adc_mode_config(data_mode_t data_mode, clock_mode_t clock_m
110112 byte value[2 ] = {0x00 , 0x00 };
111113 value[1 ] = (data_mode << 4 ) | (clock_mode << 2 );
112114
113- /* update the desired adc_mode configuration */
115+ /* update the configuration value */
114116 this ->set_register (ADCMODE_REG, value, 2 );
115117
116- /* verify updated adc_mode configuration */
118+ /* verify the updated configuration value */
117119 this ->get_register (ADCMODE_REG, value, 2 );
118120
119121 /* return error code */
@@ -128,10 +130,10 @@ int AD7173Class::set_interface_mode_config(bool continuous_read) {
128130 byte value[2 ] = {0x00 , 0x00 };
129131 value[1 ] = (continuous_read << 7 );
130132
131- /* update the desired interface_mode configuration */
133+ /* update the configuration value */
132134 this ->set_register (IFMODE_REG, value, 2 );
133135
134- /* verify updated interface_mode configuration */
136+ /* verify the updated configuration value */
135137 this ->get_register (IFMODE_REG, value, 2 );
136138
137139 /* when continuous read mode */
@@ -207,10 +209,10 @@ int AD7173Class::set_channel_config(register_t channel, bool enable, register_t
207209 value[0 ] = (enable << 7 ) | (setup << 4 ) | (ain_pos >> 3 );
208210 value[1 ] = (ain_pos << 5 ) | ain_neg;
209211
210- /* update the desired channel configuration */
212+ /* update the configuration value */
211213 this ->set_register (channel, value, 2 );
212214
213- /* verify the updated channel configuration */
215+ /* verify the updated configuration value */
214216 this ->get_register (channel, value, 2 );
215217
216218 /* return error code */
@@ -225,10 +227,10 @@ int AD7173Class::set_setup_config(register_t setup, coding_mode_t coding_mode) {
225227 value[0 ] = (coding_mode << 4 );
226228 value[1 ] = 0x00 ;
227229
228- /* update the desired setup configuration */
230+ /* update the configuration value */
229231 this ->set_register (setup, value, 2 );
230232
231- /* verify the updated setup configuration */
233+ /* verify the updated configuration value */
232234 this ->get_register (setup, value, 2 );
233235
234236 /* return error code */
@@ -243,12 +245,31 @@ int AD7173Class::set_filter_config(register_t filter, data_rate_t data_rate) {
243245 /* SINC3_MAP0 [15], RESERVED [14:12], ENHFILTEN0 [11], ENHFILT0 [10:8], RESERVED [7], ORDER0 [6:5], ORD0 [4:0] */
244246 value[1 ] = data_rate;
245247
246- /* update the desired filter configuration */
248+ /* update the configuration value */
247249 this ->set_register (filter, value, 2 );
248250
249- /* verify updated filter configuration */
251+ /* verify the updated configuration value */
250252 this ->get_register (filter, value, 2 );
251253
254+ /* return error code */
255+ return 0 ;
256+ }
257+
258+ int AD7173Class::set_offset_config (register_t offset, uint32_t offset_value) {
259+ /* Address Range: 0x30 to 0x37, Reset: 0x0000, Name: OFFSET0 to OFFSET7 */
260+
261+ /* prepare the configuration value */
262+ byte value[3 ] = {0x00 , 0x00 , 0x00 };
263+ value[0 ] = offset_value;
264+ value[1 ] = offset_value >> 8 ;
265+ value[2 ] = offset_value >> 16 ;
266+
267+ /* update the configuration value */
268+ this ->set_register (offset, value, 3 );
269+
270+ /* verify the updated configuration value */
271+ this ->get_register (offset, value, 3 );
272+
252273 /* return error code */
253274 return 0 ;
254275}
0 commit comments