Skip to content

Commit c80fa61

Browse files
committed
Merge branch 'feat/allow_to_skip_legacy_driver_conflict_check' into 'master'
feat(legacy_driver): add kconfig to skip legacy confilct check Closes IDFGH-12987 See merge request espressif/esp-idf!35458
2 parents 1ddf005 + f6c776d commit c80fa61

14 files changed

+101
-2
lines changed

components/driver/Kconfig

+58-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ menu "Driver Configurations"
2222
If you want to continue using the legacy driver, and don't want to see related deprecation warnings,
2323
you can enable this option.
2424

25+
config ADC_SKIP_LEGACY_CONFLICT_CHECK
26+
bool "Skip legacy conflict check"
27+
default n
28+
help
29+
This configuration option allows the user to bypass the conflict check mechanism with legacy code.
2530
menu "Legacy ADC Calibration Configuration"
2631

2732
config ADC_CAL_EFUSE_TP_ENABLE
@@ -72,6 +77,12 @@ menu "Driver Configurations"
7277
Whether to suppress the deprecation warnings when using legacy dac driver (driver/dac.h).
7378
If you want to continue using the legacy driver, and don't want to see related deprecation warnings,
7479
you can enable this option.
80+
81+
config DAC_SKIP_LEGACY_CONFLICT_CHECK
82+
bool "Skip legacy conflict check"
83+
default n
84+
help
85+
This configuration option allows the user to bypass the conflict check mechanism with legacy code.
7586
endmenu # Legacy DAC Driver Configurations
7687

7788
menu "Legacy MCPWM Driver Configurations"
@@ -83,6 +94,12 @@ menu "Driver Configurations"
8394
Whether to suppress the deprecation warnings when using legacy MCPWM driver (driver/mcpwm.h).
8495
If you want to continue using the legacy driver, and don't want to see related deprecation warnings,
8596
you can enable this option.
97+
98+
config MCPWM_SKIP_LEGACY_CONFLICT_CHECK
99+
bool "Skip legacy conflict check"
100+
default n
101+
help
102+
This configuration option allows the user to bypass the conflict check mechanism with legacy code.
86103
endmenu # Legacy MCPWM Driver Configurations
87104

88105
menu "Legacy Timer Group Driver Configurations"
@@ -95,6 +112,11 @@ menu "Driver Configurations"
95112
If you want to continue using the legacy driver, and don't want to see related deprecation warnings,
96113
you can enable this option.
97114

115+
config GPTIMER_SKIP_LEGACY_CONFLICT_CHECK
116+
bool "Skip legacy conflict check"
117+
default n
118+
help
119+
This configuration option allows the user to bypass the conflict check mechanism with legacy code.
98120
endmenu # Legacy Timer Group Driver Configurations
99121

100122
menu "Legacy RMT Driver Configurations"
@@ -106,6 +128,12 @@ menu "Driver Configurations"
106128
Whether to suppress the deprecation warnings when using legacy rmt driver (driver/rmt.h).
107129
If you want to continue using the legacy driver, and don't want to see related deprecation warnings,
108130
you can enable this option.
131+
132+
config RMT_SKIP_LEGACY_CONFLICT_CHECK
133+
bool "Skip legacy conflict check"
134+
default n
135+
help
136+
This configuration option allows the user to bypass the conflict check mechanism with legacy code.
109137
endmenu # Legacy RMT Driver Configurations
110138

111139
menu "Legacy I2S Driver Configurations"
@@ -117,6 +145,12 @@ menu "Driver Configurations"
117145
Whether to suppress the deprecation warnings when using legacy i2s driver (driver/i2s.h).
118146
If you want to continue using the legacy driver, and don't want to see related deprecation warnings,
119147
you can enable this option.
148+
149+
config I2S_SKIP_LEGACY_CONFLICT_CHECK
150+
bool "Skip legacy conflict check"
151+
default n
152+
help
153+
This configuration option allows the user to bypass the conflict check mechanism with legacy code.
120154
endmenu # Legacy I2S Driver Configurationss
121155

122156
menu "Legacy PCNT Driver Configurations"
@@ -128,6 +162,12 @@ menu "Driver Configurations"
128162
whether to suppress the deprecation warnings when using legacy PCNT driver (driver/pcnt.h).
129163
If you want to continue using the legacy driver, and don't want to see related deprecation warnings,
130164
you can enable this option.
165+
166+
config PCNT_SKIP_LEGACY_CONFLICT_CHECK
167+
bool "Skip legacy conflict check"
168+
default n
169+
help
170+
This configuration option allows the user to bypass the conflict check mechanism with legacy code.
131171
endmenu # Legacy PCNT Driver Configurationss
132172

133173
menu "Legacy SDM Driver Configurations"
@@ -139,6 +179,12 @@ menu "Driver Configurations"
139179
whether to suppress the deprecation warnings when using legacy SDM driver (driver/sigmadelta.h).
140180
If you want to continue using the legacy driver, and don't want to see related deprecation warnings,
141181
you can enable this option.
182+
183+
config SDM_SKIP_LEGACY_CONFLICT_CHECK
184+
bool "Skip legacy conflict check"
185+
default n
186+
help
187+
This configuration option allows the user to bypass the conflict check mechanism with legacy code.
142188
endmenu # Legacy SDM Driver Configurationss
143189

144190
menu "Legacy Temperature Sensor Driver Configurations"
@@ -150,6 +196,12 @@ menu "Driver Configurations"
150196
whether to suppress the deprecation warnings when using legacy temperature sensor driver
151197
(driver/temp_sensor.h). If you want to continue using the legacy driver,
152198
and don't want to see related deprecation warnings, you can enable this option.
199+
200+
config TEMP_SENSOR_SKIP_LEGACY_CONFLICT_CHECK
201+
bool "Skip legacy conflict check"
202+
default n
203+
help
204+
This configuration option allows the user to bypass the conflict check mechanism with legacy code.
153205
endmenu # Legacy Temperature Sensor Driver Configurationss
154206

155207
menu "Legacy Touch Sensor Driver Configurations"
@@ -161,6 +213,11 @@ menu "Driver Configurations"
161213
whether to suppress the deprecation warnings when using legacy touch sensor driver
162214
(driver/touch_sensor.h). If you want to continue using the legacy driver,
163215
and don't want to see related deprecation warnings, you can enable this option.
164-
endmenu # Legacy Touch Sensor Driver Configurationss
165216

217+
config TOUCH_SKIP_LEGACY_CONFLICT_CHECK
218+
bool "Skip legacy conflict check"
219+
default n
220+
help
221+
This configuration option allows the user to bypass the conflict check mechanism with legacy code.
222+
endmenu # Legacy Touch Sensor Driver Configurationss
166223
endmenu # Driver configurations

components/driver/deprecated/adc_dma_legacy.c

+2
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,7 @@ esp_err_t adc_digi_controller_configure(const adc_digi_configuration_t *config)
631631
return ESP_OK;
632632
}
633633

634+
#if !CONFIG_ADC_SKIP_LEGACY_CONFLICT_CHECK
634635
/**
635636
* @brief This function will be called during start up, to check that adc_continuous driver is not running along with the legacy adc_continuous driver
636637
*/
@@ -646,6 +647,7 @@ static void check_adc_continuous_driver_conflict(void)
646647
}
647648
ESP_EARLY_LOGW(ADC_TAG, "legacy driver is deprecated, please migrate to `esp_adc/adc_continuous.h`");
648649
}
650+
#endif //CONFIG_ADC_SKIP_LEGACY_CONFLICT_CHECK
649651

650652
#if SOC_ADC_CALIBRATION_V1_SUPPORTED
651653
/*---------------------------------------------------------------

components/driver/deprecated/adc_legacy.c

+2
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,7 @@ static esp_err_t adc_hal_convert(adc_unit_t adc_n, int channel, uint32_t clk_src
922922
return ESP_OK;
923923
}
924924

925+
#if !CONFIG_ADC_SKIP_LEGACY_CONFLICT_CHECK
925926
/**
926927
* @brief This function will be called during start up, to check that adc_oneshot driver is not running along with the legacy adc oneshot driver
927928
*/
@@ -937,6 +938,7 @@ static void check_adc_oneshot_driver_conflict(void)
937938
}
938939
ESP_EARLY_LOGW(ADC_TAG, "legacy driver is deprecated, please migrate to `esp_adc/adc_oneshot.h`");
939940
}
941+
#endif //CONFIG_ADC_SKIP_LEGACY_CONFLICT_CHECK
940942

941943
#if SOC_ADC_CALIBRATION_V1_SUPPORTED
942944
/*---------------------------------------------------------------

components/driver/deprecated/dac_common_legacy.c

+2
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ esp_err_t dac_cw_generator_config(dac_cw_config_t *cw)
128128
return ESP_OK;
129129
}
130130

131+
#if !CONFIG_DAC_SKIP_LEGACY_CONFLICT_CHECK
131132
/**
132133
* @brief This function will be called during start up, to check that this legacy DAC driver is not running along with the new driver
133134
*/
@@ -143,3 +144,4 @@ static void check_dac_legacy_driver_conflict(void)
143144
}
144145
ESP_EARLY_LOGW(TAG, "legacy driver is deprecated, please migrate to `driver/dac_oneshot.h`, `driver/dac_cosine.h` or `driver/dac_continuous.h` instead");
145146
}
147+
#endif //CONFIG_DAC_SKIP_LEGACY_CONFLICT_CHECK

components/driver/deprecated/i2s_legacy.c

+2
Original file line numberDiff line numberDiff line change
@@ -1981,6 +1981,7 @@ esp_err_t i2s_set_pin(i2s_port_t i2s_num, const i2s_pin_config_t *pin)
19811981
return ESP_OK;
19821982
}
19831983

1984+
#if !CONFIG_I2S_SKIP_LEGACY_CONFLICT_CHECK
19841985
/**
19851986
* @brief This function will be called during start up, to check that the new i2s driver is not running along with the legacy i2s driver
19861987
*/
@@ -1994,3 +1995,4 @@ static __attribute__((constructor)) void check_i2s_driver_conflict(void)
19941995
}
19951996
ESP_EARLY_LOGW(TAG, "legacy i2s driver is deprecated, please migrate to use driver/i2s_std.h, driver/i2s_pdm.h or driver/i2s_tdm.h");
19961997
}
1998+
#endif //CONFIG_I2S_SKIP_LEGACY_CONFLICT_CHECK

components/driver/deprecated/mcpwm_legacy.c

+2
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,7 @@ esp_err_t mcpwm_set_timer_sync_output(mcpwm_unit_t mcpwm_num, mcpwm_timer_t time
10531053
return ESP_OK;
10541054
}
10551055

1056+
#if !CONFIG_MCPWM_SKIP_LEGACY_CONFLICT_CHECK
10561057
/**
10571058
* @brief This function will be called during start up, to check that this legacy mcpwm driver is not running along with the new MCPWM driver
10581059
*/
@@ -1068,3 +1069,4 @@ static void check_mcpwm_driver_conflict(void)
10681069
}
10691070
ESP_EARLY_LOGW(TAG, "legacy driver is deprecated, please migrate to `driver/mcpwm_prelude.h`");
10701071
}
1072+
#endif //CONFIG_MCPWM_SKIP_LEGACY_CONFLICT_CHECK

components/driver/deprecated/pcnt_legacy.c

+2
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ void pcnt_isr_service_uninstall(void)
555555
_pcnt_isr_service_uninstall(PCNT_PORT_0);
556556
}
557557

558+
#if !CONFIG_PCNT_SKIP_LEGACY_CONFLICT_CHECK
558559
/**
559560
* @brief This function will be called during start up, to check that pulse_cnt driver is not running along with the legacy pcnt driver
560561
*/
@@ -570,3 +571,4 @@ static void check_pcnt_driver_conflict(void)
570571
}
571572
ESP_EARLY_LOGW(TAG, "legacy driver is deprecated, please migrate to `driver/pulse_cnt.h`");
572573
}
574+
#endif //CONFIG_PCNT_SKIP_LEGACY_CONFLICT_CHECK

components/driver/deprecated/rmt_legacy.c

+2
Original file line numberDiff line numberDiff line change
@@ -1398,6 +1398,7 @@ esp_err_t rmt_enable_tx_loop_autostop(rmt_channel_t channel, bool en)
13981398
}
13991399
#endif
14001400

1401+
#if !CONFIG_RMT_SKIP_LEGACY_CONFLICT_CHECK
14011402
/**
14021403
* @brief This function will be called during start up, to check that this legacy RMT driver is not running along with the new driver
14031404
*/
@@ -1413,3 +1414,4 @@ static void check_rmt_legacy_driver_conflict(void)
14131414
}
14141415
ESP_EARLY_LOGW(TAG, "legacy driver is deprecated, please migrate to `driver/rmt_tx.h` and/or `driver/rmt_rx.h`");
14151416
}
1417+
#endif //CONFIG_RMT_SKIP_LEGACY_CONFLICT_CHECK

components/driver/deprecated/rtc_temperature_legacy.c

+2
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ esp_err_t temp_sensor_read_celsius(float *celsius)
158158
return ESP_OK;
159159
}
160160

161+
#if !CONFIG_TEMP_SENSOR_SKIP_LEGACY_CONFLICT_CHECK
161162
/**
162163
* @brief This function will be called during start up, to check that this legacy temp sensor driver is not running along with the new driver
163164
*/
@@ -173,3 +174,4 @@ static void check_legacy_temp_sensor_driver_conflict(void)
173174
}
174175
ESP_EARLY_LOGW(TAG, "legacy driver is deprecated, please migrate to `driver/temperature_sensor.h`");
175176
}
177+
#endif //CONFIG_TEMP_SENSOR_SKIP_LEGACY_CONFLICT_CHECK

components/driver/deprecated/sigma_delta_legacy.c

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -129,3 +129,21 @@ esp_err_t sigmadelta_config(const sigmadelta_config_t *config)
129129
}
130130
return _sigmadelta_config(SIGMADELTA_PORT_0, config);
131131
}
132+
133+
#if !CONFIG_SDM_SKIP_LEGACY_CONFLICT_CHECK
134+
/**
135+
* @brief This function will be called during start up, to check that sdm driver is not running along with the legacy sdm driver
136+
*/
137+
__attribute__((constructor))
138+
static void check_sdm_driver_conflict(void)
139+
{
140+
// This function was declared as weak here. sdm driver has one implementation.
141+
// So if sdm driver is not linked in, then `sdm_new_channel` should be NULL at runtime.
142+
extern __attribute__((weak)) esp_err_t sdm_new_channel(const void *config, void **ret_unit);
143+
if ((void *)sdm_new_channel != NULL) {
144+
ESP_EARLY_LOGE(TAG, "CONFLICT! driver_ng is not allowed to be used with the legacy driver");
145+
abort();
146+
}
147+
ESP_EARLY_LOGW(TAG, "legacy driver is deprecated, please migrate to `driver/sdm.h`");
148+
}
149+
#endif //CONFIG_PCNT_SKIP_LEGACY_CONFLICT_CHECK

components/driver/deprecated/timer_legacy.c

+2
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,7 @@ bool IRAM_ATTR timer_group_get_auto_reload_in_isr(timer_group_t group_num, timer
468468
return p_timer_obj[group_num][timer_num]->auto_reload_en;
469469
}
470470

471+
#if !CONFIG_GPTIMER_SKIP_LEGACY_CONFLICT_CHECK
471472
/**
472473
* @brief This function will be called during start up, to check that this legacy timer group driver is not running along with the gptimer driver
473474
*/
@@ -483,3 +484,4 @@ static void check_legacy_timer_driver_conflict(void)
483484
}
484485
ESP_EARLY_LOGW(TIMER_TAG, "legacy driver is deprecated, please migrate to `driver/gptimer.h`");
485486
}
487+
#endif //CONFIG_GPTIMER_SKIP_LEGACY_CONFLICT_CHECK

components/driver/i2c/i2c.c

+2
Original file line numberDiff line numberDiff line change
@@ -1705,6 +1705,7 @@ int i2c_slave_read_buffer(i2c_port_t i2c_num, uint8_t *data, size_t max_size, Ti
17051705
}
17061706
#endif
17071707

1708+
#if !CONFIG_I2C_SKIP_LEGACY_CONFLICT_CHECK
17081709
/**
17091710
* @brief This function will be called during start up, to check that this legacy i2c driver is not running along with the new I2C driver
17101711
*/
@@ -1720,3 +1721,4 @@ static void check_i2c_driver_conflict(void)
17201721
}
17211722
ESP_EARLY_LOGW(I2C_TAG, "This driver is an old driver, please migrate your application code to adapt `driver/i2c_master.h`");
17221723
}
1724+
#endif //CONFIG_I2C_SKIP_LEGACY_CONFLICT_CHECK

components/driver/touch_sensor/esp32s2/touch_sensor.c

+2
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,7 @@ esp_err_t touch_pad_sleep_channel_set_work_time(uint16_t sleep_cycle, uint16_t m
685685
return ESP_OK;
686686
}
687687

688+
#if !CONFIG_TOUCH_SKIP_LEGACY_CONFLICT_CHECK
688689
/**
689690
* @brief This function will be called during start up, to check that the new touch driver is not running along with the legacy touch driver
690691
*/
@@ -698,3 +699,4 @@ static __attribute__((constructor)) void check_touch_driver_conflict(void)
698699
}
699700
ESP_EARLY_LOGW("legacy_touch_driver", "legacy touch driver is deprecated, please migrate to use driver/touch_sens.h");
700701
}
702+
#endif //CONFIG_TOUCH_SKIP_LEGACY_CONFLICT_CHECK

components/driver/touch_sensor/esp32s3/touch_sensor.c

+2
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,7 @@ esp_err_t touch_pad_sleep_channel_set_work_time(uint16_t sleep_cycle, uint16_t m
657657
return ESP_OK;
658658
}
659659

660+
#if !CONFIG_TOUCH_SKIP_LEGACY_CONFLICT_CHECK
660661
/**
661662
* @brief This function will be called during start up, to check that the new touch driver is not running along with the legacy touch driver
662663
*/
@@ -670,3 +671,4 @@ static __attribute__((constructor)) void check_touch_driver_conflict(void)
670671
}
671672
ESP_EARLY_LOGW("legacy_touch_driver", "legacy touch driver is deprecated, please migrate to use driver/touch_sens.h");
672673
}
674+
#endif //CONFIG_TOUCH_SKIP_LEGACY_CONFLICT_CHECK

0 commit comments

Comments
 (0)