Skip to content

Commit ed01677

Browse files
CYFS3wdfk-prog
authored andcommitted
fix[ADC V2]: resolve ADC V1 compatibility Kconfig loop
1 parent 00e9c8d commit ed01677

9 files changed

Lines changed: 32 additions & 28 deletions

File tree

bsp/stm32/libraries/HAL_Drivers/drivers/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ endif
2626

2727
menuconfig BSP_USING_ADC_V2
2828
bool "Enable ADC V2"
29+
select RT_USING_ADC
2930
select RT_USING_ADC_V2
30-
depends on !RT_USING_ADC
3131
default n
3232

3333
if BSP_USING_ADC_V2

bsp/stm32/libraries/HAL_Drivers/drivers/SConscript

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ if GetDepend(['RT_USING_I2C']):
4646
if GetDepend(['BSP_USING_ETH', 'RT_USING_LWIP']) and not GetDepend(['SOC_STM32H750_ARTPI']):
4747
src += ['drv_eth.c']
4848

49-
if GetDepend(['RT_USING_ADC']):
49+
if GetDepend(['RT_USING_ADC']) and not GetDepend(['RT_USING_ADC_V2']):
5050
src += ['drv_adc.c']
5151

5252
if GetDepend(['BSP_USING_ADC_V2']):

components/drivers/adc/Kconfig

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
1-
menuconfig RT_USING_ADC_V2
2-
bool "Using ADC V2 device drivers"
3-
depends on !RT_USING_ADC
1+
menuconfig RT_USING_ADC
2+
bool "Using ADC device drivers"
43
default n
5-
help
6-
Enable the standalone ADC V2 framework. ADC V2 currently uses the
7-
legacy ADC public namespace, so it cannot be enabled together with
8-
RT_USING_ADC.
4+
5+
if RT_USING_ADC
6+
config RT_USING_ADC_V2
7+
bool "Using ADC V2 device drivers"
8+
default n
9+
help
10+
Enable the standalone ADC V2 framework. ADC V2 uses the legacy ADC
11+
public namespace, so it cannot be enabled together with ADC V1.
12+
13+
config RT_USING_ADC_V1
14+
bool
15+
default y if !RT_USING_ADC_V2
16+
17+
if RT_USING_DM && RT_USING_ADC_V1
18+
osource "$(SOC_DM_ADC_DIR)/Kconfig"
19+
endif
920

1021
if RT_USING_ADC_V2
1122

@@ -107,3 +118,4 @@ config RT_ADC_V2_USING_MSH
107118

108119
endif
109120

121+
endif

components/drivers/adc/SConscript

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ from building import *
33
cwd = GetCurrentDir()
44
src = []
55
CPPPATH = [cwd + '/../include']
6+
group = []
7+
8+
if GetDepend(['RT_USING_ADC']) and not GetDepend(['RT_USING_ADC_V2']):
9+
src += ['adc.c']
610

711
if GetDepend(['RT_USING_ADC_V2']):
812
src += ['adc_v2.c']
@@ -13,6 +17,7 @@ if GetDepend(['RT_USING_ADC_V2', 'RT_ADC_USING_TRIGGER']):
1317
if GetDepend(['RT_USING_ADC_V2', 'RT_USING_FINSH', 'RT_ADC_V2_USING_MSH']):
1418
src += ['adc_v2_msh.c']
1519

16-
group = DefineGroup('DeviceDrivers', src, depend = ['RT_USING_ADC_V2'], CPPPATH = CPPPATH)
20+
if len(src):
21+
group = DefineGroup('DeviceDrivers', src, depend = ['RT_USING_ADC'], CPPPATH = CPPPATH)
1722

1823
Return('group')

components/drivers/include/drivers/adc_v2.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
#include <rtconfig.h>
2020
#include "misc.h"
21-
#if defined(RT_USING_ADC)
22-
#error "ADC V2 uses the legacy ADC namespace; disable RT_USING_ADC before enabling ADC V2."
23-
#endif /* defined(RT_USING_ADC) */
21+
#if !defined(RT_USING_ADC_V2)
22+
#error "ADC V2 interface requires RT_USING_ADC_V2."
23+
#endif /* !defined(RT_USING_ADC_V2) */
2424

2525
#include <rtatomic.h>
2626
#include <rtdevice.h>

components/drivers/include/rtdevice.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,10 @@ extern "C" {
259259
#include "drivers/dev_audio.h"
260260
#endif /* RT_USING_AUDIO */
261261

262-
#ifdef RT_USING_ADC
263-
#include "drivers/adc.h"
264-
#endif /* RT_USING_ADC */
265-
266262
#ifdef RT_USING_ADC_V2
267263
#include "drivers/adc_v2.h"
264+
#elif defined(RT_USING_ADC)
265+
#include "drivers/adc.h"
268266
#endif /* RT_USING_ADC_V2 */
269267

270268
#ifdef RT_USING_DAC

components/drivers/misc/Kconfig

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
menuconfig RT_USING_ADC
2-
bool "Using ADC device drivers"
3-
default n
4-
5-
if RT_USING_DM && RT_USING_ADC
6-
osource "$(SOC_DM_ADC_DIR)/Kconfig"
7-
endif
8-
91
config RT_USING_DAC
102
bool "Using DAC device drivers"
113
default n

components/drivers/misc/SConscript

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ src = []
55
CPPPATH = [cwd + '/../include']
66
group = []
77

8-
if GetDepend(['RT_USING_ADC']):
9-
src = src + ['adc.c']
10-
118
if GetDepend(['RT_USING_DAC']):
129
src = src + ['dac.c']
1310

0 commit comments

Comments
 (0)