@@ -119,13 +119,14 @@ LOG_MODULE_REGISTER(adc_ad7124, CONFIG_ADC_LOG_LEVEL);
119
119
#define AD7124_ADC_CTRL_REG_MODE_MSK GENMASK(5, 2)
120
120
121
121
/* IO Control 1 register bits */
122
+ #define AD7124_IO_CONTROL_1_REG_PDSW_EN BIT(15)
122
123
#define AD7124_IOUT1_CURRENT_MSK GENMASK(13, 11)
123
124
#define AD7124_IOUT0_CURRENT_MSK GENMASK(10, 8)
124
125
#define AD7124_IOUT1_CHANNEL_MSK GENMASK(7, 4)
125
126
#define AD7124_IOUT0_CHANNEL_MSK GENMASK(3, 0)
126
127
#define AD7124_IOUT_MSK \
127
- (AD7124_IOUT1_CURRENT_MSK | AD7124_IOUT0_CURRENT_MSK | AD7124_IOUT1_CHANNEL_MSK | \
128
- AD7124_IOUT0_CHANNEL_MSK)
128
+ (AD7124_IO_CONTROL_1_REG_PDSW_EN, AD7124_IOUT1_CURRENT_MSK | AD7124_IOUT0_CURRENT_MSK | \
129
+ AD7124_IOUT1_CHANNEL_MSK | AD7124_IOUT0_CHANNEL_MSK)
129
130
130
131
/* Current source configuration bits */
131
132
#define AD7124_CURRENT_SOURCE_IOUT_MSK BIT(3)
@@ -264,6 +265,7 @@ struct adc_ad7124_config {
264
265
enum ad7124_device_type active_device ;
265
266
uint8_t resolution ;
266
267
bool ref_en ;
268
+ bool pdsw_en ;
267
269
};
268
270
269
271
struct adc_ad7124_data {
@@ -710,6 +712,7 @@ static int adc_ad7124_setup_cfg(const struct device *dev, const struct ad7124_ch
710
712
int configuration_setup = 0 ;
711
713
int configuration_mask = 0 ;
712
714
int ref_internal = 0 ;
715
+ int pd_switch = 0 ;
713
716
714
717
if (cfg -> props .bipolar ) {
715
718
configuration_setup |= AD7124_CFG_REG_BIPOLAR ;
@@ -737,6 +740,10 @@ static int adc_ad7124_setup_cfg(const struct device *dev, const struct ad7124_ch
737
740
ref_internal = AD7124_ADC_CTRL_REG_REF_EN ;
738
741
}
739
742
743
+ if (config -> pdsw_en ) {
744
+ pd_switch = AD7124_IO_CONTROL_1_REG_PDSW_EN ;
745
+ }
746
+
740
747
if (cfg -> props .refsel == INTERNAL_REF ) {
741
748
ret = adc_ad7124_reg_write_msk (dev , AD7124_ADC_CONTROL , AD7124_ADC_CONTROL_REG_LEN ,
742
749
ref_internal , AD7124_ADC_CTRL_REG_REF_EN );
@@ -745,6 +752,12 @@ static int adc_ad7124_setup_cfg(const struct device *dev, const struct ad7124_ch
745
752
}
746
753
}
747
754
755
+ ret = adc_ad7124_reg_write_msk (dev , AD7124_IO_CONTROL_1 , AD7124_IO_CONTROL_1_REG_LEN ,
756
+ pd_switch , AD7124_IO_CONTROL_1_REG_PDSW_EN );
757
+ if (ret ) {
758
+ return ret ;
759
+ }
760
+
748
761
return 0 ;
749
762
}
750
763
@@ -1447,6 +1460,7 @@ static DEVICE_API(adc, adc_ad7124_api) = {
1447
1460
.power_mode = DT_INST_PROP(inst, power_mode), \
1448
1461
.active_device = DT_INST_PROP(inst, active_device), \
1449
1462
.ref_en = DT_INST_PROP(inst, reference_enable), \
1463
+ .pdsw_en = DT_INST_PROP(inst, pd_switch_enable), \
1450
1464
}; \
1451
1465
static struct adc_ad7124_data adc_ad7124_data##inst = { \
1452
1466
ADC_CONTEXT_INIT_LOCK(adc_ad7124_data##inst, ctx), \
0 commit comments