fast_gpio: fix wrong initial occupy mask

This commit is contained in:
morris 2021-12-01 20:15:05 +08:00
parent 47ab8f8e63
commit e8c5f8656b
6 changed files with 18 additions and 14 deletions

View File

@ -34,6 +34,10 @@ if(CONFIG_SOC_GDMA_SUPPORTED)
list(APPEND srcs "gdma.c")
endif()
if(CONFIG_SOC_DEDICATED_GPIO_SUPPORTED)
list(APPEND srcs "dedic_gpio.c")
endif()
if(${target} STREQUAL "esp32")
# SDMMC and MCPWM are in ESP32 only.
list(APPEND srcs "dac_common.c"
@ -53,7 +57,6 @@ endif()
if(IDF_TARGET STREQUAL "esp32s2")
list(APPEND srcs "dac_common.c"
"dedic_gpio.c"
"spi_slave_hd.c"
"touch_sensor_common.c"
"sigmadelta.c"
@ -69,8 +72,7 @@ if(IDF_TARGET STREQUAL "esp32s2")
endif()
if(${target} STREQUAL "esp32s3")
list(APPEND srcs "dedic_gpio.c"
"sdmmc_host.c"
list(APPEND srcs "sdmmc_host.c"
"sdmmc_transaction.c"
"rmt.c"
"sigmadelta.c"
@ -84,7 +86,6 @@ endif()
if(IDF_TARGET STREQUAL "esp32c3")
list(APPEND srcs "spi_slave_hd.c"
"dedic_gpio.c"
"usb_serial_jtag.c"
"i2s.c"
"rmt.c"
@ -96,7 +97,6 @@ endif()
if(IDF_TARGET STREQUAL "esp32h2")
list(APPEND srcs "spi_slave_hd.c"
"dedic_gpio.c"
"i2s.c"
"rmt.c"
"sigmadelta.c"

View File

@ -78,12 +78,15 @@ static esp_err_t dedic_gpio_build_platform(uint32_t core_id)
if (s_platform[core_id]) {
// initialize platfrom members
s_platform[core_id]->spinlock = (portMUX_TYPE)portMUX_INITIALIZER_UNLOCKED;
// initial occupy_mask: 1111...100...0
s_platform[core_id]->out_occupied_mask = UINT32_MAX & ~((1 << SOC_DEDIC_GPIO_OUT_CHANNELS_NUM) - 1);
s_platform[core_id]->in_occupied_mask = UINT32_MAX & ~((1 << SOC_DEDIC_GPIO_IN_CHANNELS_NUM) - 1);
#if SOC_DEDIC_GPIO_ALLOW_REG_ACCESS
s_platform[core_id]->dev = &DEDIC_GPIO;
#endif // SOC_DEDIC_GPIO_ALLOW_REG_ACCESS
#if !SOC_DEDIC_PERIPH_AUTO_ENABLE
#if !SOC_DEDIC_PERIPH_ALWAYS_ENABLE
periph_module_enable(dedic_gpio_periph_signals.module); // enable APB clock to peripheral
#endif // !SOC_DEDIC_PERIPH_AUTO_ENABLE
#endif // !SOC_DEDIC_PERIPH_ALWAYS_ENABLE
}
}
_lock_release(&s_platform_mutexlock[core_id]);
@ -104,9 +107,9 @@ static void dedic_gpio_break_platform(uint32_t core_id)
if (s_platform[core_id]) {
free(s_platform[core_id]);
s_platform[core_id] = NULL;
#if !SOC_DEDIC_PERIPH_AUTO_ENABLE
#if !SOC_DEDIC_PERIPH_ALWAYS_ENABLE
periph_module_disable(dedic_gpio_periph_signals.module); // disable module if no GPIO channel is being used
#endif // !SOC_DEDIC_PERIPH_AUTO_ENABLE
#endif // !SOC_DEDIC_PERIPH_ALWAYS_ENABLE
}
_lock_release(&s_platform_mutexlock[core_id]);
}
@ -309,7 +312,8 @@ esp_err_t dedic_gpio_del_bundle(dedic_gpio_bundle_handle_t bundle)
portENTER_CRITICAL(&s_platform[core_id]->spinlock);
s_platform[core_id]->out_occupied_mask &= ~(bundle->out_mask);
s_platform[core_id]->in_occupied_mask &= ~(bundle->in_mask);
if (!s_platform[core_id]->in_occupied_mask && !s_platform[core_id]->out_occupied_mask) {
if (s_platform[core_id]->in_occupied_mask == (UINT32_MAX & ~((1 << SOC_DEDIC_GPIO_IN_CHANNELS_NUM) - 1)) &&
s_platform[core_id]->out_occupied_mask == (UINT32_MAX & ~((1 << SOC_DEDIC_GPIO_OUT_CHANNELS_NUM) - 1))) {
recycle_all = true;
}
portEXIT_CRITICAL(&s_platform[core_id]->spinlock);

View File

@ -255,7 +255,7 @@ config SOC_DEDIC_GPIO_IN_CHANNELS_NUM
int
default 8
config SOC_DEDIC_PERIPH_AUTO_ENABLE
config SOC_DEDIC_PERIPH_ALWAYS_ENABLE
bool
default y

View File

@ -136,7 +136,7 @@
/*-------------------------- Dedicated GPIO CAPS -----------------------------*/
#define SOC_DEDIC_GPIO_OUT_CHANNELS_NUM (8) /*!< 8 outward channels on each CPU core */
#define SOC_DEDIC_GPIO_IN_CHANNELS_NUM (8) /*!< 8 inward channels on each CPU core */
#define SOC_DEDIC_PERIPH_AUTO_ENABLE (1) /*!< The dedicated GPIO peripheral is enabled automatically */
#define SOC_DEDIC_PERIPH_ALWAYS_ENABLE (1) /*!< The dedicated GPIO (a.k.a. fast GPIO) is featured by some customized CPU instructions, which is always enabled */
/*-------------------------- I2C CAPS ----------------------------------------*/
// ESP32-C3 have 2 I2C.

View File

@ -239,7 +239,7 @@ config SOC_DEDIC_GPIO_IN_CHANNELS_NUM
int
default 8
config SOC_DEDIC_PERIPH_AUTO_ENABLE
config SOC_DEDIC_PERIPH_ALWAYS_ENABLE
bool
default y

View File

@ -131,7 +131,7 @@
/*-------------------------- Dedicated GPIO CAPS -----------------------------*/
#define SOC_DEDIC_GPIO_OUT_CHANNELS_NUM (8) /*!< 8 outward channels on each CPU core */
#define SOC_DEDIC_GPIO_IN_CHANNELS_NUM (8) /*!< 8 inward channels on each CPU core */
#define SOC_DEDIC_PERIPH_AUTO_ENABLE (1) /*!< The dedicated GPIO peripheral is enabled automatically */
#define SOC_DEDIC_PERIPH_ALWAYS_ENABLE (1) /*!< The dedicated GPIO (a.k.a. fast GPIO) is featured by some customized CPU instructions, which is always enabled */
/*-------------------------- I2C CAPS ----------------------------------------*/
// ESP32-C3 have 2 I2C.