mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-03 00:21:44 +01:00
hw_support: move periph_ctrl from driver to hw_support
This commit is contained in:
@@ -6,7 +6,6 @@ set(srcs
|
||||
"i2c.c"
|
||||
"ledc.c"
|
||||
"legacy_new_driver_coexist.c"
|
||||
"periph_ctrl.c"
|
||||
"rtc_io.c"
|
||||
"rtc_module.c"
|
||||
"sdspi_crc.c"
|
||||
|
||||
@@ -90,6 +90,7 @@ menu "Driver configurations"
|
||||
config TWAI_ISR_IN_IRAM
|
||||
bool "Place TWAI ISR function into IRAM"
|
||||
default n
|
||||
select PERIPH_CTRL_FUNC_IN_IRAM if TWAI_ERRATA_FIX_RX_FRAME_INVALID || TWAI_ERRATA_FIX_RX_FIFO_CORRUPT
|
||||
help
|
||||
Place the TWAI ISR in to IRAM. This will allow the ISR to avoid
|
||||
cache misses, and also be able to run whilst the cache is disabled
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "soc/periph_defs.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Enable peripheral module by un-gating the clock and de-asserting the reset signal.
|
||||
*
|
||||
* @param[in] periph Peripheral module
|
||||
*
|
||||
* @note If @c periph_module_enable() is called a number of times,
|
||||
* @c periph_module_disable() has to be called the same number of times,
|
||||
* in order to put the peripheral into disabled state.
|
||||
*/
|
||||
void periph_module_enable(periph_module_t periph);
|
||||
|
||||
/**
|
||||
* @brief Disable peripheral module by gating the clock and asserting the reset signal.
|
||||
*
|
||||
* @param[in] periph Peripheral module
|
||||
*
|
||||
* @note If @c periph_module_enable() is called a number of times,
|
||||
* @c periph_module_disable() has to be called the same number of times,
|
||||
* in order to put the peripheral into disabled state.
|
||||
*/
|
||||
void periph_module_disable(periph_module_t periph);
|
||||
|
||||
/**
|
||||
* @brief Reset peripheral module by asserting and de-asserting the reset signal.
|
||||
*
|
||||
* @param[in] periph Peripheral module
|
||||
*
|
||||
* @note Calling this function does not enable or disable the clock for the module.
|
||||
*/
|
||||
void periph_module_reset(periph_module_t periph);
|
||||
|
||||
/**
|
||||
* @brief Enable Wi-Fi and BT common module
|
||||
*
|
||||
* @note If @c wifi_bt_common_module_enable() is called a number of times,
|
||||
* @c wifi_bt_common_module_disable() has to be called the same number of times,
|
||||
* in order to put the peripheral into disabled state.
|
||||
*/
|
||||
void wifi_bt_common_module_enable(void);
|
||||
|
||||
/**
|
||||
* @brief Disable Wi-Fi and BT common module
|
||||
*
|
||||
* @note If @c wifi_bt_common_module_enable() is called a number of times,
|
||||
* @c wifi_bt_common_module_disable() has to be called the same number of times,
|
||||
* in order to put the peripheral into disabled state.
|
||||
*/
|
||||
void wifi_bt_common_module_disable(void);
|
||||
|
||||
/**
|
||||
* @brief Enable Wi-Fi module
|
||||
*
|
||||
* @note Calling this function will only enable Wi-Fi module.
|
||||
*/
|
||||
void wifi_module_enable(void);
|
||||
|
||||
/**
|
||||
* @brief Disable Wi-Fi module
|
||||
*
|
||||
* @note Calling this function will only disable Wi-Fi module.
|
||||
*/
|
||||
void wifi_module_disable(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,12 +1,6 @@
|
||||
|
||||
[mapping:driver]
|
||||
archive: libdriver.a
|
||||
entries:
|
||||
# TWAI workarounds that require periph_module_reset() won't work if cache is disabled due to the use of switch jump
|
||||
# tables in periph_module_reset(). We prevent any part of periph_module_reset() (either text or RO data) from being
|
||||
# placed in flash.
|
||||
if TWAI_ISR_IN_IRAM = y && (TWAI_ERRATA_FIX_RX_FRAME_INVALID = y || TWAI_ERRATA_FIX_RX_FIFO_CORRUPT = y):
|
||||
periph_ctrl: periph_module_reset (noflash)
|
||||
if GPTIMER_CTRL_FUNC_IN_IRAM = y:
|
||||
gptimer: gptimer_set_raw_count (noflash)
|
||||
gptimer: gptimer_get_raw_count (noflash)
|
||||
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "hal/clk_gate_ll.h"
|
||||
#include "esp_attr.h"
|
||||
#include "esp_private/periph_ctrl.h"
|
||||
|
||||
static portMUX_TYPE periph_spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
|
||||
static uint8_t ref_counts[PERIPH_MODULE_MAX] = {0};
|
||||
|
||||
void periph_module_enable(periph_module_t periph)
|
||||
{
|
||||
assert(periph < PERIPH_MODULE_MAX);
|
||||
portENTER_CRITICAL_SAFE(&periph_spinlock);
|
||||
if (ref_counts[periph] == 0) {
|
||||
periph_ll_enable_clk_clear_rst(periph);
|
||||
}
|
||||
ref_counts[periph]++;
|
||||
portEXIT_CRITICAL_SAFE(&periph_spinlock);
|
||||
}
|
||||
|
||||
void periph_module_disable(periph_module_t periph)
|
||||
{
|
||||
assert(periph < PERIPH_MODULE_MAX);
|
||||
portENTER_CRITICAL_SAFE(&periph_spinlock);
|
||||
ref_counts[periph]--;
|
||||
if (ref_counts[periph] == 0) {
|
||||
periph_ll_disable_clk_set_rst(periph);
|
||||
}
|
||||
portEXIT_CRITICAL_SAFE(&periph_spinlock);
|
||||
}
|
||||
|
||||
void periph_module_reset(periph_module_t periph)
|
||||
{
|
||||
assert(periph < PERIPH_MODULE_MAX);
|
||||
portENTER_CRITICAL_SAFE(&periph_spinlock);
|
||||
periph_ll_reset(periph);
|
||||
portEXIT_CRITICAL_SAFE(&periph_spinlock);
|
||||
}
|
||||
|
||||
#if CONFIG_ESP32_WIFI_ENABLED
|
||||
IRAM_ATTR void wifi_bt_common_module_enable(void)
|
||||
{
|
||||
portENTER_CRITICAL_SAFE(&periph_spinlock);
|
||||
if (ref_counts[PERIPH_WIFI_BT_COMMON_MODULE] == 0) {
|
||||
periph_ll_wifi_bt_module_enable_clk_clear_rst();
|
||||
}
|
||||
ref_counts[PERIPH_WIFI_BT_COMMON_MODULE]++;
|
||||
portEXIT_CRITICAL_SAFE(&periph_spinlock);
|
||||
}
|
||||
|
||||
IRAM_ATTR void wifi_bt_common_module_disable(void)
|
||||
{
|
||||
portENTER_CRITICAL_SAFE(&periph_spinlock);
|
||||
ref_counts[PERIPH_WIFI_BT_COMMON_MODULE]--;
|
||||
if (ref_counts[PERIPH_WIFI_BT_COMMON_MODULE] == 0) {
|
||||
periph_ll_wifi_bt_module_disable_clk_set_rst();
|
||||
}
|
||||
portEXIT_CRITICAL_SAFE(&periph_spinlock);
|
||||
}
|
||||
|
||||
void wifi_module_enable(void)
|
||||
{
|
||||
portENTER_CRITICAL_SAFE(&periph_spinlock);
|
||||
periph_ll_wifi_module_enable_clk_clear_rst();
|
||||
portEXIT_CRITICAL_SAFE(&periph_spinlock);
|
||||
}
|
||||
|
||||
void wifi_module_disable(void)
|
||||
{
|
||||
portENTER_CRITICAL_SAFE(&periph_spinlock);
|
||||
periph_ll_wifi_module_disable_clk_set_rst();
|
||||
portEXIT_CRITICAL_SAFE(&periph_spinlock);
|
||||
}
|
||||
#endif // CONFIG_ESP32_WIFI_ENABLED
|
||||
Reference in New Issue
Block a user