mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-23 17:17:14 +00:00
misc adjustment of esp32 component
This commit is contained in:
@@ -20,12 +20,10 @@ else()
|
||||
"esp_adapter.c"
|
||||
"esp_timer_esp32.c"
|
||||
"esp_himem.c"
|
||||
"freertos_hooks.c"
|
||||
"gdbstub.c"
|
||||
"hw_random.c"
|
||||
"int_wdt.c"
|
||||
"intr_alloc.c"
|
||||
"ipc.c"
|
||||
"panic.c"
|
||||
"pm_esp32.c"
|
||||
"pm_trace.c"
|
||||
@@ -70,7 +68,6 @@ else()
|
||||
|
||||
target_linker_script(${COMPONENT_TARGET} "ld/esp32.peripherals.ld")
|
||||
|
||||
target_link_libraries(${COMPONENT_TARGET} "${CMAKE_CURRENT_SOURCE_DIR}/libhal.a")
|
||||
target_link_libraries(${COMPONENT_TARGET} gcc)
|
||||
target_link_libraries(${COMPONENT_TARGET} "-u call_user_start_cpu0")
|
||||
|
||||
|
@@ -25,7 +25,7 @@
|
||||
#include <stdbool.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_intr.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_attr.h"
|
||||
#include "soc/dport_reg.h"
|
||||
#include "sdkconfig.h"
|
||||
|
@@ -17,8 +17,7 @@ LINKER_SCRIPTS += $(COMPONENT_BUILD_DIR)/esp32.project.ld esp32.peripherals.ld
|
||||
#ld_include_panic_highint_hdl is added as an undefined symbol because otherwise the
|
||||
#linker will ignore panic_highint_hdl.S as it has no other files depending on any
|
||||
#symbols in it.
|
||||
COMPONENT_ADD_LDFLAGS += $(COMPONENT_PATH)/libhal.a \
|
||||
-L $(COMPONENT_PATH)/ld \
|
||||
COMPONENT_ADD_LDFLAGS += -L $(COMPONENT_PATH)/ld \
|
||||
-T esp32_out.ld \
|
||||
-u ld_include_panic_highint_hdl \
|
||||
$(addprefix -T ,$(LINKER_SCRIPTS)) \
|
||||
|
@@ -60,7 +60,7 @@
|
||||
#include "esp_phy_init.h"
|
||||
#include "esp32/cache_err_int.h"
|
||||
#include "esp_coexist_internal.h"
|
||||
#include "esp_panic.h"
|
||||
#include "esp_debug_helpers.h"
|
||||
#include "esp_core_dump.h"
|
||||
#include "esp_app_trace.h"
|
||||
#include "esp_private/dbg_stubs.h"
|
||||
|
@@ -16,7 +16,7 @@
|
||||
|
||||
#include "esp_attr.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_intr.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
|
||||
#include "esp32/rom/ets_sys.h"
|
||||
|
@@ -25,7 +25,7 @@
|
||||
#include <sdkconfig.h>
|
||||
#include "esp_attr.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_intr.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp32/rom/ets_sys.h"
|
||||
#include "esp32/rom/uart.h"
|
||||
|
||||
|
@@ -17,7 +17,7 @@
|
||||
#include <xtensa/corebits.h>
|
||||
#include <xtensa/config/system.h>
|
||||
#include "freertos/xtensa_context.h"
|
||||
#include "esp_panic.h"
|
||||
#include "esp_private/panic_reason.h"
|
||||
#include "sdkconfig.h"
|
||||
#include "soc/soc.h"
|
||||
#include "soc/dport_reg.h"
|
||||
@@ -137,8 +137,8 @@ xt_highint4:
|
||||
/* This section is for dport access register protection */
|
||||
/* Allocate exception frame and save minimal context. */
|
||||
/* Because the interrupt cause code has protection that only
|
||||
allows one cpu to enter in the dport section of the L4
|
||||
interrupt at one time, there's no need to have two
|
||||
allows one cpu to enter in the dport section of the L4
|
||||
interrupt at one time, there's no need to have two
|
||||
_l4_intr_stack for each cpu */
|
||||
|
||||
/* This int is edge-triggered and needs clearing. */
|
||||
@@ -192,7 +192,7 @@ xt_highint4:
|
||||
#endif // CONFIG_FREERTOS_UNICORE
|
||||
|
||||
/* The linker has no reason to link in this file; all symbols it exports are already defined
|
||||
(weakly!) in the default int handler. Define a symbol here so we can use it to have the
|
||||
(weakly!) in the default int handler. Define a symbol here so we can use it to have the
|
||||
linker inspect this anyway. */
|
||||
|
||||
.global ld_include_panic_highint_hdl
|
||||
|
@@ -29,7 +29,7 @@
|
||||
#include "esp_types.h"
|
||||
#include "esp_system.h"
|
||||
#include "esp_task.h"
|
||||
#include "esp_intr.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_attr.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_heap_caps.h"
|
||||
|
@@ -1,64 +0,0 @@
|
||||
@COMMENT@
|
||||
|
||||
#include <string.h>
|
||||
#if __has_include("soc/soc.h")
|
||||
#include "soc/soc.h"
|
||||
#endif
|
||||
@HEADERS@
|
||||
|
||||
#ifdef CONFIG_ESP_ERR_TO_NAME_LOOKUP
|
||||
#define ERR_TBL_IT(err) {err, #err}
|
||||
|
||||
typedef struct {
|
||||
esp_err_t code;
|
||||
const char *msg;
|
||||
} esp_err_msg_t;
|
||||
|
||||
static const esp_err_msg_t esp_err_msg_table[] = {
|
||||
@ERROR_ITEMS@
|
||||
};
|
||||
#endif //CONFIG_ESP_ERR_TO_NAME_LOOKUP
|
||||
|
||||
static const char esp_unknown_msg[] =
|
||||
#ifdef CONFIG_ESP_ERR_TO_NAME_LOOKUP
|
||||
"ERROR";
|
||||
#else
|
||||
"UNKNOWN ERROR";
|
||||
#endif //CONFIG_ESP_ERR_TO_NAME_LOOKUP
|
||||
|
||||
const char *esp_err_to_name(esp_err_t code)
|
||||
{
|
||||
#ifdef CONFIG_ESP_ERR_TO_NAME_LOOKUP
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sizeof(esp_err_msg_table)/sizeof(esp_err_msg_table[0]); ++i) {
|
||||
if (esp_err_msg_table[i].code == code) {
|
||||
return esp_err_msg_table[i].msg;
|
||||
}
|
||||
}
|
||||
#endif //CONFIG_ESP_ERR_TO_NAME_LOOKUP
|
||||
|
||||
return esp_unknown_msg;
|
||||
}
|
||||
|
||||
const char *esp_err_to_name_r(esp_err_t code, char *buf, size_t buflen)
|
||||
{
|
||||
#ifdef CONFIG_ESP_ERR_TO_NAME_LOOKUP
|
||||
int i;
|
||||
|
||||
for (i = 0; i < sizeof(esp_err_msg_table)/sizeof(esp_err_msg_table[0]); ++i) {
|
||||
if (esp_err_msg_table[i].code == code) {
|
||||
strlcpy(buf, esp_err_msg_table[i].msg, buflen);
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
#endif //CONFIG_ESP_ERR_TO_NAME_LOOKUP
|
||||
|
||||
if (strerror_r(code, buf, buflen) == 0) {
|
||||
return buf;
|
||||
}
|
||||
|
||||
snprintf(buf, buflen, "%s 0x%x(%d)", esp_unknown_msg, code, code);
|
||||
|
||||
return buf;
|
||||
}
|
@@ -1,151 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "esp_attr.h"
|
||||
#include "esp_freertos_hooks.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_pm.h"
|
||||
#include "esp_private/pm_impl.h"
|
||||
|
||||
//We use just a static array here because it's not expected many components will need
|
||||
//an idle or tick hook.
|
||||
#define MAX_HOOKS 8
|
||||
|
||||
static portMUX_TYPE hooks_spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
static esp_freertos_idle_cb_t idle_cb[portNUM_PROCESSORS][MAX_HOOKS]={0};
|
||||
static esp_freertos_tick_cb_t tick_cb[portNUM_PROCESSORS][MAX_HOOKS]={0};
|
||||
|
||||
void IRAM_ATTR esp_vApplicationTickHook()
|
||||
{
|
||||
int n;
|
||||
int core = xPortGetCoreID();
|
||||
for (n=0; n<MAX_HOOKS; n++) {
|
||||
if (tick_cb[core][n]!=NULL) {
|
||||
tick_cb[core][n]();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void esp_vApplicationIdleHook()
|
||||
{
|
||||
bool can_go_idle=true;
|
||||
int core = xPortGetCoreID();
|
||||
for (int n = 0; n < MAX_HOOKS; n++) {
|
||||
if (idle_cb[core][n] != NULL && !idle_cb[core][n]()) {
|
||||
can_go_idle = false;
|
||||
}
|
||||
}
|
||||
if (!can_go_idle) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_PM_ENABLE
|
||||
esp_pm_impl_idle_hook();
|
||||
#endif
|
||||
|
||||
esp_pm_impl_waiti();
|
||||
}
|
||||
|
||||
esp_err_t esp_register_freertos_idle_hook_for_cpu(esp_freertos_idle_cb_t new_idle_cb, UBaseType_t cpuid)
|
||||
{
|
||||
if(cpuid >= portNUM_PROCESSORS){
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
portENTER_CRITICAL(&hooks_spinlock);
|
||||
for(int n = 0; n < MAX_HOOKS; n++){
|
||||
if (idle_cb[cpuid][n]==NULL) {
|
||||
idle_cb[cpuid][n]=new_idle_cb;
|
||||
portEXIT_CRITICAL(&hooks_spinlock);
|
||||
return ESP_OK;
|
||||
}
|
||||
}
|
||||
portEXIT_CRITICAL(&hooks_spinlock);
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
esp_err_t esp_register_freertos_idle_hook(esp_freertos_idle_cb_t new_idle_cb)
|
||||
{
|
||||
return esp_register_freertos_idle_hook_for_cpu(new_idle_cb, xPortGetCoreID());
|
||||
}
|
||||
|
||||
esp_err_t esp_register_freertos_tick_hook_for_cpu(esp_freertos_tick_cb_t new_tick_cb, UBaseType_t cpuid)
|
||||
{
|
||||
if(cpuid >= portNUM_PROCESSORS){
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
portENTER_CRITICAL(&hooks_spinlock);
|
||||
for(int n = 0; n < MAX_HOOKS; n++){
|
||||
if (tick_cb[cpuid][n]==NULL) {
|
||||
tick_cb[cpuid][n]=new_tick_cb;
|
||||
portEXIT_CRITICAL(&hooks_spinlock);
|
||||
return ESP_OK;
|
||||
}
|
||||
}
|
||||
portEXIT_CRITICAL(&hooks_spinlock);
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
esp_err_t esp_register_freertos_tick_hook(esp_freertos_tick_cb_t new_tick_cb)
|
||||
{
|
||||
return esp_register_freertos_tick_hook_for_cpu(new_tick_cb, xPortGetCoreID());
|
||||
}
|
||||
|
||||
void esp_deregister_freertos_idle_hook_for_cpu(esp_freertos_idle_cb_t old_idle_cb, UBaseType_t cpuid)
|
||||
{
|
||||
portENTER_CRITICAL(&hooks_spinlock);
|
||||
if(cpuid >= portNUM_PROCESSORS){
|
||||
return;
|
||||
}
|
||||
for(int n = 0; n < MAX_HOOKS; n++){
|
||||
if(idle_cb[cpuid][n] == old_idle_cb) idle_cb[cpuid][n] = NULL;
|
||||
}
|
||||
portEXIT_CRITICAL(&hooks_spinlock);
|
||||
}
|
||||
|
||||
void esp_deregister_freertos_idle_hook(esp_freertos_idle_cb_t old_idle_cb)
|
||||
{
|
||||
portENTER_CRITICAL(&hooks_spinlock);
|
||||
for(int m = 0; m < portNUM_PROCESSORS; m++) {
|
||||
esp_deregister_freertos_idle_hook_for_cpu(old_idle_cb, m);
|
||||
}
|
||||
portEXIT_CRITICAL(&hooks_spinlock);
|
||||
}
|
||||
|
||||
void esp_deregister_freertos_tick_hook_for_cpu(esp_freertos_tick_cb_t old_tick_cb, UBaseType_t cpuid)
|
||||
{
|
||||
portENTER_CRITICAL(&hooks_spinlock);
|
||||
if(cpuid >= portNUM_PROCESSORS){
|
||||
return;
|
||||
}
|
||||
for(int n = 0; n < MAX_HOOKS; n++){
|
||||
if(tick_cb[cpuid][n] == old_tick_cb) tick_cb[cpuid][n] = NULL;
|
||||
}
|
||||
portEXIT_CRITICAL(&hooks_spinlock);
|
||||
}
|
||||
|
||||
void esp_deregister_freertos_tick_hook(esp_freertos_tick_cb_t old_tick_cb)
|
||||
{
|
||||
portENTER_CRITICAL(&hooks_spinlock);
|
||||
for(int m = 0; m < portNUM_PROCESSORS; m++){
|
||||
esp_deregister_freertos_tick_hook_for_cpu(old_tick_cb, m);
|
||||
}
|
||||
portEXIT_CRITICAL(&hooks_spinlock);
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@
|
||||
#include "soc/uart_reg.h"
|
||||
#include "soc/io_mux_reg.h"
|
||||
#include "esp_private/gdbstub.h"
|
||||
#include "esp_panic.h"
|
||||
#include "esp_debug_helpers.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
@@ -1,94 +0,0 @@
|
||||
// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file esp_deep_sleep.h
|
||||
* @brief legacy definitions of esp_deep_sleep APIs
|
||||
*
|
||||
* This file provides compatibility for applications using esp_deep_sleep_* APIs.
|
||||
* New applications should use functions defined in "esp_sleep.h" instead.
|
||||
* These functions and types will be deprecated at some point.
|
||||
*/
|
||||
|
||||
#warning esp_deep_sleep.h will be deprecated in the next release. Use esp_sleep.h instead.
|
||||
|
||||
#include "esp_sleep.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
typedef esp_sleep_pd_domain_t esp_deep_sleep_pd_domain_t;
|
||||
typedef esp_sleep_pd_option_t esp_deep_sleep_pd_option_t;
|
||||
typedef esp_sleep_ext1_wakeup_mode_t esp_ext1_wakeup_mode_t;
|
||||
typedef esp_sleep_wakeup_cause_t esp_deep_sleep_wakeup_cause_t;
|
||||
|
||||
inline static esp_err_t esp_deep_sleep_enable_ulp_wakeup(void)
|
||||
{
|
||||
return esp_sleep_enable_ulp_wakeup();
|
||||
}
|
||||
|
||||
inline static esp_err_t esp_deep_sleep_enable_timer_wakeup(uint64_t time_in_us)
|
||||
{
|
||||
return esp_sleep_enable_timer_wakeup(time_in_us);
|
||||
}
|
||||
|
||||
inline static esp_err_t esp_deep_sleep_enable_touchpad_wakeup(void)
|
||||
{
|
||||
return esp_sleep_enable_touchpad_wakeup();
|
||||
}
|
||||
|
||||
inline static touch_pad_t esp_deep_sleep_get_touchpad_wakeup_status()
|
||||
{
|
||||
return esp_sleep_get_touchpad_wakeup_status();
|
||||
}
|
||||
|
||||
inline static esp_err_t esp_deep_sleep_enable_ext0_wakeup(gpio_num_t gpio_num, int level)
|
||||
{
|
||||
return esp_sleep_enable_ext0_wakeup(gpio_num, level);
|
||||
}
|
||||
|
||||
inline static esp_err_t esp_deep_sleep_enable_ext1_wakeup(uint64_t mask, esp_ext1_wakeup_mode_t mode)
|
||||
{
|
||||
return esp_sleep_enable_ext1_wakeup(mask, mode);
|
||||
}
|
||||
|
||||
inline static esp_err_t esp_deep_sleep_pd_config(
|
||||
esp_deep_sleep_pd_domain_t domain,
|
||||
esp_deep_sleep_pd_option_t option)
|
||||
{
|
||||
return esp_sleep_pd_config(domain, option);
|
||||
}
|
||||
|
||||
inline static esp_deep_sleep_wakeup_cause_t esp_deep_sleep_get_wakeup_cause()
|
||||
{
|
||||
return esp_sleep_get_wakeup_cause();
|
||||
}
|
||||
|
||||
#define ESP_DEEP_SLEEP_WAKEUP_UNDEFINED ESP_SLEEP_WAKEUP_UNDEFINED
|
||||
#define ESP_DEEP_SLEEP_WAKEUP_EXT0 ESP_SLEEP_WAKEUP_EXT0
|
||||
#define ESP_DEEP_SLEEP_WAKEUP_EXT1 ESP_SLEEP_WAKEUP_EXT1
|
||||
#define ESP_DEEP_SLEEP_WAKEUP_TIMER ESP_SLEEP_WAKEUP_TIMER
|
||||
#define ESP_DEEP_SLEEP_WAKEUP_TOUCHPAD ESP_SLEEP_WAKEUP_TOUCHPAD
|
||||
#define ESP_DEEP_SLEEP_WAKEUP_ULP ESP_SLEEP_WAKEUP_ULP
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@@ -1,2 +0,0 @@
|
||||
#warning esp_deepsleep.h has been renamed to esp_sleep.h, please update include directives
|
||||
#include "esp_sleep.h"
|
@@ -1,131 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_FREERTOS_HOOKS_H__
|
||||
#define __ESP_FREERTOS_HOOKS_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*
|
||||
Definitions for the tickhook and idlehook callbacks
|
||||
*/
|
||||
typedef bool (*esp_freertos_idle_cb_t)();
|
||||
typedef void (*esp_freertos_tick_cb_t)();
|
||||
|
||||
/**
|
||||
* @brief Register a callback to be called from the specified core's idle hook.
|
||||
* The callback should return true if it should be called by the idle hook
|
||||
* once per interrupt (or FreeRTOS tick), and return false if it should
|
||||
* be called repeatedly as fast as possible by the idle hook.
|
||||
*
|
||||
* @warning Idle callbacks MUST NOT, UNDER ANY CIRCUMSTANCES, CALL
|
||||
* A FUNCTION THAT MIGHT BLOCK.
|
||||
*
|
||||
* @param[in] new_idle_cb Callback to be called
|
||||
* @param[in] cpuid id of the core
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Callback registered to the specified core's idle hook
|
||||
* - ESP_ERR_NO_MEM: No more space on the specified core's idle hook to register callback
|
||||
* - ESP_ERR_INVALID_ARG: cpuid is invalid
|
||||
*/
|
||||
esp_err_t esp_register_freertos_idle_hook_for_cpu(esp_freertos_idle_cb_t new_idle_cb, UBaseType_t cpuid);
|
||||
|
||||
/**
|
||||
* @brief Register a callback to the idle hook of the core that calls this function.
|
||||
* The callback should return true if it should be called by the idle hook
|
||||
* once per interrupt (or FreeRTOS tick), and return false if it should
|
||||
* be called repeatedly as fast as possible by the idle hook.
|
||||
*
|
||||
* @warning Idle callbacks MUST NOT, UNDER ANY CIRCUMSTANCES, CALL
|
||||
* A FUNCTION THAT MIGHT BLOCK.
|
||||
*
|
||||
* @param[in] new_idle_cb Callback to be called
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Callback registered to the calling core's idle hook
|
||||
* - ESP_ERR_NO_MEM: No more space on the calling core's idle hook to register callback
|
||||
*/
|
||||
esp_err_t esp_register_freertos_idle_hook(esp_freertos_idle_cb_t new_idle_cb);
|
||||
|
||||
/**
|
||||
* @brief Register a callback to be called from the specified core's tick hook.
|
||||
*
|
||||
* @param[in] new_tick_cb Callback to be called
|
||||
* @param[in] cpuid id of the core
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Callback registered to specified core's tick hook
|
||||
* - ESP_ERR_NO_MEM: No more space on the specified core's tick hook to register the callback
|
||||
* - ESP_ERR_INVALID_ARG: cpuid is invalid
|
||||
*/
|
||||
esp_err_t esp_register_freertos_tick_hook_for_cpu(esp_freertos_tick_cb_t new_tick_cb, UBaseType_t cpuid);
|
||||
|
||||
/**
|
||||
* @brief Register a callback to be called from the calling core's tick hook.
|
||||
*
|
||||
* @param[in] new_tick_cb Callback to be called
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Callback registered to the calling core's tick hook
|
||||
* - ESP_ERR_NO_MEM: No more space on the calling core's tick hook to register the callback
|
||||
*/
|
||||
esp_err_t esp_register_freertos_tick_hook(esp_freertos_tick_cb_t new_tick_cb);
|
||||
|
||||
/**
|
||||
* @brief Unregister an idle callback from the idle hook of the specified core
|
||||
*
|
||||
* @param[in] old_idle_cb Callback to be unregistered
|
||||
* @param[in] cpuid id of the core
|
||||
*/
|
||||
void esp_deregister_freertos_idle_hook_for_cpu(esp_freertos_idle_cb_t old_idle_cb, UBaseType_t cpuid);
|
||||
|
||||
/**
|
||||
* @brief Unregister an idle callback. If the idle callback is registered to
|
||||
* the idle hooks of both cores, the idle hook will be unregistered from
|
||||
* both cores
|
||||
*
|
||||
* @param[in] old_idle_cb Callback to be unregistered
|
||||
*/
|
||||
void esp_deregister_freertos_idle_hook(esp_freertos_idle_cb_t old_idle_cb);
|
||||
|
||||
/**
|
||||
* @brief Unregister a tick callback from the tick hook of the specified core
|
||||
*
|
||||
* @param[in] old_tick_cb Callback to be unregistered
|
||||
* @param[in] cpuid id of the core
|
||||
*/
|
||||
void esp_deregister_freertos_tick_hook_for_cpu(esp_freertos_tick_cb_t old_tick_cb, UBaseType_t cpuid);
|
||||
|
||||
/**
|
||||
* @brief Unregister a tick callback. If the tick callback is registered to the
|
||||
* tick hooks of both cores, the tick hook will be unregistered from
|
||||
* both cores
|
||||
*
|
||||
* @param[in] old_tick_cb Callback to be unregistered
|
||||
*/
|
||||
void esp_deregister_freertos_tick_hook(esp_freertos_tick_cb_t old_tick_cb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
@@ -12,78 +12,6 @@
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_INTR_H__
|
||||
#define __ESP_INTR_H__
|
||||
|
||||
#include "esp32/rom/ets_sys.h"
|
||||
#include "freertos/xtensa_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define ESP_CCOMPARE_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_CCOMPARE_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_EPWM_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_EPWM_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_MPWM_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_MPWM_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_SPI1_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_SPI1_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_SPI2_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_SPI2_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_SPI3_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_SPI3_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_I2S0_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_I2S0_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_PCNT_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_PCNT_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_LEDC_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_LEDC_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_WMAC_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_WMAC_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_FRC_TIMER1_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_FRC_TIMER1_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_FRC_TIMER2_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_FRC_TIMER2_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_GPIO_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_GPIO_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_UART0_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_UART0_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_WDT_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_WDT_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_RTC_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_RTC_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_SLC_INTR_ATTACH(func, arg) \
|
||||
xt_set_interrupt_handler(ETS_SLC_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_RMT_CTRL_INTRL(func,arg)\
|
||||
xt_set_interrupt_handler(ETS_RMT_CTRL_INUM, (func), (void *)(arg))
|
||||
|
||||
#define ESP_INTR_ENABLE(inum) \
|
||||
xt_ints_on((1<<inum))
|
||||
|
||||
#define ESP_INTR_DISABLE(inum) \
|
||||
xt_ints_off((1<<inum))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_INTR_H__ */
|
||||
#pragma once
|
||||
#warning esp_intr.h is deprecated, please include esp_intr_alloc.h instead
|
||||
#include "esp_intr_alloc.h"
|
||||
|
@@ -18,6 +18,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "freertos/xtensa_api.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -80,7 +81,10 @@ extern "C" {
|
||||
// This is used to provide SystemView with positive IRQ IDs, otherwise sheduler events are not shown properly
|
||||
#define ETS_INTERNAL_INTR_SOURCE_OFF (-ETS_INTERNAL_PROFILING_INTR_SOURCE)
|
||||
|
||||
typedef void (*intr_handler_t)(void *arg);
|
||||
#define ESP_INTR_ENABLE(inum) xt_ints_on((1<<inum))
|
||||
#define ESP_INTR_DISABLE(inum) xt_ints_off((1<<inum))
|
||||
|
||||
typedef void (*intr_handler_t)(void *arg);
|
||||
|
||||
|
||||
typedef struct intr_handle_data_t intr_handle_data_t;
|
||||
@@ -88,7 +92,7 @@ typedef intr_handle_data_t* intr_handle_t ;
|
||||
|
||||
/**
|
||||
* @brief Mark an interrupt as a shared interrupt
|
||||
*
|
||||
*
|
||||
* This will mark a certain interrupt on the specified CPU as
|
||||
* an interrupt that can be used to hook shared interrupt handlers
|
||||
* to.
|
||||
@@ -105,7 +109,7 @@ esp_err_t esp_intr_mark_shared(int intno, int cpu, bool is_in_iram);
|
||||
|
||||
/**
|
||||
* @brief Reserve an interrupt to be used outside of this framework
|
||||
*
|
||||
*
|
||||
* This will mark a certain interrupt on the specified CPU as
|
||||
* reserved, not to be allocated for any reason.
|
||||
*
|
||||
@@ -137,7 +141,7 @@ esp_err_t esp_intr_reserve(int intno, int cpu);
|
||||
* choice of interrupts that this routine can choose from. If this value
|
||||
* is 0, it will default to allocating a non-shared interrupt of level
|
||||
* 1, 2 or 3. If this is ESP_INTR_FLAG_SHARED, it will allocate a shared
|
||||
* interrupt of level 1. Setting ESP_INTR_FLAG_INTRDISABLED will return
|
||||
* interrupt of level 1. Setting ESP_INTR_FLAG_INTRDISABLED will return
|
||||
* from this function with the interrupt disabled.
|
||||
* @param handler The interrupt handler. Must be NULL when an interrupt of level >3
|
||||
* is requested, because these types of interrupts aren't C-callable.
|
||||
@@ -158,7 +162,7 @@ esp_err_t esp_intr_alloc(int source, int flags, intr_handler_t handler, void *ar
|
||||
*
|
||||
*
|
||||
* This essentially does the same as esp_intr_alloc, but allows specifying a register and mask
|
||||
* combo. For shared interrupts, the handler is only called if a read from the specified
|
||||
* combo. For shared interrupts, the handler is only called if a read from the specified
|
||||
* register, ANDed with the mask, returns non-zero. By passing an interrupt status register
|
||||
* address and a fitting mask, this can be used to accelerate interrupt handling in the case
|
||||
* a shared interrupt is triggered; by checking the interrupt statuses first, the code can
|
||||
@@ -171,7 +175,7 @@ esp_err_t esp_intr_alloc(int source, int flags, intr_handler_t handler, void *ar
|
||||
* choice of interrupts that this routine can choose from. If this value
|
||||
* is 0, it will default to allocating a non-shared interrupt of level
|
||||
* 1, 2 or 3. If this is ESP_INTR_FLAG_SHARED, it will allocate a shared
|
||||
* interrupt of level 1. Setting ESP_INTR_FLAG_INTRDISABLED will return
|
||||
* interrupt of level 1. Setting ESP_INTR_FLAG_INTRDISABLED will return
|
||||
* from this function with the interrupt disabled.
|
||||
* @param intrstatusreg The address of an interrupt status register
|
||||
* @param intrstatusmask A mask. If a read of address intrstatusreg has any of the bits
|
||||
@@ -198,9 +202,9 @@ esp_err_t esp_intr_alloc_intrstatus(int source, int flags, uint32_t intrstatusre
|
||||
* If the current core is not the core that registered this interrupt, this routine will be assigned to
|
||||
* the core that allocated this interrupt, blocking and waiting until the resource is successfully released.
|
||||
*
|
||||
* @note
|
||||
* When the handler shares its source with other handlers, the interrupt status
|
||||
* bits it's responsible for should be managed properly before freeing it. see
|
||||
* @note
|
||||
* When the handler shares its source with other handlers, the interrupt status
|
||||
* bits it's responsible for should be managed properly before freeing it. see
|
||||
* ``esp_intr_disable`` for more details. Please do not call this function in ``esp_ipc_call_blocking``.
|
||||
*
|
||||
* @param handle The handle, as obtained by esp_intr_alloc or esp_intr_alloc_intrstatus
|
||||
@@ -214,7 +218,7 @@ esp_err_t esp_intr_free(intr_handle_t handle);
|
||||
|
||||
/**
|
||||
* @brief Get CPU number an interrupt is tied to
|
||||
*
|
||||
*
|
||||
* @param handle The handle, as obtained by esp_intr_alloc or esp_intr_alloc_intrstatus
|
||||
*
|
||||
* @return The core number where the interrupt is allocated
|
||||
@@ -223,7 +227,7 @@ int esp_intr_get_cpu(intr_handle_t handle);
|
||||
|
||||
/**
|
||||
* @brief Get the allocated interrupt for a certain handle
|
||||
*
|
||||
*
|
||||
* @param handle The handle, as obtained by esp_intr_alloc or esp_intr_alloc_intrstatus
|
||||
*
|
||||
* @return The interrupt number
|
||||
@@ -232,13 +236,13 @@ int esp_intr_get_intno(intr_handle_t handle);
|
||||
|
||||
/**
|
||||
* @brief Disable the interrupt associated with the handle
|
||||
*
|
||||
* @note
|
||||
*
|
||||
* @note
|
||||
* 1. For local interrupts (ESP_INTERNAL_* sources), this function has to be called on the
|
||||
* CPU the interrupt is allocated on. Other interrupts have no such restriction.
|
||||
* 2. When several handlers sharing a same interrupt source, interrupt status bits, which are
|
||||
* 2. When several handlers sharing a same interrupt source, interrupt status bits, which are
|
||||
* handled in the handler to be disabled, should be masked before the disabling, or handled
|
||||
* in other enabled interrupts properly. Miss of interrupt status handling will cause infinite
|
||||
* in other enabled interrupts properly. Miss of interrupt status handling will cause infinite
|
||||
* interrupt calls and finally system crash.
|
||||
*
|
||||
* @param handle The handle, as obtained by esp_intr_alloc or esp_intr_alloc_intrstatus
|
||||
|
@@ -1,93 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_IPC_H__
|
||||
#define __ESP_IPC_H__
|
||||
|
||||
#include <esp_err.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/** @cond */
|
||||
typedef void (*esp_ipc_func_t)(void* arg);
|
||||
/** @endcond */
|
||||
/*
|
||||
* Inter-processor call APIs
|
||||
*
|
||||
* FreeRTOS provides several APIs which can be used to communicate between
|
||||
* different tasks, including tasks running on different CPUs.
|
||||
* This module provides additional APIs to run some code on the other CPU.
|
||||
*
|
||||
* These APIs can only be used when FreeRTOS scheduler is running.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Execute a function on the given CPU
|
||||
*
|
||||
* Run a given function on a particular CPU. The given function must accept a
|
||||
* void* argument and return void. The given function is run in the context of
|
||||
* the IPC task of the CPU specified by the cpu_id parameter. The calling task
|
||||
* will be blocked until the IPC task begins executing the given function. If
|
||||
* another IPC call is ongoing, the calling task will block until the other IPC
|
||||
* call completes. The stack size allocated for the IPC task can be configured
|
||||
* in the "Inter-Processor Call (IPC) task stack size" setting in menuconfig.
|
||||
* Increase this setting if the given function requires more stack than default.
|
||||
*
|
||||
* @note In single-core mode, returns ESP_ERR_INVALID_ARG for cpu_id 1.
|
||||
*
|
||||
* @param[in] cpu_id CPU where the given function should be executed (0 or 1)
|
||||
* @param[in] func Pointer to a function of type void func(void* arg) to be executed
|
||||
* @param[in] arg Arbitrary argument of type void* to be passed into the function
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if cpu_id is invalid
|
||||
* - ESP_ERR_INVALID_STATE if the FreeRTOS scheduler is not running
|
||||
* - ESP_OK otherwise
|
||||
*/
|
||||
esp_err_t esp_ipc_call(uint32_t cpu_id, esp_ipc_func_t func, void* arg);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Execute a function on the given CPU and blocks until it completes
|
||||
*
|
||||
* Run a given function on a particular CPU. The given function must accept a
|
||||
* void* argument and return void. The given function is run in the context of
|
||||
* the IPC task of the CPU specified by the cpu_id parameter. The calling task
|
||||
* will be blocked until the IPC task completes execution of the given function.
|
||||
* If another IPC call is ongoing, the calling task will block until the other
|
||||
* IPC call completes. The stack size allocated for the IPC task can be
|
||||
* configured in the "Inter-Processor Call (IPC) task stack size" setting in
|
||||
* menuconfig. Increase this setting if the given function requires more stack
|
||||
* than default.
|
||||
*
|
||||
* @note In single-core mode, returns ESP_ERR_INVALID_ARG for cpu_id 1.
|
||||
*
|
||||
* @param[in] cpu_id CPU where the given function should be executed (0 or 1)
|
||||
* @param[in] func Pointer to a function of type void func(void* arg) to be executed
|
||||
* @param[in] arg Arbitrary argument of type void* to be passed into the function
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if cpu_id is invalid
|
||||
* - ESP_ERR_INVALID_STATE if the FreeRTOS scheduler is not running
|
||||
* - ESP_OK otherwise
|
||||
*/
|
||||
esp_err_t esp_ipc_call_blocking(uint32_t cpu_id, esp_ipc_func_t func, void* arg);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_IPC_H__ */
|
@@ -1,77 +0,0 @@
|
||||
#ifndef PANIC_H
|
||||
#define PANIC_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#define PANIC_RSN_NONE 0
|
||||
#define PANIC_RSN_DEBUGEXCEPTION 1
|
||||
#define PANIC_RSN_DOUBLEEXCEPTION 2
|
||||
#define PANIC_RSN_KERNELEXCEPTION 3
|
||||
#define PANIC_RSN_COPROCEXCEPTION 4
|
||||
#define PANIC_RSN_INTWDT_CPU0 5
|
||||
#define PANIC_RSN_INTWDT_CPU1 6
|
||||
#define PANIC_RSN_CACHEERR 7
|
||||
#define PANIC_RSN_MAX 7
|
||||
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
|
||||
/**
|
||||
* @brief If an OCD is connected over JTAG. set breakpoint 0 to the given function
|
||||
* address. Do nothing otherwise.
|
||||
* @param data Pointer to the target breakpoint position
|
||||
*/
|
||||
|
||||
void esp_set_breakpoint_if_jtag(void *fn);
|
||||
|
||||
#define ESP_WATCHPOINT_LOAD 0x40000000
|
||||
#define ESP_WATCHPOINT_STORE 0x80000000
|
||||
#define ESP_WATCHPOINT_ACCESS 0xC0000000
|
||||
|
||||
/**
|
||||
* @brief Set a watchpoint to break/panic when a certain memory range is accessed.
|
||||
*
|
||||
* @param no Watchpoint number. On the ESP32, this can be 0 or 1.
|
||||
* @param adr Base address to watch
|
||||
* @param size Size of the region, starting at the base address, to watch. Must
|
||||
* be one of 2^n, with n in [0..6].
|
||||
* @param flags One of ESP_WATCHPOINT_* flags
|
||||
*
|
||||
* @return ESP_ERR_INVALID_ARG on invalid arg, ESP_OK otherwise
|
||||
*
|
||||
* @warning The ESP32 watchpoint hardware watches a region of bytes by effectively
|
||||
* masking away the lower n bits for a region with size 2^n. If adr does
|
||||
* not have zero for these lower n bits, you may not be watching the
|
||||
* region you intended.
|
||||
*/
|
||||
esp_err_t esp_set_watchpoint(int no, void *adr, int size, int flags);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Clear a watchpoint
|
||||
*
|
||||
* @param no Watchpoint to clear
|
||||
*
|
||||
*/
|
||||
void esp_clear_watchpoint(int no);
|
||||
|
||||
/**
|
||||
* @brief Checks stack pointer
|
||||
*/
|
||||
static inline bool esp_stack_ptr_is_sane(uint32_t sp)
|
||||
{
|
||||
return !(sp < 0x3ffae010UL || sp > 0x3ffffff0UL || ((sp & 0xf) != 0));
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@@ -23,7 +23,7 @@
|
||||
#include "freertos/task.h"
|
||||
#include <esp_types.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_intr.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_attr.h"
|
||||
#include "esp_freertos_hooks.h"
|
||||
#include "soc/timer_group_struct.h"
|
||||
|
@@ -26,7 +26,7 @@
|
||||
#include "esp_err.h"
|
||||
//#define LOG_LOCAL_LEVEL ESP_LOG_VERBOSE
|
||||
#include "esp_log.h"
|
||||
#include "esp_intr.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_attr.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_ipc.h"
|
||||
|
@@ -1,130 +0,0 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_ipc.h"
|
||||
#include "esp_attr.h"
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "freertos/semphr.h"
|
||||
|
||||
|
||||
static SemaphoreHandle_t s_ipc_mutex; // This mutex is used as a global lock for esp_ipc_* APIs
|
||||
static SemaphoreHandle_t s_ipc_sem[portNUM_PROCESSORS]; // Two semaphores used to wake each of ipc tasks
|
||||
static SemaphoreHandle_t s_ipc_ack; // Semaphore used to acknowledge that task was woken up,
|
||||
// or function has finished running
|
||||
static volatile esp_ipc_func_t s_func; // Function which should be called by high priority task
|
||||
static void * volatile s_func_arg; // Argument to pass into s_func
|
||||
typedef enum {
|
||||
IPC_WAIT_FOR_START,
|
||||
IPC_WAIT_FOR_END
|
||||
} esp_ipc_wait_t;
|
||||
|
||||
static volatile esp_ipc_wait_t s_ipc_wait; // This variable tells high priority task when it should give
|
||||
// s_ipc_ack semaphore: before s_func is called, or
|
||||
// after it returns
|
||||
|
||||
static void IRAM_ATTR ipc_task(void* arg)
|
||||
{
|
||||
const uint32_t cpuid = (uint32_t) arg;
|
||||
assert(cpuid == xPortGetCoreID());
|
||||
while (true) {
|
||||
// Wait for IPC to be initiated.
|
||||
// This will be indicated by giving the semaphore corresponding to
|
||||
// this CPU.
|
||||
if (xSemaphoreTake(s_ipc_sem[cpuid], portMAX_DELAY) != pdTRUE) {
|
||||
// TODO: when can this happen?
|
||||
abort();
|
||||
}
|
||||
|
||||
esp_ipc_func_t func = s_func;
|
||||
void* arg = s_func_arg;
|
||||
|
||||
if (s_ipc_wait == IPC_WAIT_FOR_START) {
|
||||
xSemaphoreGive(s_ipc_ack);
|
||||
}
|
||||
(*func)(arg);
|
||||
if (s_ipc_wait == IPC_WAIT_FOR_END) {
|
||||
xSemaphoreGive(s_ipc_ack);
|
||||
}
|
||||
}
|
||||
// TODO: currently this is unreachable code. Introduce esp_ipc_uninit
|
||||
// function which will signal to both tasks that they can shut down.
|
||||
// Not critical at this point, we don't have a use case for stopping
|
||||
// IPC yet.
|
||||
// Also need to delete the semaphore here.
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize inter-processor call module. This function is called automatically
|
||||
* on CPU start and should not be called from the application.
|
||||
*
|
||||
* This function start two tasks, one on each CPU. These tasks are started
|
||||
* with high priority. These tasks are normally inactive, waiting until one of
|
||||
* the esp_ipc_call_* functions to be used. One of these tasks will be
|
||||
* woken up to execute the callback provided to esp_ipc_call_nonblocking or
|
||||
* esp_ipc_call_blocking.
|
||||
*/
|
||||
static void esp_ipc_init() __attribute__((constructor));
|
||||
|
||||
static void esp_ipc_init()
|
||||
{
|
||||
s_ipc_mutex = xSemaphoreCreateMutex();
|
||||
s_ipc_ack = xSemaphoreCreateBinary();
|
||||
char task_name[15];
|
||||
for (int i = 0; i < portNUM_PROCESSORS; ++i) {
|
||||
snprintf(task_name, sizeof(task_name), "ipc%d", i);
|
||||
s_ipc_sem[i] = xSemaphoreCreateBinary();
|
||||
portBASE_TYPE res = xTaskCreatePinnedToCore(ipc_task, task_name, CONFIG_IPC_TASK_STACK_SIZE, (void*) i,
|
||||
configMAX_PRIORITIES - 1, NULL, i);
|
||||
assert(res == pdTRUE);
|
||||
}
|
||||
}
|
||||
|
||||
static esp_err_t esp_ipc_call_and_wait(uint32_t cpu_id, esp_ipc_func_t func, void* arg, esp_ipc_wait_t wait_for)
|
||||
{
|
||||
if (cpu_id >= portNUM_PROCESSORS) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if (xTaskGetSchedulerState() != taskSCHEDULER_RUNNING) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
xSemaphoreTake(s_ipc_mutex, portMAX_DELAY);
|
||||
|
||||
s_func = func;
|
||||
s_func_arg = arg;
|
||||
s_ipc_wait = wait_for;
|
||||
xSemaphoreGive(s_ipc_sem[cpu_id]);
|
||||
xSemaphoreTake(s_ipc_ack, portMAX_DELAY);
|
||||
xSemaphoreGive(s_ipc_mutex);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_ipc_call(uint32_t cpu_id, esp_ipc_func_t func, void* arg)
|
||||
{
|
||||
return esp_ipc_call_and_wait(cpu_id, func, arg, IPC_WAIT_FOR_START);
|
||||
}
|
||||
|
||||
esp_err_t esp_ipc_call_blocking(uint32_t cpu_id, esp_ipc_func_t func, void* arg)
|
||||
{
|
||||
return esp_ipc_call_and_wait(cpu_id, func, arg, IPC_WAIT_FOR_END);
|
||||
}
|
||||
|
@@ -1,12 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo '/*'
|
||||
echo 'ESP32 ROM address table'
|
||||
echo 'Generated for ROM with MD5sum:'
|
||||
md5sum $1
|
||||
echo '*/'
|
||||
xtensa-esp108-elf-nm $1 | grep '[0-9a-f] [TBRD]' | while read adr ttp nm; do
|
||||
if ! echo "$nm" | grep -q -e '^_bss' -e '_heap'; then
|
||||
echo "PROVIDE ( $nm = 0x$adr );";
|
||||
fi
|
||||
done
|
Binary file not shown.
@@ -3,11 +3,6 @@ archive: libesp32.a
|
||||
entries:
|
||||
panic (noflash)
|
||||
|
||||
[mapping]
|
||||
archive: libhal.a
|
||||
entries:
|
||||
* (noflash_text)
|
||||
|
||||
[mapping]
|
||||
archive: libgcc.a
|
||||
entries:
|
||||
|
@@ -33,7 +33,8 @@
|
||||
#include "soc/rtc_wdt.h"
|
||||
|
||||
#include "esp_private/gdbstub.h"
|
||||
#include "esp_panic.h"
|
||||
#include "esp_debug_helpers.h"
|
||||
#include "esp_private/panic_reason.h"
|
||||
#include "esp_attr.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_core_dump.h"
|
||||
@@ -382,7 +383,7 @@ static void illegal_instruction_helper(XtExcFrame *frame)
|
||||
panicPutStr("Memory dump at 0x");
|
||||
panicPutHex(epc);
|
||||
panicPutStr(": ");
|
||||
|
||||
|
||||
panicPutHex(*pepc);
|
||||
panicPutStr(" ");
|
||||
panicPutHex(*(pepc + 1));
|
||||
|
@@ -25,7 +25,7 @@
|
||||
#include "freertos/semphr.h"
|
||||
#include <esp_types.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_intr.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_attr.h"
|
||||
#include "esp_freertos_hooks.h"
|
||||
|
Reference in New Issue
Block a user