Skip to content

Commit 4d3a9b0

Browse files
committed
refactor(esp_hal_gpio): move some caps definitions to esp_hal_gpio
1 parent 62899cb commit 4d3a9b0

File tree

115 files changed

+586
-329
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+586
-329
lines changed

components/esp_driver_gpio/src/dedic_gpio.c

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "esp_cpu.h"
1818
#include "soc/soc_caps_full.h"
1919
#include "soc/io_mux_reg.h"
20+
#include "hal/dedic_gpio_caps.h"
2021
#include "hal/dedic_gpio_cpu_ll.h"
2122
#include "esp_private/gpio.h"
2223
#include "esp_private/periph_ctrl.h"
@@ -25,10 +26,10 @@
2526
#include "driver/dedic_gpio.h"
2627
#include "hal/dedic_gpio_periph.h"
2728

28-
#if DEDIC_GPIO_LL_ALLOW_REG_ACCESS
29+
#if DEDIC_GPIO_CAPS_GET(ALLOW_REG_ACCESS)
2930
#include "soc/dedic_gpio_struct.h"
3031
#endif
31-
#if !DEDIC_GPIO_CPU_LL_PERIPH_ALWAYS_ENABLE
32+
#if !DEDIC_GPIO_CAPS_GET(CPU_PERIPH_ALWAYS_ENABLE)
3233
#include "hal/dedic_gpio_ll.h"
3334
#endif
3435

@@ -50,11 +51,11 @@ struct dedic_gpio_platform_t {
5051
uint32_t in_occupied_mask; // mask of input channels that already occupied
5152
#if SOC_DEDIC_GPIO_HAS_INTERRUPT
5253
intr_handle_t intr_hdl; // interrupt handle
53-
dedic_gpio_isr_callback_t cbs[SOC_DEDIC_GPIO_ATTR(IN_CHANS_PER_CPU)]; // array of callback function for input channel
54-
void *cb_args[SOC_DEDIC_GPIO_ATTR(IN_CHANS_PER_CPU)]; // array of callback arguments for input channel
55-
dedic_gpio_bundle_t *in_bundles[SOC_DEDIC_GPIO_ATTR(IN_CHANS_PER_CPU)]; // which bundle belongs to for input channel
54+
dedic_gpio_isr_callback_t cbs[DEDIC_GPIO_CAPS_GET(IN_CHANS_PER_CPU)]; // array of callback function for input channel
55+
void *cb_args[DEDIC_GPIO_CAPS_GET(IN_CHANS_PER_CPU)]; // array of callback arguments for input channel
56+
dedic_gpio_bundle_t *in_bundles[DEDIC_GPIO_CAPS_GET(IN_CHANS_PER_CPU)]; // which bundle belongs to for input channel
5657
#endif
57-
#if DEDIC_GPIO_LL_ALLOW_REG_ACCESS
58+
#if DEDIC_GPIO_CAPS_GET(ALLOW_REG_ACCESS)
5859
dedic_dev_t *dev;
5960
#endif
6061
};
@@ -81,18 +82,18 @@ static esp_err_t dedic_gpio_build_platform(int core_id)
8182
// initialize platform members
8283
s_platform[core_id]->spinlock = (portMUX_TYPE)portMUX_INITIALIZER_UNLOCKED;
8384
// initial occupy_mask: 1111...100...0
84-
s_platform[core_id]->out_occupied_mask = UINT32_MAX & ~((1 << SOC_DEDIC_GPIO_ATTR(OUT_CHANS_PER_CPU)) - 1);
85-
s_platform[core_id]->in_occupied_mask = UINT32_MAX & ~((1 << SOC_DEDIC_GPIO_ATTR(IN_CHANS_PER_CPU)) - 1);
86-
#if DEDIC_GPIO_LL_ALLOW_REG_ACCESS
85+
s_platform[core_id]->out_occupied_mask = UINT32_MAX & ~((1 << DEDIC_GPIO_CAPS_GET(OUT_CHANS_PER_CPU)) - 1);
86+
s_platform[core_id]->in_occupied_mask = UINT32_MAX & ~((1 << DEDIC_GPIO_CAPS_GET(IN_CHANS_PER_CPU)) - 1);
87+
#if DEDIC_GPIO_CAPS_GET(ALLOW_REG_ACCESS)
8788
s_platform[core_id]->dev = &DEDIC_GPIO;
88-
#endif // DEDIC_GPIO_LL_ALLOW_REG_ACCESS
89-
#if !DEDIC_GPIO_CPU_LL_PERIPH_ALWAYS_ENABLE
89+
#endif // DEDIC_GPIO_CAPS_GET(ALLOW_REG_ACCESS)
90+
#if !DEDIC_GPIO_CAPS_GET(CPU_PERIPH_ALWAYS_ENABLE)
9091
// enable dedicated GPIO register clock
9192
PERIPH_RCC_ATOMIC() {
9293
dedic_gpio_ll_enable_bus_clock(true);
9394
dedic_gpio_ll_reset_register();
9495
}
95-
#endif // !DEDIC_GPIO_CPU_LL_PERIPH_ALWAYS_ENABLE
96+
#endif // !DEDIC_GPIO_CAPS_GET(CPU_PERIPH_ALWAYS_ENABLE)
9697
}
9798
}
9899
_lock_release(&s_platform_mutexlock[core_id]);
@@ -113,12 +114,12 @@ static void dedic_gpio_break_platform(int core_id)
113114
if (s_platform[core_id]) {
114115
free(s_platform[core_id]);
115116
s_platform[core_id] = NULL;
116-
#if !DEDIC_GPIO_CPU_LL_PERIPH_ALWAYS_ENABLE
117+
#if !DEDIC_GPIO_CAPS_GET(CPU_PERIPH_ALWAYS_ENABLE)
117118
// disable the register clock if no GPIO channel is in use
118119
PERIPH_RCC_ATOMIC() {
119120
dedic_gpio_ll_enable_bus_clock(false);
120121
}
121-
#endif // !DEDIC_GPIO_CPU_LL_PERIPH_ALWAYS_ENABLE
122+
#endif // !DEDIC_GPIO_CAPS_GET(CPU_PERIPH_ALWAYS_ENABLE)
122123
}
123124
_lock_release(&s_platform_mutexlock[core_id]);
124125
}
@@ -222,11 +223,11 @@ esp_err_t dedic_gpio_new_bundle(const dedic_gpio_bundle_config_t *config, dedic_
222223
// configure outwards channels
223224
uint32_t out_offset = 0;
224225
if (config->flags.out_en) {
225-
ESP_GOTO_ON_FALSE(config->array_size <= SOC_DEDIC_GPIO_ATTR(OUT_CHANS_PER_CPU), ESP_ERR_INVALID_ARG, err, TAG,
226-
"array size(%d) exceeds maximum supported out channels(%d)", config->array_size, SOC_DEDIC_GPIO_ATTR(OUT_CHANS_PER_CPU));
226+
ESP_GOTO_ON_FALSE(config->array_size <= DEDIC_GPIO_CAPS_GET(OUT_CHANS_PER_CPU), ESP_ERR_INVALID_ARG, err, TAG,
227+
"array size(%d) exceeds maximum supported out channels(%d)", config->array_size, DEDIC_GPIO_CAPS_GET(OUT_CHANS_PER_CPU));
227228
// prevent install bundle concurrently
228229
portENTER_CRITICAL(&s_platform[core_id]->spinlock);
229-
for (size_t i = 0; i <= SOC_DEDIC_GPIO_ATTR(OUT_CHANS_PER_CPU) - config->array_size; i++) {
230+
for (size_t i = 0; i <= DEDIC_GPIO_CAPS_GET(OUT_CHANS_PER_CPU) - config->array_size; i++) {
230231
if ((s_platform[core_id]->out_occupied_mask & (pattern << i)) == 0) {
231232
out_mask = pattern << i;
232233
out_offset = i;
@@ -235,7 +236,7 @@ esp_err_t dedic_gpio_new_bundle(const dedic_gpio_bundle_config_t *config, dedic_
235236
}
236237
if (out_mask) {
237238
s_platform[core_id]->out_occupied_mask |= out_mask;
238-
#if DEDIC_GPIO_LL_ALLOW_REG_ACCESS
239+
#if DEDIC_GPIO_CAPS_GET(ALLOW_REG_ACCESS)
239240
// always enable instruction to access output GPIO, which has better performance than register access
240241
dedic_gpio_ll_enable_instruction_access_out(s_platform[core_id]->dev, out_mask, true);
241242
#endif
@@ -248,11 +249,11 @@ esp_err_t dedic_gpio_new_bundle(const dedic_gpio_bundle_config_t *config, dedic_
248249
// configure inwards channels
249250
uint32_t in_offset = 0;
250251
if (config->flags.in_en) {
251-
ESP_GOTO_ON_FALSE(config->array_size <= SOC_DEDIC_GPIO_ATTR(IN_CHANS_PER_CPU), ESP_ERR_INVALID_ARG, err, TAG,
252-
"array size(%d) exceeds maximum supported in channels(%d)", config->array_size, SOC_DEDIC_GPIO_ATTR(IN_CHANS_PER_CPU));
252+
ESP_GOTO_ON_FALSE(config->array_size <= DEDIC_GPIO_CAPS_GET(IN_CHANS_PER_CPU), ESP_ERR_INVALID_ARG, err, TAG,
253+
"array size(%d) exceeds maximum supported in channels(%d)", config->array_size, DEDIC_GPIO_CAPS_GET(IN_CHANS_PER_CPU));
253254
// prevent install bundle concurrently
254255
portENTER_CRITICAL(&s_platform[core_id]->spinlock);
255-
for (size_t i = 0; i <= SOC_DEDIC_GPIO_ATTR(IN_CHANS_PER_CPU) - config->array_size; i++) {
256+
for (size_t i = 0; i <= DEDIC_GPIO_CAPS_GET(IN_CHANS_PER_CPU) - config->array_size; i++) {
256257
if ((s_platform[core_id]->in_occupied_mask & (pattern << i)) == 0) {
257258
in_mask = pattern << i;
258259
in_offset = i;
@@ -320,8 +321,8 @@ esp_err_t dedic_gpio_del_bundle(dedic_gpio_bundle_handle_t bundle)
320321
portENTER_CRITICAL(&s_platform[core_id]->spinlock);
321322
s_platform[core_id]->out_occupied_mask &= ~(bundle->out_mask);
322323
s_platform[core_id]->in_occupied_mask &= ~(bundle->in_mask);
323-
if (s_platform[core_id]->in_occupied_mask == (UINT32_MAX & ~((1 << SOC_DEDIC_GPIO_ATTR(IN_CHANS_PER_CPU)) - 1)) &&
324-
s_platform[core_id]->out_occupied_mask == (UINT32_MAX & ~((1 << SOC_DEDIC_GPIO_ATTR(OUT_CHANS_PER_CPU)) - 1))) {
324+
if (s_platform[core_id]->in_occupied_mask == (UINT32_MAX & ~((1 << DEDIC_GPIO_CAPS_GET(IN_CHANS_PER_CPU)) - 1)) &&
325+
s_platform[core_id]->out_occupied_mask == (UINT32_MAX & ~((1 << DEDIC_GPIO_CAPS_GET(OUT_CHANS_PER_CPU)) - 1))) {
325326
recycle_all = true;
326327
}
327328
portEXIT_CRITICAL(&s_platform[core_id]->spinlock);

components/esp_driver_gpio/src/gpio.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,12 @@ static const char *GPIO_TAG = "gpio";
3232

3333
#define GPIO_ISR_CORE_ID_UNINIT (3)
3434

35-
//default value for SOC_GPIO_SUPPORT_RTC_INDEPENDENT is 0
36-
#ifndef SOC_GPIO_SUPPORT_RTC_INDEPENDENT
37-
#define SOC_GPIO_SUPPORT_RTC_INDEPENDENT 0
35+
// On ESP32, those PADs which have RTC functions must set pullup/down/drv capability via RTC register.
36+
// On other targets, digital IOs have their own registers to control pullup/down/drv capability, independent with RTC_IO (LP_IOMUX) registers.
37+
#if CONFIG_IDF_TARGET_ESP32
38+
#define GPIO_RTCIO_ARE_INDEPENDENT 0
39+
#else // for any other target has RTC_IO (LP_IOMUX) registers
40+
#define GPIO_RTCIO_ARE_INDEPENDENT 1
3841
#endif
3942

4043
typedef struct {
@@ -77,7 +80,7 @@ esp_err_t gpio_pullup_en(gpio_num_t gpio_num)
7780
{
7881
GPIO_CHECK(GPIO_IS_VALID_OUTPUT_GPIO(gpio_num), "GPIO number error (input-only pad has no internal PU)", ESP_ERR_INVALID_ARG);
7982

80-
if (!rtc_gpio_is_valid_gpio(gpio_num) || SOC_GPIO_SUPPORT_RTC_INDEPENDENT) {
83+
if (!rtc_gpio_is_valid_gpio(gpio_num) || GPIO_RTCIO_ARE_INDEPENDENT) {
8184
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
8285
gpio_hal_pullup_en(gpio_context.gpio_hal, gpio_num);
8386
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
@@ -96,7 +99,7 @@ esp_err_t gpio_pullup_dis(gpio_num_t gpio_num)
9699
{
97100
GPIO_CHECK(GPIO_IS_VALID_GPIO(gpio_num), "GPIO number error", ESP_ERR_INVALID_ARG);
98101

99-
if (!rtc_gpio_is_valid_gpio(gpio_num) || SOC_GPIO_SUPPORT_RTC_INDEPENDENT) {
102+
if (!rtc_gpio_is_valid_gpio(gpio_num) || GPIO_RTCIO_ARE_INDEPENDENT) {
100103
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
101104
gpio_hal_pullup_dis(gpio_context.gpio_hal, gpio_num);
102105
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
@@ -115,7 +118,7 @@ esp_err_t gpio_pulldown_en(gpio_num_t gpio_num)
115118
{
116119
GPIO_CHECK(GPIO_IS_VALID_OUTPUT_GPIO(gpio_num), "GPIO number error (input-only pad has no internal PD)", ESP_ERR_INVALID_ARG);
117120

118-
if (!rtc_gpio_is_valid_gpio(gpio_num) || SOC_GPIO_SUPPORT_RTC_INDEPENDENT) {
121+
if (!rtc_gpio_is_valid_gpio(gpio_num) || GPIO_RTCIO_ARE_INDEPENDENT) {
119122
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
120123
gpio_hal_pulldown_en(gpio_context.gpio_hal, gpio_num);
121124
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
@@ -134,7 +137,7 @@ esp_err_t gpio_pulldown_dis(gpio_num_t gpio_num)
134137
{
135138
GPIO_CHECK(GPIO_IS_VALID_GPIO(gpio_num), "GPIO number error", ESP_ERR_INVALID_ARG);
136139

137-
if (!rtc_gpio_is_valid_gpio(gpio_num) || SOC_GPIO_SUPPORT_RTC_INDEPENDENT) {
140+
if (!rtc_gpio_is_valid_gpio(gpio_num) || GPIO_RTCIO_ARE_INDEPENDENT) {
138141
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
139142
gpio_hal_pulldown_dis(gpio_context.gpio_hal, gpio_num);
140143
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
@@ -701,7 +704,7 @@ esp_err_t gpio_set_drive_capability(gpio_num_t gpio_num, gpio_drive_cap_t streng
701704
GPIO_CHECK(strength < GPIO_DRIVE_CAP_MAX, "GPIO drive capability error", ESP_ERR_INVALID_ARG);
702705
esp_err_t ret = ESP_OK;
703706

704-
if (!rtc_gpio_is_valid_gpio(gpio_num) || SOC_GPIO_SUPPORT_RTC_INDEPENDENT) {
707+
if (!rtc_gpio_is_valid_gpio(gpio_num) || GPIO_RTCIO_ARE_INDEPENDENT) {
705708
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
706709
gpio_hal_set_drive_capability(gpio_context.gpio_hal, gpio_num, strength);
707710
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
@@ -722,7 +725,7 @@ esp_err_t gpio_get_drive_capability(gpio_num_t gpio_num, gpio_drive_cap_t *stren
722725
GPIO_CHECK(strength != NULL, "GPIO drive capability pointer error", ESP_ERR_INVALID_ARG);
723726
esp_err_t ret = ESP_OK;
724727

725-
if (!rtc_gpio_is_valid_gpio(gpio_num) || SOC_GPIO_SUPPORT_RTC_INDEPENDENT) {
728+
if (!rtc_gpio_is_valid_gpio(gpio_num) || GPIO_RTCIO_ARE_INDEPENDENT) {
726729
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
727730
gpio_hal_get_drive_capability(gpio_context.gpio_hal, gpio_num, strength);
728731
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
@@ -1062,7 +1065,7 @@ esp_err_t gpio_get_io_config(gpio_num_t gpio_num, gpio_io_config_t *out_io_confi
10621065
ESP_RETURN_ON_FALSE(out_io_config, ESP_ERR_INVALID_ARG, GPIO_TAG, "out_io_config is a null pointer");
10631066

10641067
gpio_hal_get_io_config(gpio_context.gpio_hal, gpio_num, out_io_config);
1065-
#if !SOC_GPIO_SUPPORT_RTC_INDEPENDENT && SOC_RTCIO_PIN_COUNT > 0
1068+
#if !GPIO_RTCIO_ARE_INDEPENDENT && SOC_RTCIO_PIN_COUNT > 0
10661069
if (rtc_gpio_is_valid_gpio(gpio_num)) {
10671070
int rtcio_num = rtc_io_number_get(gpio_num);
10681071
out_io_config->pu = rtcio_hal_is_pullup_enabled(rtcio_num);

components/esp_driver_gpio/src/gpio_etm.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -15,6 +15,7 @@
1515
#include "esp_log.h"
1616
#include "esp_check.h"
1717
#include "soc/soc_caps.h"
18+
#include "hal/gpio_caps.h"
1819
#include "hal/gpio_ll.h"
1920
#include "hal/gpio_etm_ll.h"
2021
#include "esp_private/etm_interface.h"
@@ -29,10 +30,10 @@ typedef struct gpio_etm_event_t gpio_etm_event_t;
2930
typedef struct gpio_etm_group_t {
3031
portMUX_TYPE spinlock;
3132
gpio_etm_dev_t *dev;
32-
uint8_t tasks[GPIO_LL_ETM_TASK_CHANNELS_PER_GROUP]; // Array of the acquired action masks in each GPIO ETM task channel
33-
uint8_t events[GPIO_LL_ETM_EVENT_CHANNELS_PER_GROUP]; // Array of the acquired event masks in each GPIO ETM event channel
33+
uint8_t tasks[GPIO_CAPS_GET(ETM_TASK_CHANNELS_PER_GROUP)]; // Array of the acquired action masks in each GPIO ETM task channel
34+
uint8_t events[GPIO_CAPS_GET(ETM_EVENT_CHANNELS_PER_GROUP)]; // Array of the acquired event masks in each GPIO ETM event channel
3435
uint8_t actions[SOC_GPIO_PIN_COUNT]; // Array of the masks of the added actions to each GPIO
35-
uint8_t edges[GPIO_LL_ETM_EVENT_CHANNELS_PER_GROUP]; // Array of the masks of the bound event edges in each GPIO ETM event channel
36+
uint8_t edges[GPIO_CAPS_GET(ETM_EVENT_CHANNELS_PER_GROUP)]; // Array of the masks of the bound event edges in each GPIO ETM event channel
3637
} gpio_etm_group_t;
3738

3839
struct gpio_etm_event_t {
@@ -63,7 +64,7 @@ static esp_err_t gpio_etm_acquire_event_channel(uint8_t event_mask, int *chan_id
6364
int free_chan_id = -1;
6465
// loop to search free event channel in the group
6566
portENTER_CRITICAL(&group->spinlock);
66-
for (int j = 0; j < GPIO_LL_ETM_EVENT_CHANNELS_PER_GROUP; j++) {
67+
for (int j = 0; j < GPIO_CAPS_GET(ETM_EVENT_CHANNELS_PER_GROUP); j++) {
6768
if (!group->events[j]) {
6869
free_chan_id = j;
6970
group->events[j] = event_mask;
@@ -94,7 +95,7 @@ static esp_err_t gpio_etm_acquire_task_channel(uint8_t task_mask, int *chan_id)
9495
int free_chan_id = -1;
9596
// loop to search free task channel in the group
9697
portENTER_CRITICAL(&group->spinlock);
97-
for (int j = 0; j < GPIO_LL_ETM_TASK_CHANNELS_PER_GROUP; j++) {
98+
for (int j = 0; j < GPIO_CAPS_GET(ETM_TASK_CHANNELS_PER_GROUP); j++) {
9899
if (!group->tasks[j]) {
99100
free_chan_id = j;
100101
group->tasks[j] = task_mask;

components/esp_driver_gpio/src/gpio_pin_glitch_filter.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "hal/gpio_ll.h"
1313
#include "esp_clk_tree.h"
1414
#include "esp_private/io_mux.h"
15+
#include "hal/gpio_caps.h"
1516

1617
static const char *TAG = "gpio-filter";
1718

@@ -93,11 +94,11 @@ esp_err_t gpio_new_pin_glitch_filter(const gpio_pin_glitch_filter_config_t *conf
9394
// create pm lock according to different clock source
9495
#if CONFIG_PM_ENABLE
9596
esp_pm_lock_type_t lock_type = ESP_PM_NO_LIGHT_SLEEP;
96-
#if SOC_GPIO_FILTER_CLK_SUPPORT_APB
97+
#if GPIO_CAPS_GET(FILTER_CLK_SUPPORT_APB)
9798
if (config->clk_src == GLITCH_FILTER_CLK_SRC_APB) {
9899
lock_type = ESP_PM_APB_FREQ_MAX;
99100
}
100-
#endif // SOC_GPIO_FILTER_CLK_SUPPORT_APB
101+
#endif // GPIO_CAPS_GET(FILTER_CLK_SUPPORT_APB)
101102
sprintf(filter->pm_lock_name, "filter_io_%d", config->gpio_num); // e.g. filter_io_0
102103
ESP_GOTO_ON_ERROR(esp_pm_lock_create(lock_type, 0, filter->pm_lock_name, &filter->pm_lock),
103104
err, TAG, "create pm_lock failed");

components/esp_driver_gpio/src/rtc_io.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
#include "hal/rtc_io_hal.h"
1717
#include "hal/rtc_io_periph.h"
1818
#include "soc/soc_caps.h"
19+
#if SOC_RTCIO_PIN_COUNT > 0
20+
#include "hal/rtc_gpio_caps.h"
21+
#endif
1922
#if SOC_LP_GPIO_MATRIX_SUPPORTED
2023
#include "soc/lp_gpio_pins.h"
2124
#endif
@@ -263,11 +266,11 @@ esp_err_t rtc_gpio_isolate(gpio_num_t gpio_num)
263266
esp_err_t rtc_gpio_wakeup_enable(gpio_num_t gpio_num, gpio_int_type_t intr_type)
264267
{
265268
ESP_RETURN_ON_FALSE(rtc_gpio_is_valid_gpio(gpio_num), ESP_ERR_INVALID_ARG, RTCIO_TAG, "RTCIO number error");
266-
#if !SOC_RTCIO_EDGE_WAKE_SUPPORTED
269+
#if !RTC_GPIO_CAPS_GET(EDGE_WAKEUP_SUPPORTED)
267270
if (intr_type == GPIO_INTR_POSEDGE || intr_type == GPIO_INTR_NEGEDGE || intr_type == GPIO_INTR_ANYEDGE) {
268271
return ESP_ERR_INVALID_ARG; // Dont support this mode.
269272
}
270-
#endif //!SOC_RTCIO_EDGE_WAKE_SUPPORTED
273+
#endif //!RTC_GPIO_CAPS_GET(EDGE_WAKEUP_SUPPORTED)
271274
RTCIO_ENTER_CRITICAL();
272275
rtcio_hal_wakeup_enable(rtc_io_number_get(gpio_num), intr_type);
273276
RTCIO_EXIT_CRITICAL();

components/esp_driver_gpio/test_apps/gpio_extensions/main/test_dedicated_gpio.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,17 @@
1212
#include "unity_test_utils.h"
1313
#include "esp_rom_sys.h"
1414
#include "soc/soc_caps_full.h"
15+
#include "hal/dedic_gpio_caps.h"
1516
#include "hal/dedic_gpio_periph.h"
1617
#include "hal/dedic_gpio_cpu_ll.h"
1718
#include "driver/gpio.h"
1819
#include "driver/dedic_gpio.h"
1920

2021
TEST_CASE("Dedicated_GPIO_bundle_install/uninstall", "[dedic_gpio]")
2122
{
22-
const int test_gpios[SOC_DEDIC_GPIO_ATTR(OUT_CHANS_PER_CPU) / 2] = {0};
23-
const int test2_gpios[SOC_DEDIC_GPIO_ATTR(OUT_CHANS_PER_CPU) / 2 + 1] = {0};
24-
const int test3_gpios[SOC_DEDIC_GPIO_ATTR(OUT_CHANS_PER_CPU) + 1] = {0};
23+
const int test_gpios[DEDIC_GPIO_CAPS_GET(OUT_CHANS_PER_CPU) / 2] = {0};
24+
const int test2_gpios[DEDIC_GPIO_CAPS_GET(OUT_CHANS_PER_CPU) / 2 + 1] = {0};
25+
const int test3_gpios[DEDIC_GPIO_CAPS_GET(OUT_CHANS_PER_CPU) + 1] = {0};
2526
dedic_gpio_bundle_handle_t test_bundle, test_bundle2, test_bundle3 = NULL;
2627
dedic_gpio_bundle_config_t bundle_config = {
2728
.gpio_array = test_gpios,
@@ -48,7 +49,7 @@ TEST_CASE("Dedicated_GPIO_bundle_install/uninstall", "[dedic_gpio]")
4849
TEST_ASSERT_EQUAL_MESSAGE(ESP_OK, dedic_gpio_new_bundle(&bundle_config, &test_bundle), "create bundle with half channels failed");
4950
uint32_t mask = 0;
5051
TEST_ESP_OK(dedic_gpio_get_out_mask(test_bundle, &mask));
51-
TEST_ASSERT_EQUAL_MESSAGE((1 << (SOC_DEDIC_GPIO_ATTR(OUT_CHANS_PER_CPU) / 2)) - 1, mask, "wrong out mask");
52+
TEST_ASSERT_EQUAL_MESSAGE((1 << (DEDIC_GPIO_CAPS_GET(OUT_CHANS_PER_CPU) / 2)) - 1, mask, "wrong out mask");
5253
TEST_ESP_OK(dedic_gpio_get_in_mask(test_bundle, &mask));
5354
TEST_ASSERT_EQUAL_MESSAGE(0, mask, "wrong in mask");
5455

0 commit comments

Comments
 (0)