mirror of
https://github.com/espressif/esp-idf.git
synced 2025-11-02 08:01:43 +01:00
hw_support: move rtc_ctrl from driver to hw_support
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
idf_build_get_property(target IDF_TARGET)
|
||||
|
||||
set(srcs
|
||||
"gpio.c"
|
||||
"gpio/gpio.c"
|
||||
"gpio/rtc_io.c"
|
||||
"gptimer.c"
|
||||
"i2c.c"
|
||||
"ledc.c"
|
||||
"rtc_io.c"
|
||||
"rtc_module.c"
|
||||
"sdspi_crc.c"
|
||||
"sdspi_host.c"
|
||||
"sdspi_transaction.c"
|
||||
@@ -39,11 +38,11 @@ if(CONFIG_SOC_GDMA_SUPPORTED)
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_DEDICATED_GPIO_SUPPORTED)
|
||||
list(APPEND srcs "dedic_gpio.c")
|
||||
list(APPEND srcs "gpio/dedic_gpio.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_SIGMADELTA_SUPPORTED)
|
||||
list(APPEND srcs "sigmadelta.c")
|
||||
list(APPEND srcs "gpio/sigmadelta_gpio.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_RMT_SUPPORTED)
|
||||
@@ -71,6 +70,10 @@ if(CONFIG_SOC_TWAI_SUPPORTED)
|
||||
list(APPEND srcs "twai.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_USB_SERIAL_JTAG_SUPPORTED)
|
||||
list(APPEND srcs "usb_serial_jtag.c")
|
||||
endif()
|
||||
|
||||
if(CONFIG_SOC_SPI_SUPPORT_SLAVE_HD_VER2)
|
||||
list(APPEND srcs "spi_slave_hd.c")
|
||||
endif()
|
||||
@@ -96,14 +99,12 @@ if(IDF_TARGET STREQUAL "esp32s2")
|
||||
endif()
|
||||
|
||||
if(${target} STREQUAL "esp32s3")
|
||||
list(APPEND srcs "usb_serial_jtag.c"
|
||||
"touch_sensor_common.c"
|
||||
list(APPEND srcs "touch_sensor_common.c"
|
||||
"esp32s3/touch_sensor.c")
|
||||
endif()
|
||||
|
||||
if(IDF_TARGET STREQUAL "esp32c3")
|
||||
list(APPEND srcs "usb_serial_jtag.c"
|
||||
"esp32c3/adc2_init_cal.c")
|
||||
list(APPEND srcs "esp32c3/adc2_init_cal.c")
|
||||
endif()
|
||||
|
||||
if(BOOTLOADER_BUILD)
|
||||
|
||||
8
components/driver/deprecated/driver/rtc_cntl.h
Normal file
8
components/driver/deprecated/driver/rtc_cntl.h
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#pragma once
|
||||
#warning driver/rtc_cntl.h header is no longer used, and will be removed in future versions.
|
||||
#include "esp_private/rtc_ctrl.h"
|
||||
@@ -18,7 +18,7 @@
|
||||
#include "freertos/timers.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "driver/rtc_io.h"
|
||||
#include "driver/rtc_cntl.h"
|
||||
#include "esp_private/rtc_ctrl.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/adc.h"
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "driver/rtc_io.h"
|
||||
#include "driver/touch_pad.h"
|
||||
#include "driver/rtc_cntl.h"
|
||||
#include "esp_private/rtc_ctrl.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "esp_check.h"
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "driver/rtc_io.h"
|
||||
#include "driver/touch_pad.h"
|
||||
#include "driver/rtc_cntl.h"
|
||||
#include "esp_private/rtc_ctrl.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_check.h"
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "driver/rtc_io.h"
|
||||
#include "driver/touch_pad.h"
|
||||
#include "driver/rtc_cntl.h"
|
||||
#include "esp_private/rtc_ctrl.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_check.h"
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2016-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Register a handler for specific RTC_CNTL interrupts
|
||||
*
|
||||
* Multiple handlers can be registered using this function. Whenever an
|
||||
* RTC interrupt happens, all handlers with matching rtc_intr_mask values
|
||||
* will be called.
|
||||
*
|
||||
* @param handler handler function to call
|
||||
* @param handler_arg argument to be passed to the handler
|
||||
* @param rtc_intr_mask combination of RTC_CNTL_*_INT_ENA bits indicating the
|
||||
* sources to call the handler for
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NO_MEM not enough memory to allocate handler structure
|
||||
* - other errors returned by esp_intr_alloc
|
||||
*/
|
||||
esp_err_t rtc_isr_register(intr_handler_t handler, void* handler_arg,
|
||||
uint32_t rtc_intr_mask);
|
||||
/**
|
||||
* @brief Deregister the handler previously registered using rtc_isr_register
|
||||
* @param handler handler function to call (as passed to rtc_isr_register)
|
||||
* @param handler_arg argument of the handler (as passed to rtc_isr_register)
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE if a handler matching both handler and
|
||||
* handler_arg isn't registered
|
||||
*/
|
||||
esp_err_t rtc_isr_deregister(intr_handler_t handler, void* handler_arg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,126 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2016-2021 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_types.h"
|
||||
#include "esp_log.h"
|
||||
#include "soc/rtc_periph.h"
|
||||
#include "soc/syscon_periph.h"
|
||||
#include "soc/rtc.h"
|
||||
#include "soc/periph_defs.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/timers.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "sys/lock.h"
|
||||
#include "driver/rtc_cntl.h"
|
||||
|
||||
#ifndef NDEBUG
|
||||
// Enable built-in checks in queue.h in debug builds
|
||||
#define INVARIANTS
|
||||
#endif
|
||||
#include "sys/queue.h"
|
||||
|
||||
portMUX_TYPE rtc_spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
|
||||
/*---------------------------------------------------------------
|
||||
INTERRUPT HANDLER
|
||||
---------------------------------------------------------------*/
|
||||
|
||||
|
||||
typedef struct rtc_isr_handler_ {
|
||||
uint32_t mask;
|
||||
intr_handler_t handler;
|
||||
void* handler_arg;
|
||||
SLIST_ENTRY(rtc_isr_handler_) next;
|
||||
} rtc_isr_handler_t;
|
||||
|
||||
static SLIST_HEAD(rtc_isr_handler_list_, rtc_isr_handler_) s_rtc_isr_handler_list =
|
||||
SLIST_HEAD_INITIALIZER(s_rtc_isr_handler_list);
|
||||
portMUX_TYPE s_rtc_isr_handler_list_lock = portMUX_INITIALIZER_UNLOCKED;
|
||||
static intr_handle_t s_rtc_isr_handle;
|
||||
|
||||
static void rtc_isr(void* arg)
|
||||
{
|
||||
uint32_t status = REG_READ(RTC_CNTL_INT_ST_REG);
|
||||
rtc_isr_handler_t* it;
|
||||
portENTER_CRITICAL_ISR(&s_rtc_isr_handler_list_lock);
|
||||
SLIST_FOREACH(it, &s_rtc_isr_handler_list, next) {
|
||||
if (it->mask & status) {
|
||||
portEXIT_CRITICAL_ISR(&s_rtc_isr_handler_list_lock);
|
||||
(*it->handler)(it->handler_arg);
|
||||
portENTER_CRITICAL_ISR(&s_rtc_isr_handler_list_lock);
|
||||
}
|
||||
}
|
||||
portEXIT_CRITICAL_ISR(&s_rtc_isr_handler_list_lock);
|
||||
REG_WRITE(RTC_CNTL_INT_CLR_REG, status);
|
||||
}
|
||||
|
||||
static esp_err_t rtc_isr_ensure_installed(void)
|
||||
{
|
||||
esp_err_t err = ESP_OK;
|
||||
portENTER_CRITICAL(&s_rtc_isr_handler_list_lock);
|
||||
if (s_rtc_isr_handle) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
REG_WRITE(RTC_CNTL_INT_ENA_REG, 0);
|
||||
REG_WRITE(RTC_CNTL_INT_CLR_REG, UINT32_MAX);
|
||||
err = esp_intr_alloc(ETS_RTC_CORE_INTR_SOURCE, 0, &rtc_isr, NULL, &s_rtc_isr_handle);
|
||||
if (err != ESP_OK) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
out:
|
||||
portEXIT_CRITICAL(&s_rtc_isr_handler_list_lock);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
esp_err_t rtc_isr_register(intr_handler_t handler, void* handler_arg, uint32_t rtc_intr_mask)
|
||||
{
|
||||
esp_err_t err = rtc_isr_ensure_installed();
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
rtc_isr_handler_t* item = malloc(sizeof(*item));
|
||||
if (item == NULL) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
item->handler = handler;
|
||||
item->handler_arg = handler_arg;
|
||||
item->mask = rtc_intr_mask;
|
||||
portENTER_CRITICAL(&s_rtc_isr_handler_list_lock);
|
||||
SLIST_INSERT_HEAD(&s_rtc_isr_handler_list, item, next);
|
||||
portEXIT_CRITICAL(&s_rtc_isr_handler_list_lock);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t rtc_isr_deregister(intr_handler_t handler, void* handler_arg)
|
||||
{
|
||||
rtc_isr_handler_t* it;
|
||||
rtc_isr_handler_t* prev = NULL;
|
||||
bool found = false;
|
||||
portENTER_CRITICAL(&s_rtc_isr_handler_list_lock);
|
||||
SLIST_FOREACH(it, &s_rtc_isr_handler_list, next) {
|
||||
if (it->handler == handler && it->handler_arg == handler_arg) {
|
||||
if (it == SLIST_FIRST(&s_rtc_isr_handler_list)) {
|
||||
SLIST_REMOVE_HEAD(&s_rtc_isr_handler_list, next);
|
||||
} else {
|
||||
SLIST_REMOVE_AFTER(prev, next);
|
||||
}
|
||||
found = true;
|
||||
free(it);
|
||||
break;
|
||||
}
|
||||
prev = it;
|
||||
}
|
||||
portEXIT_CRITICAL(&s_rtc_isr_handler_list_lock);
|
||||
return found ? ESP_OK : ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "driver/rtc_io.h"
|
||||
#include "driver/touch_pad.h"
|
||||
#include "driver/rtc_cntl.h"
|
||||
#include "esp_private/rtc_ctrl.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "hal/touch_sensor_types.h"
|
||||
#include "hal/touch_sensor_hal.h"
|
||||
|
||||
Reference in New Issue
Block a user