Skip to content

Commit aed1f1a

Browse files
feilongflcarlescufi
authored andcommitted
drivers: gd32_adc: add support for gd32a50x series.
add support for gd32a50x series. Signed-off-by: YuLong Yao <[email protected]>
1 parent 2a01321 commit aed1f1a

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

drivers/adc/adc_gd32.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,20 @@ static const uint32_t table_samp_time[] = {
9898
SMP_TIME(71),
9999
SMP_TIME(239),
100100
};
101+
#elif defined(CONFIG_SOC_SERIES_GD32A50X)
102+
#define SMP_TIME(x) ADC_SAMPLETIME_##x##POINT5
103+
104+
static const uint16_t acq_time_tbl[8] = {3, 15, 28, 56, 84, 112, 144, 480};
105+
static const uint32_t table_samp_time[] = {
106+
SMP_TIME(2),
107+
SMP_TIME(14),
108+
SMP_TIME(27),
109+
SMP_TIME(55),
110+
SMP_TIME(83),
111+
SMP_TIME(111),
112+
SMP_TIME(143),
113+
SMP_TIME(479)
114+
};
101115
#else
102116
#define SMP_TIME(x) ADC_SAMPLETIME_##x##POINT5
103117

@@ -289,7 +303,8 @@ static int adc_gd32_start_read(const struct device *dev,
289303
defined(CONFIG_SOC_SERIES_GD32L23X)
290304
ADC_CTL0(cfg->reg) &= ~ADC_CTL0_DRES;
291305
ADC_CTL0(cfg->reg) |= CTL0_DRES(resolution_id);
292-
#elif defined(CONFIG_SOC_SERIES_GD32F403)
306+
#elif defined(CONFIG_SOC_SERIES_GD32F403) || \
307+
defined(CONFIG_SOC_SERIES_GD32A50X)
293308
ADC_OVSAMPCTL(cfg->reg) &= ~ADC_OVSAMPCTL_DRES;
294309
ADC_OVSAMPCTL(cfg->reg) |= OVSAMPCTL_DRES(resolution_id);
295310
#elif defined(CONFIG_SOC_SERIES_GD32VF103)
@@ -384,6 +399,11 @@ static int adc_gd32_init(const struct device *dev)
384399
ADC_CTL1(cfg->reg) |= ADC_CTL1_ETERC;
385400
#endif
386401

402+
#ifdef CONFIG_SOC_SERIES_GD32A50X
403+
ADC_CTL1(cfg->reg) |= ADC_CTL1_ETSRC;
404+
ADC_CTL1(cfg->reg) |= ADC_CTL1_ETERC;
405+
#endif
406+
387407
/* Enable ADC */
388408
ADC_CTL1(cfg->reg) |= ADC_CTL1_ADCON;
389409

0 commit comments

Comments
 (0)