change(esp_hw_support): optimize periph ctrl memory (iram or flash) usage control by PERIPH_CTRL_FUNC_IN_IRAM

This commit is contained in:
Li Shuai
2025-03-05 15:14:37 +08:00
parent 1e54f38b51
commit e0920f621d
2 changed files with 13 additions and 7 deletions

View File

@@ -42,6 +42,12 @@ entries:
rtc_wdt (noflash_text) rtc_wdt (noflash_text)
if PERIPH_CTRL_FUNC_IN_IRAM = y: if PERIPH_CTRL_FUNC_IN_IRAM = y:
periph_ctrl:periph_module_reset (noflash) periph_ctrl:periph_module_reset (noflash)
periph_ctrl:periph_rcc_enter (noflash)
periph_ctrl:periph_rcc_exit (noflash)
periph_ctrl:periph_rcc_acquire_enter (noflash)
periph_ctrl:periph_rcc_acquire_exit (noflash)
periph_ctrl:periph_rcc_release_enter (noflash)
periph_ctrl:periph_rcc_release_exit (noflash)
if PERIPH_CTRL_FUNC_IN_IRAM = y && ESP_WIFI_ENABLED = y: if PERIPH_CTRL_FUNC_IN_IRAM = y && ESP_WIFI_ENABLED = y:
periph_ctrl: wifi_module_enable (noflash) periph_ctrl: wifi_module_enable (noflash)
periph_ctrl: wifi_module_disable (noflash) periph_ctrl: wifi_module_disable (noflash)

View File

@@ -21,35 +21,35 @@ static portMUX_TYPE periph_spinlock = portMUX_INITIALIZER_UNLOCKED;
static uint8_t ref_counts[PERIPH_MODULE_MAX] = {0}; static uint8_t ref_counts[PERIPH_MODULE_MAX] = {0};
IRAM_ATTR void periph_rcc_enter(void) void periph_rcc_enter(void)
{ {
portENTER_CRITICAL_SAFE(&periph_spinlock); portENTER_CRITICAL_SAFE(&periph_spinlock);
} }
IRAM_ATTR void periph_rcc_exit(void) void periph_rcc_exit(void)
{ {
portEXIT_CRITICAL_SAFE(&periph_spinlock); portEXIT_CRITICAL_SAFE(&periph_spinlock);
} }
IRAM_ATTR uint8_t periph_rcc_acquire_enter(periph_module_t periph) uint8_t periph_rcc_acquire_enter(periph_module_t periph)
{ {
periph_rcc_enter(); periph_rcc_enter();
return ref_counts[periph]; return ref_counts[periph];
} }
IRAM_ATTR void periph_rcc_acquire_exit(periph_module_t periph, uint8_t ref_count) void periph_rcc_acquire_exit(periph_module_t periph, uint8_t ref_count)
{ {
ref_counts[periph] = ++ref_count; ref_counts[periph] = ++ref_count;
periph_rcc_exit(); periph_rcc_exit();
} }
IRAM_ATTR uint8_t periph_rcc_release_enter(periph_module_t periph) uint8_t periph_rcc_release_enter(periph_module_t periph)
{ {
periph_rcc_enter(); periph_rcc_enter();
return ref_counts[periph] - 1; return ref_counts[periph] - 1;
} }
IRAM_ATTR void periph_rcc_release_exit(periph_module_t periph, uint8_t ref_count) void periph_rcc_release_exit(periph_module_t periph, uint8_t ref_count)
{ {
ref_counts[periph] = ref_count; ref_counts[periph] = ref_count;
periph_rcc_exit(); periph_rcc_exit();