Skip to content

Commit 9a517d3

Browse files
committed
drivers: adc: ad7124: Add burnout current source support
Add support for burnout sources in the devicetree and adc configuration structure. Implement the burnout current source for the adi,ad7124. Signed-off-by: Florin Berger <florin@fam-berger.ch>
1 parent 697705e commit 9a517d3

File tree

6 files changed

+42
-0
lines changed

6 files changed

+42
-0
lines changed

‎drivers/adc/Kconfig‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ config ADC_CONFIGURABLE_EXCITATION_CURRENT_SOURCE_PIN
3838
config ADC_CONFIGURABLE_VBIAS_PIN
3939
bool
4040

41+
# By selecting or not this option particular ADC drivers indicate if they
42+
# support configurable burnout current sources
43+
config ADC_CONFIGURABLE_BURNOUT_SOURCE
44+
bool
45+
4146
config ADC_ASYNC
4247
bool "Asynchronous call support"
4348
select POLL

‎drivers/adc/Kconfig.ad7124‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ config ADC_AD7124
99
select CRC
1010
select ADC_CONFIGURABLE_INPUTS
1111
select ADC_CONFIGURABLE_EXCITATION_CURRENT_SOURCE_PIN
12+
select ADC_CONFIGURABLE_BURNOUT_SOURCE
1213
help
1314
Enable the ad7124 adc
1415

‎drivers/adc/adc_ad7124.c‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ LOG_MODULE_REGISTER(adc_ad7124, CONFIG_ADC_LOG_LEVEL);
136136
/* Error register bits */
137137
#define AD7124_ERR_REG_SPI_IGNORE_ERR BIT(6)
138138

139+
/* Burnout current source configuration bits */
140+
#define AD7124_BURNOUT_CURRENT_SOURCE_MSK GENMASK(10, 9)
141+
139142
enum ad7124_register_lengths {
140143
AD7124_STATUS_REG_LEN = 1,
141144
AD7124_ADC_CONTROL_REG_LEN = 2,
@@ -232,6 +235,13 @@ enum ad7124_iout_channel {
232235
AD7124_IOUT_AIN7 = 15,
233236
};
234237

238+
enum ad7124_burnout_current_strength {
239+
AD7124_BURNOUT_OFF = 0,
240+
AD7124_BURNOUT_0_5_UA = 1,
241+
AD7124_BURNOUT_2_UA = 2,
242+
AD7124_BURNOUT_4_UA = 3
243+
};
244+
235245
struct ad7124_current_source_config {
236246
enum ad7124_iout_current current;
237247
enum ad7124_iout_channel channel;
@@ -241,6 +251,7 @@ struct ad7124_config_props {
241251
enum ad7124_reference_source refsel;
242252
enum ad7124_gain pga_bits;
243253
enum ad7124_filter_type filter_type;
254+
enum ad7124_burnout_current_strength burnout_strength;
244255
uint16_t odr_sel_bits;
245256
bool bipolar;
246257
bool inbuf_enable;
@@ -464,6 +475,7 @@ static int adc_ad7124_create_new_cfg(const struct device *dev, const struct adc_
464475
new_cfg->props.filter_type = AD7124_FILTER_SINC4;
465476
}
466477

478+
new_cfg->props.burnout_strength = cfg->burnout_source_strength;
467479
new_cfg->props.odr_sel_bits = adc_ad7124_odr_to_fs(dev, odr);
468480
new_cfg->props.bipolar = config->bipolar_mask & BIT(cfg->channel_id);
469481
new_cfg->props.inbuf_enable = config->inbuf_enable_mask & BIT(cfg->channel_id);
@@ -725,6 +737,8 @@ static int adc_ad7124_setup_cfg(const struct device *dev, const struct ad7124_ch
725737

726738
configuration_setup |= FIELD_PREP(AD7124_SETUP_CONF_REG_REF_SEL_MSK, cfg->props.refsel);
727739
configuration_setup |= FIELD_PREP(AD7124_SETUP_CONF_PGA_MSK, cfg->props.pga_bits);
740+
configuration_setup |=
741+
FIELD_PREP(AD7124_BURNOUT_CURRENT_SOURCE_MSK, cfg->props.burnout_strength);
728742
configuration_mask |= AD7124_SETUP_CONFIGURATION_MASK;
729743

730744
ret = adc_ad7124_reg_write_msk(dev, AD7124_CONFIG(cfg->cfg_slot), AD7124_CONFIG_REG_LEN,

‎dts/bindings/adc/adc-controller.yaml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,3 +169,10 @@ child-binding:
169169
Output pin selection for the bias voltage. The actual interpretation
170170
depends on the driver. This is used only for drivers which select
171171
the ADC_CONFIGURABLE_VBIAS_PIN Kconfig option.
172+
173+
zephyr,burnout-source-strength:
174+
type: int
175+
description: |
176+
Selection of burnout current source strength. The actual interpretation
177+
depends on the driver. This is used only for drivers which select the
178+
ADC_CONFIGURABLE_BURNOUT_SOURCE Kconfig option.

‎include/zephyr/drivers/adc.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,16 @@ struct adc_channel_cfg {
196196
*/
197197
uint32_t vbias_pins;
198198
#endif /* CONFIG_ADC_CONFIGURABLE_VBIAS_PIN */
199+
200+
#ifdef CONFIG_ADC_CONFIGURABLE_BURNOUT_SOURCE
201+
/**
202+
* Drive strength for burnout sources.
203+
* This is only available if the driver enables the feature
204+
* via the hidden configuration option ADC_CONFIGURABLE_BURNOUT_SOURCE.
205+
* The interpretation of this field is dependent on the driver.
206+
*/
207+
uint8_t burnout_source_strength;
208+
#endif /* CONFIG_ADC_CONFIGURABLE_BURNOUT_SOURCE */
199209
};
200210

201211
/**

‎include/zephyr/dt-bindings/adc/ad7124-adc.h‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,9 @@
6666
#define AD7124_IOUT_CH_AIN6 0E
6767
#define AD7124_IOUT_CH_AIN7 0F
6868

69+
#define AD7124_BURNOUT_OFF 00
70+
#define AD7124_BURNOUT_0_5_UA 01
71+
#define AD7124_BURNOUT_2_UA 02
72+
#define AD7124_BURNOUT_4_UA 03
73+
6974
#endif /* ZEPHYR_INCLUDE_DT_BINDINGS_AD7124_ADC_H_ */

0 commit comments

Comments
 (0)