Skip to content

Commit ccd092d

Browse files
committed
refactor(hal): clean up some hal file dependency on sdkconfig.h
1 parent 0296c30 commit ccd092d

35 files changed

+108
-149
lines changed

components/esp_rom/esp32/include/esp32/rom/sha.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,14 @@ typedef struct SHAContext {
2727
uint32_t total_input_bits[4];
2828
} SHA_CTX;
2929

30-
enum SHA_TYPE {
30+
typedef enum SHA_TYPE {
3131
SHA1 = 0,
3232
SHA2_256,
3333
SHA2_384,
3434
SHA2_512,
3535

36-
3736
SHA_INVALID = -1,
38-
};
37+
} SHA_TYPE;
3938

4039
/* Do not use these function in multi core mode due to
4140
* inside they have no safe implementation (without DPORT workaround).

components/hal/adc_hal.c

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@
55
*/
66

77
#include <sys/param.h>
8-
#include "sdkconfig.h"
98
#include "hal/adc_hal.h"
109
#include "hal/assert.h"
1110
#include "soc/lldesc.h"
12-
#include "soc/soc_caps.h"
11+
#include "soc/soc_caps_full.h"
1312

14-
#if CONFIG_IDF_TARGET_ESP32
13+
#if SOC_IS(ESP32)
1514
//ADC utilises I2S0 DMA on ESP32
1615
#include "hal/i2s_hal.h"
1716
#include "hal/i2s_types.h"
@@ -58,7 +57,7 @@ void adc_hal_digi_init(adc_hal_dma_ctx_t *hal)
5857
adc_ll_digi_set_clk_div(ADC_LL_DIGI_SAR_CLK_DIV_DEFAULT);
5958

6059
adc_ll_digi_dma_set_eof_num(hal->eof_num);
61-
#if CONFIG_IDF_TARGET_ESP32
60+
#if SOC_IS(ESP32)
6261
i2s_ll_rx_set_sample_bit(adc_hal_i2s_dev, SAMPLE_BITS, SAMPLE_BITS);
6362
i2s_ll_rx_enable_mono_mode(adc_hal_i2s_dev, 1);
6463
i2s_ll_rx_force_enable_fifo_mod(adc_hal_i2s_dev, 1);
@@ -91,20 +90,20 @@ void adc_hal_digi_deinit()
9190
---------------------------------------------------------------*/
9291
static adc_ll_digi_convert_mode_t get_convert_mode(adc_digi_convert_mode_t convert_mode)
9392
{
94-
#if CONFIG_IDF_TARGET_ESP32 || SOC_ADC_DIGI_CONTROLLER_NUM == 1
93+
#if SOC_IS(ESP32) || SOC_ADC_DIGI_CONTROLLER_NUM == 1
9594
return ADC_LL_DIGI_CONV_ONLY_ADC1;
9695
#elif (SOC_ADC_DIGI_CONTROLLER_NUM >= 2)
9796
switch (convert_mode) {
98-
case ADC_CONV_SINGLE_UNIT_1:
99-
return ADC_LL_DIGI_CONV_ONLY_ADC1;
100-
case ADC_CONV_SINGLE_UNIT_2:
101-
return ADC_LL_DIGI_CONV_ONLY_ADC2;
102-
case ADC_CONV_BOTH_UNIT:
103-
return ADC_LL_DIGI_CONV_BOTH_UNIT;
104-
case ADC_CONV_ALTER_UNIT:
105-
return ADC_LL_DIGI_CONV_ALTER_UNIT;
106-
default:
107-
abort();
97+
case ADC_CONV_SINGLE_UNIT_1:
98+
return ADC_LL_DIGI_CONV_ONLY_ADC1;
99+
case ADC_CONV_SINGLE_UNIT_2:
100+
return ADC_LL_DIGI_CONV_ONLY_ADC2;
101+
case ADC_CONV_BOTH_UNIT:
102+
return ADC_LL_DIGI_CONV_BOTH_UNIT;
103+
case ADC_CONV_ALTER_UNIT:
104+
return ADC_LL_DIGI_CONV_ALTER_UNIT;
105+
default:
106+
abort();
108107
}
109108
#endif
110109
}
@@ -118,7 +117,7 @@ static adc_ll_digi_convert_mode_t get_convert_mode(adc_digi_convert_mode_t conve
118117
*/
119118
static void adc_hal_digi_sample_freq_config(adc_hal_dma_ctx_t *hal, adc_continuous_clk_src_t clk_src, uint32_t clk_src_freq_hz, uint32_t sample_freq_hz)
120119
{
121-
#if !CONFIG_IDF_TARGET_ESP32
120+
#if !SOC_IS(ESP32)
122121
uint32_t interval = clk_src_freq_hz / (ADC_LL_CLKM_DIV_NUM_DEFAULT + ADC_LL_CLKM_DIV_A_DEFAULT / ADC_LL_CLKM_DIV_B_DEFAULT + 1) / 2 / sample_freq_hz;
123122
//set sample interval
124123
adc_ll_digi_set_trigger_interval(interval);
@@ -218,14 +217,14 @@ void adc_hal_digi_dma_link(adc_hal_dma_ctx_t *hal, uint8_t *data_buf)
218217
.dw0.suc_eof = 0,
219218
.dw0.owner = 1,
220219
.buffer = data_buf,
221-
.next = &desc[n+1]
220+
.next = &desc[n + 1]
222221
};
223222
eof_size -= this_len;
224223
data_buf += this_len;
225224
n++;
226225
}
227226
}
228-
desc[n-1].next = desc_head;
227+
desc[n - 1].next = desc_head;
229228
}
230229

231230
adc_hal_dma_desc_status_t adc_hal_get_reading_result(adc_hal_dma_ctx_t *hal, const intptr_t eof_desc_addr, uint8_t **buffer, uint32_t *len)

components/hal/apm_hal.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
*/
66

77
#include <stdbool.h>
8+
#include "soc/soc_caps.h"
89
#include "hal/assert.h"
910
#include "hal/apm_hal.h"
1011
#include "hal/apm_ll.h"
1112
#include "hal/log.h"
1213

13-
#if CONFIG_IDF_TARGET_ESP32P4
14+
#if SOC_IS(ESP32P4)
1415
void apm_hal_hp_peri_access_enable(apm_ll_master_id_t master_id, apm_ll_hp_peri_t hp_peri,
1516
apm_ll_secure_mode_t sec_mode, bool enable)
1617
{
@@ -523,4 +524,4 @@ void apm_hal_enable_ctrl_clk_gating(apm_ctrl_module_t ctrl_mod, bool enable)
523524
}
524525
}
525526

526-
#endif //CONFIG_IDF_TARGET_ESP32P4
527+
#endif //SOC_IS(ESP32P4)

components/hal/emac_hal.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66
#include <string.h>
7-
#include "sdkconfig.h"
7+
#include "soc/soc_caps_full.h"
88
#include "esp_attr.h"
99
#include "hal/emac_hal.h"
1010
#include "hal/emac_ll.h"
@@ -29,7 +29,7 @@ void emac_hal_init(emac_hal_context_t *hal)
2929
{
3030
hal->dma_regs = &EMAC_DMA;
3131
hal->mac_regs = &EMAC_MAC;
32-
#if CONFIG_IDF_TARGET_ESP32
32+
#if SOC_IS(ESP32)
3333
hal->ext_regs = &EMAC_EXT;
3434
#else
3535
hal->ext_regs = NULL;
@@ -137,7 +137,7 @@ void emac_hal_init_dma_default(emac_hal_context_t *hal, emac_hal_dma_config_t *h
137137
/* DMAOMR Configuration */
138138
/* Enable Dropping of TCP/IP Checksum Error Frames */
139139
emac_ll_drop_tcp_err_frame_enable(hal->dma_regs, true);
140-
#if CONFIG_IDF_TARGET_ESP32P4
140+
#if SOC_IS(ESP32P4)
141141
/* Disable Receive Store Forward (Rx FIFO is only 256B) */
142142
emac_ll_recv_store_forward_enable(hal->dma_regs, false);
143143
#else

components/hal/esp32/efuse_hal.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
/*
2-
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
#include "sdkconfig.h"
87
#include <sys/param.h>
9-
#include "soc/soc_caps.h"
108
#include "hal/efuse_ll.h"
119
#include "hal/assert.h"
1210
#include "hal/efuse_hal.h"
11+
#include "hal/config.h"
1312
#include "soc/syscon_reg.h"
1413
#include "esp_attr.h"
1514

@@ -30,11 +29,11 @@ IRAM_ATTR uint32_t efuse_hal_get_major_chip_version(void)
3029
case 3:
3130
chip_ver = 2;
3231
break;
33-
#if CONFIG_IDF_ENV_FPGA
32+
#if HAL_CONFIG_EFUSE_ENV_FPGA
3433
case 4: /* Empty efuses, but SYSCON_DATE_REG bit is set */
3534
chip_ver = 3;
3635
break;
37-
#endif // CONFIG_IDF_ENV_FPGA
36+
#endif // HAL_CONFIG_EFUSE_ENV_FPGA
3837
case 7:
3938
chip_ver = 3;
4039
break;

components/hal/esp32c2/clk_tree_hal.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
#include "sdkconfig.h"
87
#include "soc/clkout_channel.h"
98
#include "hal/assert.h"
9+
#include "hal/config.h"
1010
#include "hal/clk_tree_hal.h"
1111
#include "hal/clk_tree_ll.h"
1212
#include "hal/gpio_ll.h"
@@ -78,8 +78,8 @@ uint32_t clk_hal_xtal_get_freq_mhz(void)
7878
{
7979
uint32_t freq = clk_ll_xtal_load_freq_mhz();
8080
if (freq == 0) {
81-
HAL_LOGW(CLK_HAL_TAG, "invalid RTC_XTAL_FREQ_REG value, assume %dMHz", CONFIG_XTAL_FREQ);
82-
return CONFIG_XTAL_FREQ;
81+
HAL_LOGW(CLK_HAL_TAG, "invalid RTC_XTAL_FREQ_REG value, assume %dMHz", HAL_CONFIG_XTAL_HINT_FREQ_MHZ);
82+
return HAL_CONFIG_XTAL_HINT_FREQ_MHZ;
8383
}
8484
return freq;
8585
}

components/hal/esp32c5/efuse_hal.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66

77
#include <sys/param.h>
8-
#include "sdkconfig.h"
98
#include "soc/soc_caps.h"
109
#include "hal/assert.h"
1110
#include "hal/efuse_hal.h"

components/hal/esp32c6/efuse_hal.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66

77
#include <sys/param.h>
8-
#include "sdkconfig.h"
98
#include "soc/soc_caps.h"
109
#include "hal/assert.h"
1110
#include "hal/efuse_hal.h"

components/hal/esp32c61/efuse_hal.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66

77
#include <sys/param.h>
8-
#include "sdkconfig.h"
98
#include "soc/soc_caps.h"
109
#include "hal/assert.h"
1110
#include "hal/efuse_hal.h"

components/hal/esp32h2/efuse_hal.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
*/
66

77
#include <sys/param.h>
8-
#include "sdkconfig.h"
98
#include "soc/soc_caps.h"
109
#include "soc/chip_revision.h"
1110
#include "hal/assert.h"

0 commit comments

Comments
 (0)