mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-07-03 22:06:32 +02:00
Initial Esp32c3 Support (#5060)
This commit is contained in:
115
tools/sdk/esp32c3/include/esp_system/include/esp_async_memcpy.h
Normal file
115
tools/sdk/esp32c3/include/esp_system/include/esp_async_memcpy.h
Normal file
@ -0,0 +1,115 @@
|
||||
// Copyright 2020 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
/**
|
||||
* @brief Type of async memcpy handle
|
||||
*
|
||||
*/
|
||||
typedef struct async_memcpy_context_t *async_memcpy_t;
|
||||
|
||||
/**
|
||||
* @brief Type of async memcpy event object
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
void *data; /*!< Event data */
|
||||
} async_memcpy_event_t;
|
||||
|
||||
/**
|
||||
* @brief Type of async memcpy interrupt callback function
|
||||
*
|
||||
* @param mcp_hdl Handle of async memcpy
|
||||
* @param event Event object, which contains related data, reserved for future
|
||||
* @param cb_args User defined arguments, passed from esp_async_memcpy function
|
||||
* @return Whether a high priority task is woken up by the callback function
|
||||
*
|
||||
* @note User can call OS primitives (semaphore, mutex, etc) in the callback function.
|
||||
* Keep in mind, if any OS primitive wakes high priority task up, the callback should return true.
|
||||
*/
|
||||
typedef bool (*async_memcpy_isr_cb_t)(async_memcpy_t mcp_hdl, async_memcpy_event_t *event, void *cb_args);
|
||||
|
||||
/**
|
||||
* @brief Type of async memcpy configuration
|
||||
*
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t backlog; /*!< Maximum number of streams that can be handled simultaneously */
|
||||
uint32_t flags; /*!< Extra flags to control async memcpy feature */
|
||||
} async_memcpy_config_t;
|
||||
|
||||
/**
|
||||
* @brief Default configuration for async memcpy
|
||||
*
|
||||
*/
|
||||
#define ASYNC_MEMCPY_DEFAULT_CONFIG() \
|
||||
{ \
|
||||
.backlog = 8, \
|
||||
.flags = 0, \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Install async memcpy driver
|
||||
*
|
||||
* @param[in] config Configuration of async memcpy
|
||||
* @param[out] asmcp Handle of async memcpy that returned from this API. If driver installation is failed, asmcp would be assigned to NULL.
|
||||
* @return
|
||||
* - ESP_OK: Install async memcpy driver successfully
|
||||
* - ESP_ERR_INVALID_ARG: Install async memcpy driver failed because of invalid argument
|
||||
* - ESP_ERR_NO_MEM: Install async memcpy driver failed because out of memory
|
||||
* - ESP_FAIL: Install async memcpy driver failed because of other error
|
||||
*/
|
||||
esp_err_t esp_async_memcpy_install(const async_memcpy_config_t *config, async_memcpy_t *asmcp);
|
||||
|
||||
/**
|
||||
* @brief Uninstall async memcpy driver
|
||||
*
|
||||
* @param[in] asmcp Handle of async memcpy driver that returned from esp_async_memcpy_install
|
||||
* @return
|
||||
* - ESP_OK: Uninstall async memcpy driver successfully
|
||||
* - ESP_ERR_INVALID_ARG: Uninstall async memcpy driver failed because of invalid argument
|
||||
* - ESP_FAIL: Uninstall async memcpy driver failed because of other error
|
||||
*/
|
||||
esp_err_t esp_async_memcpy_uninstall(async_memcpy_t asmcp);
|
||||
|
||||
/**
|
||||
* @brief Send an asynchronous memory copy request
|
||||
*
|
||||
* @param[in] asmcp Handle of async memcpy driver that returned from esp_async_memcpy_install
|
||||
* @param[in] dst Destination address (copy to)
|
||||
* @param[in] src Source address (copy from)
|
||||
* @param[in] n Number of bytes to copy
|
||||
* @param[in] cb_isr Callback function, which got invoked in interrupt context. Set to NULL can bypass the callback.
|
||||
* @param[in] cb_args User defined argument to be passed to the callback function
|
||||
* @return
|
||||
* - ESP_OK: Send memory copy request successfully
|
||||
* - ESP_ERR_INVALID_ARG: Send memory copy request failed because of invalid argument
|
||||
* - ESP_FAIL: Send memory copy request failed because of other error
|
||||
*
|
||||
* @note The callback function is invoked in interrupt context, never do blocking jobs in the callback.
|
||||
*/
|
||||
esp_err_t esp_async_memcpy(async_memcpy_t asmcp, void *dst, void *src, size_t n, async_memcpy_isr_cb_t cb_isr, void *cb_args);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
122
tools/sdk/esp32c3/include/esp_system/include/esp_debug_helpers.h
Normal file
122
tools/sdk/esp32c3/include/esp_system/include/esp_debug_helpers.h
Normal file
@ -0,0 +1,122 @@
|
||||
// Copyright 2015-2019 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "soc/soc.h" // [refactor-todo] IDF-2297
|
||||
#include "esp_cpu.h"
|
||||
|
||||
/*
|
||||
* @brief Structure used for backtracing
|
||||
*
|
||||
* This structure stores the backtrace information of a particular stack frame
|
||||
* (i.e. the PC and SP). This structure is used iteratively with the
|
||||
* esp_cpu_get_next_backtrace_frame() function to traverse each frame within a
|
||||
* single stack. The next_pc represents the PC of the current frame's caller, thus
|
||||
* a next_pc of 0 indicates that the current frame is the last frame on the stack.
|
||||
*
|
||||
* @note Call esp_backtrace_get_start() to obtain initialization values for
|
||||
* this structure
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t pc; /* PC of the current frame */
|
||||
uint32_t sp; /* SP of the current frame */
|
||||
uint32_t next_pc; /* PC of the current frame's caller */
|
||||
} esp_backtrace_frame_t;
|
||||
|
||||
/**
|
||||
* @brief If an OCD is connected over JTAG. set breakpoint 0 to the given function
|
||||
* address. Do nothing otherwise.
|
||||
* @param fn Pointer to the target breakpoint position
|
||||
*/
|
||||
void esp_set_breakpoint_if_jtag(void *fn);
|
||||
|
||||
/**
|
||||
* Get the first frame of the current stack's backtrace
|
||||
*
|
||||
* Given the following function call flow (B -> A -> X -> esp_backtrace_get_start),
|
||||
* this function will do the following.
|
||||
* - Flush CPU registers and window frames onto the current stack
|
||||
* - Return PC and SP of function A (i.e. start of the stack's backtrace)
|
||||
* - Return PC of function B (i.e. next_pc)
|
||||
*
|
||||
* @note This function is implemented in assembly
|
||||
*
|
||||
* @param[out] pc PC of the first frame in the backtrace
|
||||
* @param[out] sp SP of the first frame in the backtrace
|
||||
* @param[out] next_pc PC of the first frame's caller
|
||||
*/
|
||||
extern void esp_backtrace_get_start(uint32_t *pc, uint32_t *sp, uint32_t *next_pc);
|
||||
|
||||
/**
|
||||
* Get the next frame on a stack for backtracing
|
||||
*
|
||||
* Given a stack frame(i), this function will obtain the next stack frame(i-1)
|
||||
* on the same call stack (i.e. the caller of frame(i)). This function is meant to be
|
||||
* called iteratively when doing a backtrace.
|
||||
*
|
||||
* Entry Conditions: Frame structure containing valid SP and next_pc
|
||||
* Exit Conditions:
|
||||
* - Frame structure updated with SP and PC of frame(i-1). next_pc now points to frame(i-2).
|
||||
* - If a next_pc of 0 is returned, it indicates that frame(i-1) is last frame on the stack
|
||||
*
|
||||
* @param[inout] frame Pointer to frame structure
|
||||
*
|
||||
* @return
|
||||
* - True if the SP and PC of the next frame(i-1) are sane
|
||||
* - False otherwise
|
||||
*/
|
||||
bool esp_backtrace_get_next_frame(esp_backtrace_frame_t *frame);
|
||||
|
||||
/**
|
||||
* @brief Print the backtrace of the current stack
|
||||
*
|
||||
* @param depth The maximum number of stack frames to print (should be > 0)
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK Backtrace successfully printed to completion or to depth limit
|
||||
* - ESP_FAIL Backtrace is corrupted
|
||||
*/
|
||||
esp_err_t esp_backtrace_print(int depth);
|
||||
|
||||
/**
|
||||
* @brief Set a watchpoint to break/panic when a certain memory range is accessed.
|
||||
* Superseded by esp_cpu_set_watchpoint in esp_cpu.h.
|
||||
*/
|
||||
static inline __attribute__((deprecated)) esp_err_t esp_set_watchpoint(int no, void *adr, int size, int flags)
|
||||
{
|
||||
return esp_cpu_set_watchpoint(no, adr, size, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set a watchpoint to break/panic when a certain memory range is accessed.
|
||||
* Superseded by esp_cpu_clear_watchpoint in esp_cpu.h.
|
||||
*/
|
||||
static inline __attribute__((deprecated)) void esp_clear_watchpoint(int no)
|
||||
{
|
||||
esp_cpu_clear_watchpoint(no);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,49 @@
|
||||
// Copyright 2015-2019 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
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/semphr.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_debug_helpers.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef void (*shared_stack_function)(void);
|
||||
|
||||
#define ESP_EXECUTE_EXPRESSION_WITH_STACK(lock, stack, stack_size, expression) \
|
||||
esp_execute_shared_stack_function(lock, stack, stack_size, expression)
|
||||
|
||||
/**
|
||||
* @brief Calls user defined shared stack space function
|
||||
* @param lock Mutex object to protect in case of shared stack
|
||||
* @param stack Pointer to user alocated stack
|
||||
* @param stack_size Size of current stack in bytes
|
||||
* @param function pointer to the shared stack function to be executed
|
||||
* @note if either lock, stack or stack size is invalid, the expression will
|
||||
* be called using the current stack.
|
||||
*/
|
||||
void esp_execute_shared_stack_function(SemaphoreHandle_t lock,
|
||||
void *stack,
|
||||
size_t stack_size,
|
||||
shared_stack_function function);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,134 @@
|
||||
// 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 "freertos/portmacro.h"
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*
|
||||
Definitions for the tickhook and idlehook callbacks
|
||||
*/
|
||||
typedef bool (*esp_freertos_idle_cb_t)(void);
|
||||
typedef void (*esp_freertos_tick_cb_t)(void);
|
||||
|
||||
/**
|
||||
* @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
|
67
tools/sdk/esp32c3/include/esp_system/include/esp_int_wdt.h
Normal file
67
tools/sdk/esp32c3/include/esp_system/include/esp_int_wdt.h
Normal file
@ -0,0 +1,67 @@
|
||||
// Copyright 2015-2018 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_INT_WDT_H
|
||||
#define __ESP_INT_WDT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** @addtogroup Watchdog_APIs
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*
|
||||
This routine enables a watchdog to catch instances of processes disabling
|
||||
interrupts for too long, or code within interrupt handlers taking too long.
|
||||
It does this by setting up a watchdog which gets fed from the FreeRTOS
|
||||
task switch interrupt. When this watchdog times out, initially it will call
|
||||
a high-level interrupt routine that will panic FreeRTOS in order to allow
|
||||
for forensic examination of the state of the both CPUs. When this interrupt
|
||||
handler is not called and the watchdog times out a second time, it will
|
||||
reset the SoC.
|
||||
|
||||
This uses the TIMERG1 WDT.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initialize the non-CPU-specific parts of interrupt watchdog.
|
||||
* This is called in the init code if the interrupt watchdog
|
||||
* is enabled in menuconfig.
|
||||
*
|
||||
*/
|
||||
void esp_int_wdt_init(void);
|
||||
|
||||
/**
|
||||
* @brief Enable the interrupt watchdog on the current CPU. This is called
|
||||
* in the init code by both CPUs if the interrupt watchdog is enabled
|
||||
* in menuconfig.
|
||||
*
|
||||
*/
|
||||
void esp_int_wdt_cpu_init(void);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
322
tools/sdk/esp32c3/include/esp_system/include/esp_intr_alloc.h
Normal file
322
tools/sdk/esp32c3/include/esp_system/include/esp_intr_alloc.h
Normal file
@ -0,0 +1,322 @@
|
||||
// Copyright 2015-2020 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
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/** @addtogroup Intr_Alloc
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/** @brief Interrupt allocation flags
|
||||
*
|
||||
* These flags can be used to specify which interrupt qualities the
|
||||
* code calling esp_intr_alloc* needs.
|
||||
*
|
||||
*/
|
||||
|
||||
//Keep the LEVELx values as they are here; they match up with (1<<level)
|
||||
#define ESP_INTR_FLAG_LEVEL1 (1<<1) ///< Accept a Level 1 interrupt vector (lowest priority)
|
||||
#define ESP_INTR_FLAG_LEVEL2 (1<<2) ///< Accept a Level 2 interrupt vector
|
||||
#define ESP_INTR_FLAG_LEVEL3 (1<<3) ///< Accept a Level 3 interrupt vector
|
||||
#define ESP_INTR_FLAG_LEVEL4 (1<<4) ///< Accept a Level 4 interrupt vector
|
||||
#define ESP_INTR_FLAG_LEVEL5 (1<<5) ///< Accept a Level 5 interrupt vector
|
||||
#define ESP_INTR_FLAG_LEVEL6 (1<<6) ///< Accept a Level 6 interrupt vector
|
||||
#define ESP_INTR_FLAG_NMI (1<<7) ///< Accept a Level 7 interrupt vector (highest priority)
|
||||
#define ESP_INTR_FLAG_SHARED (1<<8) ///< Interrupt can be shared between ISRs
|
||||
#define ESP_INTR_FLAG_EDGE (1<<9) ///< Edge-triggered interrupt
|
||||
#define ESP_INTR_FLAG_IRAM (1<<10) ///< ISR can be called if cache is disabled
|
||||
#define ESP_INTR_FLAG_INTRDISABLED (1<<11) ///< Return with this interrupt disabled
|
||||
|
||||
#define ESP_INTR_FLAG_LOWMED (ESP_INTR_FLAG_LEVEL1|ESP_INTR_FLAG_LEVEL2|ESP_INTR_FLAG_LEVEL3) ///< Low and medium prio interrupts. These can be handled in C.
|
||||
#define ESP_INTR_FLAG_HIGH (ESP_INTR_FLAG_LEVEL4|ESP_INTR_FLAG_LEVEL5|ESP_INTR_FLAG_LEVEL6|ESP_INTR_FLAG_NMI) ///< High level interrupts. Need to be handled in assembly.
|
||||
|
||||
#define ESP_INTR_FLAG_LEVELMASK (ESP_INTR_FLAG_LEVEL1|ESP_INTR_FLAG_LEVEL2|ESP_INTR_FLAG_LEVEL3| \
|
||||
ESP_INTR_FLAG_LEVEL4|ESP_INTR_FLAG_LEVEL5|ESP_INTR_FLAG_LEVEL6| \
|
||||
ESP_INTR_FLAG_NMI) ///< Mask for all level flags
|
||||
|
||||
|
||||
/** @addtogroup Intr_Alloc_Pseudo_Src
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* The esp_intr_alloc* functions can allocate an int for all ETS_*_INTR_SOURCE interrupt sources that
|
||||
* are routed through the interrupt mux. Apart from these sources, each core also has some internal
|
||||
* sources that do not pass through the interrupt mux. To allocate an interrupt for these sources,
|
||||
* pass these pseudo-sources to the functions.
|
||||
*/
|
||||
#define ETS_INTERNAL_TIMER0_INTR_SOURCE -1 ///< Platform timer 0 interrupt source
|
||||
#define ETS_INTERNAL_TIMER1_INTR_SOURCE -2 ///< Platform timer 1 interrupt source
|
||||
#define ETS_INTERNAL_TIMER2_INTR_SOURCE -3 ///< Platform timer 2 interrupt source
|
||||
#define ETS_INTERNAL_SW0_INTR_SOURCE -4 ///< Software int source 1
|
||||
#define ETS_INTERNAL_SW1_INTR_SOURCE -5 ///< Software int source 2
|
||||
#define ETS_INTERNAL_PROFILING_INTR_SOURCE -6 ///< Int source for profiling
|
||||
|
||||
/**@}*/
|
||||
|
||||
/** Provides SystemView with positive IRQ IDs, otherwise scheduler events are not shown properly
|
||||
*/
|
||||
#define ETS_INTERNAL_INTR_SOURCE_OFF (-ETS_INTERNAL_PROFILING_INTR_SOURCE)
|
||||
|
||||
/** Enable interrupt by interrupt number */
|
||||
#define ESP_INTR_ENABLE(inum) esp_intr_enable_source(inum)
|
||||
|
||||
/** Disable interrupt by interrupt number */
|
||||
#define ESP_INTR_DISABLE(inum) esp_intr_disable_source(inum)
|
||||
|
||||
/** Function prototype for interrupt handler function */
|
||||
typedef void (*intr_handler_t)(void *arg);
|
||||
|
||||
/** Interrupt handler associated data structure */
|
||||
typedef struct intr_handle_data_t intr_handle_data_t;
|
||||
|
||||
/** Handle to an interrupt handler */
|
||||
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.
|
||||
*
|
||||
* @param intno The number of the interrupt (0-31)
|
||||
* @param cpu CPU on which the interrupt should be marked as shared (0 or 1)
|
||||
* @param is_in_iram Shared interrupt is for handlers that reside in IRAM and
|
||||
* the int can be left enabled while the flash cache is disabled.
|
||||
*
|
||||
* @return ESP_ERR_INVALID_ARG if cpu or intno is invalid
|
||||
* ESP_OK otherwise
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param intno The number of the interrupt (0-31)
|
||||
* @param cpu CPU on which the interrupt should be marked as shared (0 or 1)
|
||||
*
|
||||
* @return ESP_ERR_INVALID_ARG if cpu or intno is invalid
|
||||
* ESP_OK otherwise
|
||||
*/
|
||||
esp_err_t esp_intr_reserve(int intno, int cpu);
|
||||
|
||||
/**
|
||||
* @brief Allocate an interrupt with the given parameters.
|
||||
*
|
||||
* This finds an interrupt that matches the restrictions as given in the flags
|
||||
* parameter, maps the given interrupt source to it and hooks up the given
|
||||
* interrupt handler (with optional argument) as well. If needed, it can return
|
||||
* a handle for the interrupt as well.
|
||||
*
|
||||
* The interrupt will always be allocated on the core that runs this function.
|
||||
*
|
||||
* If ESP_INTR_FLAG_IRAM flag is used, and handler address is not in IRAM or
|
||||
* RTC_FAST_MEM, then ESP_ERR_INVALID_ARG is returned.
|
||||
*
|
||||
* @param source The interrupt source. One of the ETS_*_INTR_SOURCE interrupt mux
|
||||
* sources, as defined in soc/soc.h, or one of the internal
|
||||
* ETS_INTERNAL_*_INTR_SOURCE sources as defined in this header.
|
||||
* @param flags An ORred mask of the ESP_INTR_FLAG_* defines. These restrict the
|
||||
* 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
|
||||
* 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.
|
||||
* @param arg Optional argument for passed to the interrupt handler
|
||||
* @param ret_handle Pointer to an intr_handle_t to store a handle that can later be
|
||||
* used to request details or free the interrupt. Can be NULL if no handle
|
||||
* is required.
|
||||
*
|
||||
* @return ESP_ERR_INVALID_ARG if the combination of arguments is invalid.
|
||||
* ESP_ERR_NOT_FOUND No free interrupt found with the specified flags
|
||||
* ESP_OK otherwise
|
||||
*/
|
||||
esp_err_t esp_intr_alloc(int source, int flags, intr_handler_t handler, void *arg, intr_handle_t *ret_handle);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Allocate an interrupt with the given parameters.
|
||||
*
|
||||
*
|
||||
* 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
|
||||
* 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
|
||||
* decide which ISRs can be skipped
|
||||
*
|
||||
* @param source The interrupt source. One of the ETS_*_INTR_SOURCE interrupt mux
|
||||
* sources, as defined in soc/soc.h, or one of the internal
|
||||
* ETS_INTERNAL_*_INTR_SOURCE sources as defined in this header.
|
||||
* @param flags An ORred mask of the ESP_INTR_FLAG_* defines. These restrict the
|
||||
* 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
|
||||
* 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
|
||||
* that are 1 in the mask set, the ISR will be called. If not, it will be
|
||||
* skipped.
|
||||
* @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.
|
||||
* @param arg Optional argument for passed to the interrupt handler
|
||||
* @param ret_handle Pointer to an intr_handle_t to store a handle that can later be
|
||||
* used to request details or free the interrupt. Can be NULL if no handle
|
||||
* is required.
|
||||
*
|
||||
* @return ESP_ERR_INVALID_ARG if the combination of arguments is invalid.
|
||||
* ESP_ERR_NOT_FOUND No free interrupt found with the specified flags
|
||||
* ESP_OK otherwise
|
||||
*/
|
||||
esp_err_t esp_intr_alloc_intrstatus(int source, int flags, uint32_t intrstatusreg, uint32_t intrstatusmask, intr_handler_t handler, void *arg, intr_handle_t *ret_handle);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Disable and free an interrupt.
|
||||
*
|
||||
* Use an interrupt handle to disable the interrupt and release the resources associated with it.
|
||||
* 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
|
||||
* ``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
|
||||
*
|
||||
* @return ESP_ERR_INVALID_ARG the handle is NULL
|
||||
* ESP_FAIL failed to release this handle
|
||||
* ESP_OK otherwise
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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
|
||||
*/
|
||||
int esp_intr_get_intno(intr_handle_t handle);
|
||||
|
||||
/**
|
||||
* @brief Disable the interrupt associated with the handle
|
||||
*
|
||||
* @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
|
||||
* 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
|
||||
* interrupt calls and finally system crash.
|
||||
*
|
||||
* @param handle The handle, as obtained by esp_intr_alloc or esp_intr_alloc_intrstatus
|
||||
*
|
||||
* @return ESP_ERR_INVALID_ARG if the combination of arguments is invalid.
|
||||
* ESP_OK otherwise
|
||||
*/
|
||||
esp_err_t esp_intr_disable(intr_handle_t handle);
|
||||
|
||||
/**
|
||||
* @brief Enable the interrupt associated with the handle
|
||||
*
|
||||
* @note 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.
|
||||
*
|
||||
* @param handle The handle, as obtained by esp_intr_alloc or esp_intr_alloc_intrstatus
|
||||
*
|
||||
* @return ESP_ERR_INVALID_ARG if the combination of arguments is invalid.
|
||||
* ESP_OK otherwise
|
||||
*/
|
||||
esp_err_t esp_intr_enable(intr_handle_t handle);
|
||||
|
||||
/**
|
||||
* @brief Set the "in IRAM" status of the handler.
|
||||
*
|
||||
* @note Does not work on shared interrupts.
|
||||
*
|
||||
* @param handle The handle, as obtained by esp_intr_alloc or esp_intr_alloc_intrstatus
|
||||
* @param is_in_iram Whether the handler associated with this handle resides in IRAM.
|
||||
* Handlers residing in IRAM can be called when cache is disabled.
|
||||
*
|
||||
* @return ESP_ERR_INVALID_ARG if the combination of arguments is invalid.
|
||||
* ESP_OK otherwise
|
||||
*/
|
||||
esp_err_t esp_intr_set_in_iram(intr_handle_t handle, bool is_in_iram);
|
||||
|
||||
/**
|
||||
* @brief Disable interrupts that aren't specifically marked as running from IRAM
|
||||
*/
|
||||
void esp_intr_noniram_disable(void);
|
||||
|
||||
/**
|
||||
* @brief Re-enable interrupts disabled by esp_intr_noniram_disable
|
||||
*/
|
||||
void esp_intr_noniram_enable(void);
|
||||
|
||||
/**
|
||||
* @brief enable the interrupt source based on its number
|
||||
* @param inum interrupt number from 0 to 31
|
||||
*/
|
||||
void esp_intr_enable_source(int inum);
|
||||
|
||||
/**
|
||||
* @brief disable the interrupt source based on its number
|
||||
* @param inum interrupt number from 0 to 31
|
||||
*/
|
||||
void esp_intr_disable_source(int inum);
|
||||
|
||||
/**
|
||||
* @brief Get the lowest interrupt level from the flags
|
||||
* @param flags The same flags that pass to `esp_intr_alloc_intrstatus` API
|
||||
*/
|
||||
static inline int esp_intr_flags_to_level(int flags)
|
||||
{
|
||||
return __builtin_ffs((flags & ESP_INTR_FLAG_LEVELMASK) >> 1) + 1;
|
||||
}
|
||||
|
||||
/**@}*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,71 @@
|
||||
// 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_CROSSCORE_INT_H
|
||||
#define __ESP_CROSSCORE_INT_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Initialize the crosscore interrupt system for this CPU.
|
||||
* This needs to be called once on every CPU that is used
|
||||
* by FreeRTOS.
|
||||
*
|
||||
* If multicore FreeRTOS support is enabled, this will be
|
||||
* called automatically by the startup code and should not
|
||||
* be called manually.
|
||||
*/
|
||||
void esp_crosscore_int_init(void);
|
||||
|
||||
|
||||
/**
|
||||
* Send an interrupt to a CPU indicating it should yield its
|
||||
* currently running task in favour of a higher-priority task
|
||||
* that presumably just woke up.
|
||||
*
|
||||
* This is used internally by FreeRTOS in multicore mode
|
||||
* and should not be called by the user.
|
||||
*
|
||||
* @param core_id Core that should do the yielding
|
||||
*/
|
||||
void esp_crosscore_int_send_yield(int core_id);
|
||||
|
||||
|
||||
/**
|
||||
* Send an interrupt to a CPU indicating it should update its
|
||||
* CCOMPARE1 value due to a frequency switch.
|
||||
*
|
||||
* This is used internally when dynamic frequency switching is
|
||||
* enabled, and should not be called from application code.
|
||||
*
|
||||
* @param core_id Core that should update its CCOMPARE1 value
|
||||
*/
|
||||
void esp_crosscore_int_send_freq_switch(int core_id);
|
||||
|
||||
/**
|
||||
* Send an interrupt to a CPU indicating it should print its current backtrace
|
||||
*
|
||||
* This is use internally by the Task Watchdog to dump the backtrace of the
|
||||
* opposite core and should not be called from application code.
|
||||
*
|
||||
* @param core_id Core that should print its backtrace
|
||||
*/
|
||||
void esp_crosscore_int_send_print_backtrace(int core_id);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -0,0 +1,58 @@
|
||||
// Copyright 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.
|
||||
#ifndef ESP_DBG_STUBS_H_
|
||||
#define ESP_DBG_STUBS_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "esp_err.h"
|
||||
|
||||
/**
|
||||
* Debug stubs entries IDs
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_DBG_STUB_CONTROL_DATA, ///< stubs descriptor entry
|
||||
ESP_DBG_STUB_ENTRY_FIRST,
|
||||
ESP_DBG_STUB_ENTRY_GCOV ///< GCOV entry
|
||||
= ESP_DBG_STUB_ENTRY_FIRST,
|
||||
ESP_DBG_STUB_ENTRY_MAX
|
||||
} esp_dbg_stub_id_t;
|
||||
|
||||
/**
|
||||
* @brief Initializes debug stubs.
|
||||
*
|
||||
* @note Must be called after esp_apptrace_init() if app tracing is enabled.
|
||||
*/
|
||||
void esp_dbg_stubs_init(void);
|
||||
|
||||
/**
|
||||
* @brief Initializes application tracing module.
|
||||
*
|
||||
* @note Should be called before any esp_apptrace_xxx call.
|
||||
*
|
||||
* @param id Stub ID.
|
||||
* @param entry Stub entry. Usually it is stub entry function address,
|
||||
* but can be any value meaningfull for OpenOCD command/code.
|
||||
*
|
||||
* @return ESP_OK on success, otherwise see esp_err_t
|
||||
*/
|
||||
esp_err_t esp_dbg_stub_entry_set(esp_dbg_stub_id_t id, uint32_t entry);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //ESP_DBG_STUBS_H_
|
@ -0,0 +1,97 @@
|
||||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern bool g_panic_abort;
|
||||
|
||||
extern void *g_exc_frames[SOC_CPU_CORES_NUM];
|
||||
|
||||
// Function to print longer amounts of information such as the details
|
||||
// and backtrace field of panic_info_t. These functions should limit themselves
|
||||
// to printing to the console and should do other more involved processing,
|
||||
// and must be aware that the main logic in panic.c has a watchdog timer active.
|
||||
typedef void (*panic_info_dump_fn_t)(const void* frame);
|
||||
|
||||
// Non architecture specific exceptions (generally valid for all targets).
|
||||
// Can be used to convey to the main logic what exception is being
|
||||
// dealt with to perform some actions, without knowing the underlying
|
||||
// architecture/chip-specific exception.
|
||||
typedef enum {
|
||||
PANIC_EXCEPTION_DEBUG,
|
||||
PANIC_EXCEPTION_IWDT,
|
||||
PANIC_EXCEPTION_TWDT,
|
||||
PANIC_EXCEPTION_ABORT,
|
||||
PANIC_EXCEPTION_FAULT, // catch-all for all types of faults
|
||||
} panic_exception_t;
|
||||
|
||||
typedef struct {
|
||||
int core; // core which triggered panic
|
||||
panic_exception_t exception; // non-architecture-specific exception code
|
||||
const char* reason; // exception string
|
||||
const char* description; // short description of the exception
|
||||
panic_info_dump_fn_t details; // more details on the exception
|
||||
panic_info_dump_fn_t state; // processor state, usually the contents of the registers
|
||||
const void* addr; // instruction address that triggered the exception
|
||||
const void* frame; // reference to the frame
|
||||
bool pseudo_excause; // flag indicating that exception cause has special meaning
|
||||
} panic_info_t;
|
||||
|
||||
#define PANIC_INFO_DUMP(info, dump_fn) {if ((info)->dump_fn) (*(info)->dump_fn)((info->frame));}
|
||||
|
||||
// Create own print functions, since printf might be broken, and can be silenced
|
||||
// when CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT
|
||||
#if !CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT
|
||||
void panic_print_char(char c);
|
||||
void panic_print_str(const char *str);
|
||||
void panic_print_dec(int d);
|
||||
void panic_print_hex(int h);
|
||||
#else
|
||||
#define panic_print_char(c)
|
||||
#define panic_print_str(str)
|
||||
#define panic_print_dec(d)
|
||||
#define panic_print_hex(h)
|
||||
#endif
|
||||
|
||||
void __attribute__((noreturn)) panic_abort(const char *details);
|
||||
|
||||
void panic_arch_fill_info(void *frame, panic_info_t *info);
|
||||
|
||||
void panic_soc_fill_info(void *frame, panic_info_t *info);
|
||||
|
||||
void panic_print_registers(const void *frame, int core);
|
||||
|
||||
void panic_print_backtrace(const void *frame, int core);
|
||||
|
||||
uint32_t panic_get_address(const void* frame);
|
||||
|
||||
void panic_set_address(void *frame, uint32_t addr);
|
||||
|
||||
uint32_t panic_get_cause(const void* frame);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,40 @@
|
||||
// Copyright 2020 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
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP_SYSTEM_PM_POWER_DOWN_CPU
|
||||
/**
|
||||
* @brief CPU Power down low-level initialize
|
||||
*
|
||||
* @param enable enable or disable CPU power down during light sleep
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NO_MEM not enough retention memory
|
||||
*/
|
||||
esp_err_t esp_sleep_cpu_pd_low_init(bool enable);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,73 @@
|
||||
// Copyright 2015-2018 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
|
||||
|
||||
#include "esp_attr.h"
|
||||
|
||||
#include "soc/soc_caps.h"
|
||||
#include "hal/cpu_hal.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern bool g_spiram_ok; // [refactor-todo] better way to communicate this from port layer to common startup code
|
||||
|
||||
// Port layer defines the entry point. It then transfer control to a `sys_startup_fn_t`, stored in this
|
||||
// array, one per core.
|
||||
typedef void (*sys_startup_fn_t)(void);
|
||||
|
||||
#if !CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE
|
||||
extern sys_startup_fn_t g_startup_fn[SOC_CPU_CORES_NUM];
|
||||
#else
|
||||
extern sys_startup_fn_t g_startup_fn[1];
|
||||
#endif
|
||||
|
||||
// Utility to execute `sys_startup_fn_t` for the current core.
|
||||
#define SYS_STARTUP_FN() ((*g_startup_fn[(cpu_hal_get_core_id())])())
|
||||
|
||||
#if !CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE
|
||||
void startup_resume_other_cores(void);
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
void (*fn)(void);
|
||||
uint32_t cores;
|
||||
} esp_system_init_fn_t;
|
||||
|
||||
/*
|
||||
* Declare an component initialization function that will execute on the specified cores (ex. if BIT0 == 1, will execute
|
||||
* on CORE0, CORE1 if BIT1 and so on).
|
||||
*
|
||||
* @note Initialization functions should be placed in a compilation unit where at least one other
|
||||
* symbol is referenced 'meaningfully' in another compilation unit, otherwise this gets discarded during linking. (By
|
||||
* 'meaningfully' we mean the reference should not itself get optimized out by the compiler/discarded by the linker).
|
||||
*/
|
||||
#define ESP_SYSTEM_INIT_FN(f, c, ...) \
|
||||
static void __attribute__((used)) __VA_ARGS__ __esp_system_init_fn_##f(void); \
|
||||
static __attribute__((used)) esp_system_init_fn_t _SECTION_ATTR_IMPL(".esp_system_init_fn", f) \
|
||||
esp_system_init_fn_##f = { .fn = ( __esp_system_init_fn_##f), .cores = (c) }; \
|
||||
static __attribute__((used)) __VA_ARGS__ void __esp_system_init_fn_##f(void) // [refactor-todo] this can be made public API if we allow components to declare init functions,
|
||||
// instead of calling them explicitly
|
||||
|
||||
extern uint64_t g_startup_time; // Startup time that serves as the point of origin for system time. Should be set by the entry
|
||||
// function in the port layer. May be 0 as well if this is not backed by a persistent counter, in which case
|
||||
// startup time = system time = 0 at the point the entry function sets this variable.
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,81 @@
|
||||
// Copyright 2018 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
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "esp_system.h"
|
||||
|
||||
#define MWDT0_TICK_PRESCALER 40000
|
||||
#define MWDT0_TICKS_PER_US 500
|
||||
#define MWDT1_TICK_PRESCALER 40000
|
||||
#define MWDT1_TICKS_PER_US 500
|
||||
|
||||
/**
|
||||
* @brief Internal function to restart PRO and APP CPUs.
|
||||
*
|
||||
* @note This function should not be called from FreeRTOS applications.
|
||||
* Use esp_restart instead.
|
||||
*
|
||||
* This is an internal function called by esp_restart. It is called directly
|
||||
* by the panic handler and brownout detector interrupt.
|
||||
*/
|
||||
void esp_restart_noos(void) __attribute__ ((noreturn));
|
||||
|
||||
/**
|
||||
* @brief Similar to esp_restart_noos, but resets all the digital peripherals.
|
||||
*/
|
||||
void esp_restart_noos_dig(void) __attribute__ ((noreturn));
|
||||
|
||||
/**
|
||||
* @brief Internal function to set reset reason hint
|
||||
*
|
||||
* The hint is used do distinguish different reset reasons when software reset
|
||||
* is performed.
|
||||
*
|
||||
* The hint is stored in RTC store register, RTC_RESET_CAUSE_REG.
|
||||
*
|
||||
* @param hint Desired esp_reset_reason_t value for the real reset reason
|
||||
*/
|
||||
void esp_reset_reason_set_hint(esp_reset_reason_t hint);
|
||||
|
||||
/**
|
||||
* @brief Internal function to get the reset hint value
|
||||
* @return - Reset hint value previously stored into RTC_RESET_CAUSE_REG using
|
||||
* esp_reset_reason_set_hint function
|
||||
* - ESP_RST_UNKNOWN if the value in RTC_RESET_CAUSE_REG is invalid
|
||||
*/
|
||||
esp_reset_reason_t esp_reset_reason_get_hint(void);
|
||||
|
||||
/**
|
||||
* @brief Get the time in microseconds since startup
|
||||
*
|
||||
* @returns time since g_startup_time; definition should be fixed by system time provider
|
||||
* no matter the underlying timer used.
|
||||
*/
|
||||
int64_t esp_system_get_time(void);
|
||||
|
||||
/**
|
||||
* @brief Get the resolution of the time returned by `esp_system_get_time`.
|
||||
*
|
||||
* @returns the resolution in nanoseconds
|
||||
*/
|
||||
uint32_t esp_system_get_time_resolution(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,73 @@
|
||||
// Copyright 2019-2020 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
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file usb_console.h
|
||||
* This file contains definitions of low-level USB console functions.
|
||||
* These functions are not considered to be a public interface and
|
||||
* should not be called by applications directly.
|
||||
* Application interface to the USB console is provided either by
|
||||
* "cdcacm" VFS driver, or by the USB CDC driver in TinyUSB.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* RX/TX callback function type
|
||||
* @param arg callback-specific context pointer
|
||||
*/
|
||||
typedef void (*esp_usb_console_cb_t)(void* arg);
|
||||
|
||||
/**
|
||||
* Initialize USB console output using ROM USB CDC driver.
|
||||
* This function is called by the early startup code if USB CDC is
|
||||
* selected as the console output option.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NO_MEM
|
||||
* - other error codes from the interrupt allocator
|
||||
*/
|
||||
esp_err_t esp_usb_console_init(void);
|
||||
|
||||
/**
|
||||
* Write a buffer to USB CDC
|
||||
* @param buf data to write
|
||||
* @param size size of the data, in bytes
|
||||
* @return -1 on error, otherwise the number of bytes
|
||||
*/
|
||||
ssize_t esp_usb_console_write_buf(const char* buf, size_t size);
|
||||
|
||||
ssize_t esp_usb_console_flush(void);
|
||||
|
||||
ssize_t esp_usb_console_read_buf(char* buf, size_t buf_size);
|
||||
|
||||
bool esp_usb_console_read_available(void);
|
||||
|
||||
bool esp_usb_console_write_available(void);
|
||||
|
||||
esp_err_t esp_usb_console_set_cb(esp_usb_console_cb_t rx_cb, esp_usb_console_cb_t tx_cb, void* arg);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
503
tools/sdk/esp32c3/include/esp_system/include/esp_sleep.h
Normal file
503
tools/sdk/esp32c3/include/esp_system/include/esp_sleep.h
Normal file
@ -0,0 +1,503 @@
|
||||
// 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
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#include "hal/touch_sensor_types.h"
|
||||
#include "hal/gpio_types.h"
|
||||
|
||||
#include "soc/soc_caps.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Logic function used for EXT1 wakeup mode.
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_EXT1_WAKEUP_ALL_LOW = 0, //!< Wake the chip when all selected GPIOs go low
|
||||
ESP_EXT1_WAKEUP_ANY_HIGH = 1 //!< Wake the chip when any of the selected GPIOs go high
|
||||
} esp_sleep_ext1_wakeup_mode_t;
|
||||
|
||||
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
|
||||
typedef enum {
|
||||
ESP_GPIO_WAKEUP_GPIO_LOW = 0,
|
||||
ESP_GPIO_WAKEUP_GPIO_HIGH = 1
|
||||
} esp_deepsleep_gpio_wake_up_mode_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Power domains which can be powered down in sleep mode
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_PD_DOMAIN_RTC_PERIPH, //!< RTC IO, sensors and ULP co-processor
|
||||
ESP_PD_DOMAIN_RTC_SLOW_MEM, //!< RTC slow memory
|
||||
ESP_PD_DOMAIN_RTC_FAST_MEM, //!< RTC fast memory
|
||||
ESP_PD_DOMAIN_XTAL, //!< XTAL oscillator
|
||||
ESP_PD_DOMAIN_CPU, //!< CPU core
|
||||
ESP_PD_DOMAIN_VDDSDIO, //!< VDD_SDIO
|
||||
ESP_PD_DOMAIN_MAX //!< Number of domains
|
||||
} esp_sleep_pd_domain_t;
|
||||
|
||||
/**
|
||||
* @brief Power down options
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_PD_OPTION_OFF, //!< Power down the power domain in sleep mode
|
||||
ESP_PD_OPTION_ON, //!< Keep power domain enabled during sleep mode
|
||||
ESP_PD_OPTION_AUTO //!< Keep power domain enabled in sleep mode, if it is needed by one of the wakeup options. Otherwise power it down.
|
||||
} esp_sleep_pd_option_t;
|
||||
|
||||
/**
|
||||
* @brief Sleep wakeup cause
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_SLEEP_WAKEUP_UNDEFINED, //!< In case of deep sleep, reset was not caused by exit from deep sleep
|
||||
ESP_SLEEP_WAKEUP_ALL, //!< Not a wakeup cause, used to disable all wakeup sources with esp_sleep_disable_wakeup_source
|
||||
ESP_SLEEP_WAKEUP_EXT0, //!< Wakeup caused by external signal using RTC_IO
|
||||
ESP_SLEEP_WAKEUP_EXT1, //!< Wakeup caused by external signal using RTC_CNTL
|
||||
ESP_SLEEP_WAKEUP_TIMER, //!< Wakeup caused by timer
|
||||
ESP_SLEEP_WAKEUP_TOUCHPAD, //!< Wakeup caused by touchpad
|
||||
ESP_SLEEP_WAKEUP_ULP, //!< Wakeup caused by ULP program
|
||||
ESP_SLEEP_WAKEUP_GPIO, //!< Wakeup caused by GPIO (light sleep only)
|
||||
ESP_SLEEP_WAKEUP_UART, //!< Wakeup caused by UART (light sleep only)
|
||||
ESP_SLEEP_WAKEUP_WIFI, //!< Wakeup caused by WIFI (light sleep only)
|
||||
ESP_SLEEP_WAKEUP_COCPU, //!< Wakeup caused by COCPU int
|
||||
ESP_SLEEP_WAKEUP_COCPU_TRAP_TRIG, //!< Wakeup caused by COCPU crash
|
||||
ESP_SLEEP_WAKEUP_BT, //!< Wakeup caused by BT (light sleep only)
|
||||
} esp_sleep_source_t;
|
||||
|
||||
/* Leave this type define for compatibility */
|
||||
typedef esp_sleep_source_t esp_sleep_wakeup_cause_t;
|
||||
|
||||
/**
|
||||
* @brief Disable wakeup source
|
||||
*
|
||||
* This function is used to deactivate wake up trigger for source
|
||||
* defined as parameter of the function.
|
||||
*
|
||||
* @note This function does not modify wake up configuration in RTC.
|
||||
* It will be performed in esp_sleep_start function.
|
||||
*
|
||||
* See docs/sleep-modes.rst for details.
|
||||
*
|
||||
* @param source - number of source to disable of type esp_sleep_source_t
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE if trigger was not active
|
||||
*/
|
||||
esp_err_t esp_sleep_disable_wakeup_source(esp_sleep_source_t source);
|
||||
|
||||
#if SOC_ULP_SUPPORTED
|
||||
/**
|
||||
* @brief Enable wakeup by ULP coprocessor
|
||||
* @note In revisions 0 and 1 of the ESP32, ULP wakeup source
|
||||
* cannot be used when RTC_PERIPH power domain is forced
|
||||
* to be powered on (ESP_PD_OPTION_ON) or when
|
||||
* ext0 wakeup source is used.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NOT_SUPPORTED if additional current by touch (CONFIG_ESP32_RTC_EXT_CRYST_ADDIT_CURRENT) is enabled.
|
||||
* - ESP_ERR_INVALID_STATE if ULP co-processor is not enabled or if wakeup triggers conflict
|
||||
*/
|
||||
esp_err_t esp_sleep_enable_ulp_wakeup(void);
|
||||
|
||||
#endif // SOC_ULP_SUPPORTED
|
||||
|
||||
/**
|
||||
* @brief Enable wakeup by timer
|
||||
* @param time_in_us time before wakeup, in microseconds
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if value is out of range (TBD)
|
||||
*/
|
||||
esp_err_t esp_sleep_enable_timer_wakeup(uint64_t time_in_us);
|
||||
|
||||
#if SOC_TOUCH_SENSOR_NUM > 0
|
||||
|
||||
/**
|
||||
* @brief Enable wakeup by touch sensor
|
||||
*
|
||||
* @note In revisions 0 and 1 of the ESP32, touch wakeup source
|
||||
* can not be used when RTC_PERIPH power domain is forced
|
||||
* to be powered on (ESP_PD_OPTION_ON) or when ext0 wakeup
|
||||
* source is used.
|
||||
*
|
||||
* @note The FSM mode of the touch button should be configured
|
||||
* as the timer trigger mode.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NOT_SUPPORTED if additional current by touch (CONFIG_ESP32_RTC_EXT_CRYST_ADDIT_CURRENT) is enabled.
|
||||
* - ESP_ERR_INVALID_STATE if wakeup triggers conflict
|
||||
*/
|
||||
esp_err_t esp_sleep_enable_touchpad_wakeup(void);
|
||||
|
||||
/**
|
||||
* @brief Get the touch pad which caused wakeup
|
||||
*
|
||||
* If wakeup was caused by another source, this function will return TOUCH_PAD_MAX;
|
||||
*
|
||||
* @return touch pad which caused wakeup
|
||||
*/
|
||||
touch_pad_t esp_sleep_get_touchpad_wakeup_status(void);
|
||||
|
||||
#endif // SOC_TOUCH_SENSOR_NUM > 0
|
||||
|
||||
/**
|
||||
* @brief Returns true if a GPIO number is valid for use as wakeup source.
|
||||
*
|
||||
* @note For SoCs with RTC IO capability, this can be any valid RTC IO input pin.
|
||||
*
|
||||
* @param gpio_num Number of the GPIO to test for wakeup source capability
|
||||
*
|
||||
* @return True if this GPIO number will be accepted as a sleep wakeup source.
|
||||
*/
|
||||
bool esp_sleep_is_valid_wakeup_gpio(gpio_num_t gpio_num);
|
||||
|
||||
#if SOC_PM_SUPPORT_EXT_WAKEUP
|
||||
|
||||
/**
|
||||
* @brief Enable wakeup using a pin
|
||||
*
|
||||
* This function uses external wakeup feature of RTC_IO peripheral.
|
||||
* It will work only if RTC peripherals are kept on during sleep.
|
||||
*
|
||||
* This feature can monitor any pin which is an RTC IO. Once the pin transitions
|
||||
* into the state given by level argument, the chip will be woken up.
|
||||
*
|
||||
* @note This function does not modify pin configuration. The pin is
|
||||
* configured in esp_sleep_start, immediately before entering sleep mode.
|
||||
*
|
||||
* @note In revisions 0 and 1 of the ESP32, ext0 wakeup source
|
||||
* can not be used together with touch or ULP wakeup sources.
|
||||
*
|
||||
* @param gpio_num GPIO number used as wakeup source. Only GPIOs which are have RTC
|
||||
* functionality can be used: 0,2,4,12-15,25-27,32-39.
|
||||
* @param level input level which will trigger wakeup (0=low, 1=high)
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if the selected GPIO is not an RTC GPIO,
|
||||
* or the mode is invalid
|
||||
* - ESP_ERR_INVALID_STATE if wakeup triggers conflict
|
||||
*/
|
||||
esp_err_t esp_sleep_enable_ext0_wakeup(gpio_num_t gpio_num, int level);
|
||||
|
||||
/**
|
||||
* @brief Enable wakeup using multiple pins
|
||||
*
|
||||
* This function uses external wakeup feature of RTC controller.
|
||||
* It will work even if RTC peripherals are shut down during sleep.
|
||||
*
|
||||
* This feature can monitor any number of pins which are in RTC IOs.
|
||||
* Once any of the selected pins goes into the state given by mode argument,
|
||||
* the chip will be woken up.
|
||||
*
|
||||
* @note This function does not modify pin configuration. The pins are
|
||||
* configured in esp_sleep_start, immediately before
|
||||
* entering sleep mode.
|
||||
*
|
||||
* @note internal pullups and pulldowns don't work when RTC peripherals are
|
||||
* shut down. In this case, external resistors need to be added.
|
||||
* Alternatively, RTC peripherals (and pullups/pulldowns) may be
|
||||
* kept enabled using esp_sleep_pd_config function.
|
||||
*
|
||||
* @param mask bit mask of GPIO numbers which will cause wakeup. Only GPIOs
|
||||
* which are have RTC functionality can be used in this bit map:
|
||||
* 0,2,4,12-15,25-27,32-39.
|
||||
* @param mode select logic function used to determine wakeup condition:
|
||||
* - ESP_EXT1_WAKEUP_ALL_LOW: wake up when all selected GPIOs are low
|
||||
* - ESP_EXT1_WAKEUP_ANY_HIGH: wake up when any of the selected GPIOs is high
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if any of the selected GPIOs is not an RTC GPIO,
|
||||
* or mode is invalid
|
||||
*/
|
||||
esp_err_t esp_sleep_enable_ext1_wakeup(uint64_t mask, esp_sleep_ext1_wakeup_mode_t mode);
|
||||
|
||||
#endif // SOC_PM_SUPPORT_EXT_WAKEUP
|
||||
|
||||
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
|
||||
/**
|
||||
* @brief Enable wakeup using specific gpio pins
|
||||
*
|
||||
* This function enables an IO pin to wake the chip from deep sleep
|
||||
*
|
||||
* @note This function does not modify pin configuration. The pins are
|
||||
* configured in esp_sleep_start, immediately before
|
||||
* entering sleep mode.
|
||||
*
|
||||
* @note You don't need to care to pull-up or pull-down before using this
|
||||
* function, because this will be done in esp_sleep_start based on
|
||||
* param mask you give. BTW, when you use low level to wake up the
|
||||
* chip, we strongly recommand you to add external registors(pull-up).
|
||||
*
|
||||
* @param gpio_pin_mask Bit mask of GPIO numbers which will cause wakeup. Only GPIOs
|
||||
* which are have RTC functionality can be used in this bit map.
|
||||
* @param mode Select logic function used to determine wakeup condition:
|
||||
* - ESP_GPIO_WAKEUP_GPIO_LOW: wake up when the gpio turn to low.
|
||||
* - ESP_GPIO_WAKEUP_GPIO_HIGH: wake up when the gpio turn to high.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if gpio num is more than 5 or mode is invalid,
|
||||
*/
|
||||
esp_err_t esp_deep_sleep_enable_gpio_wakeup(uint64_t gpio_pin_mask, esp_deepsleep_gpio_wake_up_mode_t mode);
|
||||
#endif
|
||||
/**
|
||||
* @brief Enable wakeup from light sleep using GPIOs
|
||||
*
|
||||
* Each GPIO supports wakeup function, which can be triggered on either low level
|
||||
* or high level. Unlike EXT0 and EXT1 wakeup sources, this method can be used
|
||||
* both for all IOs: RTC IOs and digital IOs. It can only be used to wakeup from
|
||||
* light sleep though.
|
||||
*
|
||||
* To enable wakeup, first call gpio_wakeup_enable, specifying gpio number and
|
||||
* wakeup level, for each GPIO which is used for wakeup.
|
||||
* Then call this function to enable wakeup feature.
|
||||
*
|
||||
* @note In revisions 0 and 1 of the ESP32, GPIO wakeup source
|
||||
* can not be used together with touch or ULP wakeup sources.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE if wakeup triggers conflict
|
||||
*/
|
||||
esp_err_t esp_sleep_enable_gpio_wakeup(void);
|
||||
|
||||
/**
|
||||
* @brief Enable wakeup from light sleep using UART
|
||||
*
|
||||
* Use uart_set_wakeup_threshold function to configure UART wakeup threshold.
|
||||
*
|
||||
* Wakeup from light sleep takes some time, so not every character sent
|
||||
* to the UART can be received by the application.
|
||||
*
|
||||
* @note ESP32 does not support wakeup from UART2.
|
||||
*
|
||||
* @param uart_num UART port to wake up from
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if wakeup from given UART is not supported
|
||||
*/
|
||||
esp_err_t esp_sleep_enable_uart_wakeup(int uart_num);
|
||||
|
||||
/**
|
||||
* @brief Enable wakeup by WiFi MAC
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_sleep_enable_wifi_wakeup(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the bit mask of GPIOs which caused wakeup (ext1)
|
||||
*
|
||||
* If wakeup was caused by another source, this function will return 0.
|
||||
*
|
||||
* @return bit mask, if GPIOn caused wakeup, BIT(n) will be set
|
||||
*/
|
||||
uint64_t esp_sleep_get_ext1_wakeup_status(void);
|
||||
|
||||
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
|
||||
/**
|
||||
* @brief Get the bit mask of GPIOs which caused wakeup (gpio)
|
||||
*
|
||||
* If wakeup was caused by another source, this function will return 0.
|
||||
*
|
||||
* @return bit mask, if GPIOn caused wakeup, BIT(n) will be set
|
||||
*/
|
||||
uint64_t esp_sleep_get_gpio_wakeup_status(void);
|
||||
#endif //SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
|
||||
|
||||
/**
|
||||
* @brief Set power down mode for an RTC power domain in sleep mode
|
||||
*
|
||||
* If not set set using this API, all power domains default to ESP_PD_OPTION_AUTO.
|
||||
*
|
||||
* @param domain power domain to configure
|
||||
* @param option power down option (ESP_PD_OPTION_OFF, ESP_PD_OPTION_ON, or ESP_PD_OPTION_AUTO)
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if either of the arguments is out of range
|
||||
*/
|
||||
esp_err_t esp_sleep_pd_config(esp_sleep_pd_domain_t domain,
|
||||
esp_sleep_pd_option_t option);
|
||||
|
||||
/**
|
||||
* @brief Enter deep sleep with the configured wakeup options
|
||||
*
|
||||
* This function does not return.
|
||||
*/
|
||||
void esp_deep_sleep_start(void) __attribute__((noreturn));
|
||||
|
||||
/**
|
||||
* @brief Enter light sleep with the configured wakeup options
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success (returned after wakeup)
|
||||
* - ESP_ERR_INVALID_STATE if WiFi or BT is not stopped
|
||||
*/
|
||||
esp_err_t esp_light_sleep_start(void);
|
||||
|
||||
/**
|
||||
* @brief Enter deep-sleep mode
|
||||
*
|
||||
* The device will automatically wake up after the deep-sleep time
|
||||
* Upon waking up, the device calls deep sleep wake stub, and then proceeds
|
||||
* to load application.
|
||||
*
|
||||
* Call to this function is equivalent to a call to esp_deep_sleep_enable_timer_wakeup
|
||||
* followed by a call to esp_deep_sleep_start.
|
||||
*
|
||||
* esp_deep_sleep does not shut down WiFi, BT, and higher level protocol
|
||||
* connections gracefully.
|
||||
* Make sure relevant WiFi and BT stack functions are called to close any
|
||||
* connections and deinitialize the peripherals. These include:
|
||||
* - esp_bluedroid_disable
|
||||
* - esp_bt_controller_disable
|
||||
* - esp_wifi_stop
|
||||
*
|
||||
* This function does not return.
|
||||
*
|
||||
* @param time_in_us deep-sleep time, unit: microsecond
|
||||
*/
|
||||
void esp_deep_sleep(uint64_t time_in_us) __attribute__((noreturn));
|
||||
|
||||
|
||||
/**
|
||||
* @brief Get the wakeup source which caused wakeup from sleep
|
||||
*
|
||||
* @return cause of wake up from last sleep (deep sleep or light sleep)
|
||||
*/
|
||||
esp_sleep_wakeup_cause_t esp_sleep_get_wakeup_cause(void);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Default stub to run on wake from deep sleep.
|
||||
*
|
||||
* Allows for executing code immediately on wake from sleep, before
|
||||
* the software bootloader or ESP-IDF app has started up.
|
||||
*
|
||||
* This function is weak-linked, so you can implement your own version
|
||||
* to run code immediately when the chip wakes from
|
||||
* sleep.
|
||||
*
|
||||
* See docs/deep-sleep-stub.rst for details.
|
||||
*/
|
||||
void esp_wake_deep_sleep(void);
|
||||
|
||||
/**
|
||||
* @brief Function type for stub to run on wake from sleep.
|
||||
*
|
||||
*/
|
||||
typedef void (*esp_deep_sleep_wake_stub_fn_t)(void);
|
||||
|
||||
/**
|
||||
* @brief Install a new stub at runtime to run on wake from deep sleep
|
||||
*
|
||||
* If implementing esp_wake_deep_sleep() then it is not necessary to
|
||||
* call this function.
|
||||
*
|
||||
* However, it is possible to call this function to substitute a
|
||||
* different deep sleep stub. Any function used as a deep sleep stub
|
||||
* must be marked RTC_IRAM_ATTR, and must obey the same rules given
|
||||
* for esp_wake_deep_sleep().
|
||||
*/
|
||||
void esp_set_deep_sleep_wake_stub(esp_deep_sleep_wake_stub_fn_t new_stub);
|
||||
|
||||
/**
|
||||
* @brief Get current wake from deep sleep stub
|
||||
* @return Return current wake from deep sleep stub, or NULL if
|
||||
* no stub is installed.
|
||||
*/
|
||||
esp_deep_sleep_wake_stub_fn_t esp_get_deep_sleep_wake_stub(void);
|
||||
|
||||
/**
|
||||
* @brief The default esp-idf-provided esp_wake_deep_sleep() stub.
|
||||
*
|
||||
* See docs/deep-sleep-stub.rst for details.
|
||||
*/
|
||||
void esp_default_wake_deep_sleep(void);
|
||||
|
||||
/**
|
||||
* @brief Disable logging from the ROM code after deep sleep.
|
||||
*
|
||||
* Using LSB of RTC_STORE4.
|
||||
*/
|
||||
void esp_deep_sleep_disable_rom_logging(void);
|
||||
|
||||
#if SOC_GPIO_SUPPORT_SLP_SWITCH
|
||||
/**
|
||||
* @brief Configure to isolate all GPIO pins in sleep state
|
||||
*/
|
||||
void esp_sleep_config_gpio_isolate(void);
|
||||
|
||||
/**
|
||||
* @brief Enable or disable GPIO pins status switching between slept status and waked status.
|
||||
* @param enable decide whether to switch status or not
|
||||
*/
|
||||
void esp_sleep_enable_gpio_switch(bool enable);
|
||||
#endif
|
||||
|
||||
#if CONFIG_MAC_BB_PD
|
||||
/**
|
||||
* @brief Function type for stub to run mac bb power down.
|
||||
*/
|
||||
typedef void (* mac_bb_power_down_cb_t)(void);
|
||||
|
||||
/**
|
||||
* @brief Function type for stub to run mac bb power up.
|
||||
*/
|
||||
typedef void (* mac_bb_power_up_cb_t)(void);
|
||||
|
||||
/**
|
||||
* @brief Registet mac bb power down callback.
|
||||
* @param cb mac bb power down callback.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_register_mac_bb_pd_callback(mac_bb_power_down_cb_t cb);
|
||||
|
||||
/**
|
||||
* @brief Unregistet mac bb power down callback.
|
||||
* @param cb mac bb power down callback.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_unregister_mac_bb_pd_callback(mac_bb_power_down_cb_t cb);
|
||||
|
||||
/**
|
||||
* @brief Registet mac bb power up callback.
|
||||
* @param cb mac bb power up callback.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_register_mac_bb_pu_callback(mac_bb_power_up_cb_t cb);
|
||||
|
||||
/**
|
||||
* @brief Unregistet mac bb power up callback.
|
||||
* @param cb mac bb power up callback.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_unregister_mac_bb_pu_callback(mac_bb_power_up_cb_t cb);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
310
tools/sdk/esp32c3/include/esp_system/include/esp_system.h
Normal file
310
tools/sdk/esp32c3/include/esp_system/include/esp_system.h
Normal file
@ -0,0 +1,310 @@
|
||||
// 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_SYSTEM_H__
|
||||
#define __ESP_SYSTEM_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_attr.h"
|
||||
#include "esp_bit_defs.h"
|
||||
#include "esp_idf_version.h"
|
||||
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
ESP_MAC_WIFI_STA,
|
||||
ESP_MAC_WIFI_SOFTAP,
|
||||
ESP_MAC_BT,
|
||||
ESP_MAC_ETH,
|
||||
} esp_mac_type_t;
|
||||
|
||||
/** @cond */
|
||||
#define TWO_UNIVERSAL_MAC_ADDR 2
|
||||
#define FOUR_UNIVERSAL_MAC_ADDR 4
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32S2_UNIVERSAL_MAC_ADDRESSES
|
||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||
#define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32S3_UNIVERSAL_MAC_ADDRESSES
|
||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||
#define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32C3_UNIVERSAL_MAC_ADDRESSES
|
||||
#endif
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* @brief Reset reasons
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_RST_UNKNOWN, //!< Reset reason can not be determined
|
||||
ESP_RST_POWERON, //!< Reset due to power-on event
|
||||
ESP_RST_EXT, //!< Reset by external pin (not applicable for ESP32)
|
||||
ESP_RST_SW, //!< Software reset via esp_restart
|
||||
ESP_RST_PANIC, //!< Software reset due to exception/panic
|
||||
ESP_RST_INT_WDT, //!< Reset (software or hardware) due to interrupt watchdog
|
||||
ESP_RST_TASK_WDT, //!< Reset due to task watchdog
|
||||
ESP_RST_WDT, //!< Reset due to other watchdogs
|
||||
ESP_RST_DEEPSLEEP, //!< Reset after exiting deep sleep mode
|
||||
ESP_RST_BROWNOUT, //!< Brownout reset (software or hardware)
|
||||
ESP_RST_SDIO, //!< Reset over SDIO
|
||||
} esp_reset_reason_t;
|
||||
|
||||
/**
|
||||
* Shutdown handler type
|
||||
*/
|
||||
typedef void (*shutdown_handler_t)(void);
|
||||
|
||||
/**
|
||||
* @brief Register shutdown handler
|
||||
*
|
||||
* This function allows you to register a handler that gets invoked before
|
||||
* the application is restarted using esp_restart function.
|
||||
* @param handle function to execute on restart
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE if the handler has already been registered
|
||||
* - ESP_ERR_NO_MEM if no more shutdown handler slots are available
|
||||
*/
|
||||
esp_err_t esp_register_shutdown_handler(shutdown_handler_t handle);
|
||||
|
||||
/**
|
||||
* @brief Unregister shutdown handler
|
||||
*
|
||||
* This function allows you to unregister a handler which was previously
|
||||
* registered using esp_register_shutdown_handler function.
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE if the given handler hasn't been registered before
|
||||
*/
|
||||
esp_err_t esp_unregister_shutdown_handler(shutdown_handler_t handle);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Restart PRO and APP CPUs.
|
||||
*
|
||||
* This function can be called both from PRO and APP CPUs.
|
||||
* After successful restart, CPU reset reason will be SW_CPU_RESET.
|
||||
* Peripherals (except for WiFi, BT, UART0, SPI1, and legacy timers) are not reset.
|
||||
* This function does not return.
|
||||
*/
|
||||
void esp_restart(void) __attribute__ ((noreturn));
|
||||
|
||||
/**
|
||||
* @brief Get reason of last reset
|
||||
* @return See description of esp_reset_reason_t for explanation of each value.
|
||||
*/
|
||||
esp_reset_reason_t esp_reset_reason(void);
|
||||
|
||||
/**
|
||||
* @brief Get the size of available heap.
|
||||
*
|
||||
* Note that the returned value may be larger than the maximum contiguous block
|
||||
* which can be allocated.
|
||||
*
|
||||
* @return Available heap size, in bytes.
|
||||
*/
|
||||
uint32_t esp_get_free_heap_size(void);
|
||||
|
||||
/**
|
||||
* @brief Get the size of available internal heap.
|
||||
*
|
||||
* Note that the returned value may be larger than the maximum contiguous block
|
||||
* which can be allocated.
|
||||
*
|
||||
* @return Available internal heap size, in bytes.
|
||||
*/
|
||||
uint32_t esp_get_free_internal_heap_size(void);
|
||||
|
||||
/**
|
||||
* @brief Get the minimum heap that has ever been available
|
||||
*
|
||||
* @return Minimum free heap ever available
|
||||
*/
|
||||
uint32_t esp_get_minimum_free_heap_size( void );
|
||||
|
||||
/**
|
||||
* @brief Get one random 32-bit word from hardware RNG
|
||||
*
|
||||
* The hardware RNG is fully functional whenever an RF subsystem is running (ie Bluetooth or WiFi is enabled). For
|
||||
* random values, call this function after WiFi or Bluetooth are started.
|
||||
*
|
||||
* If the RF subsystem is not used by the program, the function bootloader_random_enable() can be called to enable an
|
||||
* entropy source. bootloader_random_disable() must be called before RF subsystem or I2S peripheral are used. See these functions'
|
||||
* documentation for more details.
|
||||
*
|
||||
* Any time the app is running without an RF subsystem (or bootloader_random) enabled, RNG hardware should be
|
||||
* considered a PRNG. A very small amount of entropy is available due to pre-seeding while the IDF
|
||||
* bootloader is running, but this should not be relied upon for any use.
|
||||
*
|
||||
* @return Random value between 0 and UINT32_MAX
|
||||
*/
|
||||
uint32_t esp_random(void);
|
||||
|
||||
/**
|
||||
* @brief Fill a buffer with random bytes from hardware RNG
|
||||
*
|
||||
* @note This function has the same restrictions regarding available entropy as esp_random()
|
||||
*
|
||||
* @param buf Pointer to buffer to fill with random numbers.
|
||||
* @param len Length of buffer in bytes
|
||||
*/
|
||||
void esp_fill_random(void *buf, size_t len);
|
||||
|
||||
/**
|
||||
* @brief Set base MAC address with the MAC address which is stored in BLK3 of EFUSE or
|
||||
* external storage e.g. flash and EEPROM.
|
||||
*
|
||||
* Base MAC address is used to generate the MAC addresses used by the networking interfaces.
|
||||
* If using base MAC address stored in BLK3 of EFUSE or external storage, call this API to set base MAC
|
||||
* address with the MAC address which is stored in BLK3 of EFUSE or external storage before initializing
|
||||
* WiFi/BT/Ethernet.
|
||||
*
|
||||
* @note Base MAC must be a unicast MAC (least significant bit of first byte must be zero).
|
||||
*
|
||||
* @note If not using a valid OUI, set the "locally administered" bit
|
||||
* (bit value 0x02 in the first byte) to avoid collisions.
|
||||
*
|
||||
* @param mac base MAC address, length: 6 bytes.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* ESP_ERR_INVALID_ARG If mac is NULL or is not a unicast MAC
|
||||
*/
|
||||
esp_err_t esp_base_mac_addr_set(const uint8_t *mac);
|
||||
|
||||
/**
|
||||
* @brief Return base MAC address which is set using esp_base_mac_addr_set.
|
||||
*
|
||||
* @param mac base MAC address, length: 6 bytes.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* ESP_ERR_INVALID_MAC base MAC address has not been set
|
||||
*/
|
||||
esp_err_t esp_base_mac_addr_get(uint8_t *mac);
|
||||
|
||||
/**
|
||||
* @brief Return base MAC address which was previously written to BLK3 of EFUSE.
|
||||
*
|
||||
* Base MAC address is used to generate the MAC addresses used by the networking interfaces.
|
||||
* This API returns the custom base MAC address which was previously written to BLK3 of EFUSE.
|
||||
* Writing this EFUSE allows setting of a different (non-Espressif) base MAC address. It is also
|
||||
* possible to store a custom base MAC address elsewhere, see esp_base_mac_addr_set() for details.
|
||||
*
|
||||
* @param mac base MAC address, length: 6 bytes.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
* ESP_ERR_INVALID_VERSION An invalid MAC version field was read from BLK3 of EFUSE
|
||||
* ESP_ERR_INVALID_CRC An invalid MAC CRC was read from BLK3 of EFUSE
|
||||
*/
|
||||
esp_err_t esp_efuse_mac_get_custom(uint8_t *mac);
|
||||
|
||||
/**
|
||||
* @brief Return base MAC address which is factory-programmed by Espressif in BLK0 of EFUSE.
|
||||
*
|
||||
* @param mac base MAC address, length: 6 bytes.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_efuse_mac_get_default(uint8_t *mac);
|
||||
|
||||
/**
|
||||
* @brief Read base MAC address and set MAC address of the interface.
|
||||
*
|
||||
* This function first get base MAC address using esp_base_mac_addr_get or reads base MAC address
|
||||
* from BLK0 of EFUSE. Then set the MAC address of the interface including wifi station, wifi softap,
|
||||
* bluetooth and ethernet.
|
||||
*
|
||||
* @param mac MAC address of the interface, length: 6 bytes.
|
||||
* @param type type of MAC address, 0:wifi station, 1:wifi softap, 2:bluetooth, 3:ethernet.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_read_mac(uint8_t* mac, esp_mac_type_t type);
|
||||
|
||||
/**
|
||||
* @brief Derive local MAC address from universal MAC address.
|
||||
*
|
||||
* This function derives a local MAC address from an universal MAC address.
|
||||
* A `definition of local vs universal MAC address can be found on Wikipedia
|
||||
* <https://en.wikipedia.org/wiki/MAC_address#Universal_vs._local>`.
|
||||
* In ESP32, universal MAC address is generated from base MAC address in EFUSE or other external storage.
|
||||
* Local MAC address is derived from the universal MAC address.
|
||||
*
|
||||
* @param local_mac Derived local MAC address, length: 6 bytes.
|
||||
* @param universal_mac Source universal MAC address, length: 6 bytes.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_derive_local_mac(uint8_t* local_mac, const uint8_t* universal_mac);
|
||||
|
||||
/**
|
||||
* @brief Trigger a software abort
|
||||
*
|
||||
* @param details Details that will be displayed during panic handling.
|
||||
*/
|
||||
void __attribute__((noreturn)) esp_system_abort(const char* details);
|
||||
|
||||
/**
|
||||
* @brief Chip models
|
||||
*/
|
||||
typedef enum {
|
||||
CHIP_ESP32 = 1, //!< ESP32
|
||||
CHIP_ESP32S2 = 2, //!< ESP32-S2
|
||||
CHIP_ESP32S3 = 4, //!< ESP32-S3
|
||||
CHIP_ESP32C3 = 5, //!< ESP32-C3
|
||||
} esp_chip_model_t;
|
||||
|
||||
/* Chip feature flags, used in esp_chip_info_t */
|
||||
#define CHIP_FEATURE_EMB_FLASH BIT(0) //!< Chip has embedded flash memory
|
||||
#define CHIP_FEATURE_WIFI_BGN BIT(1) //!< Chip has 2.4GHz WiFi
|
||||
#define CHIP_FEATURE_BLE BIT(4) //!< Chip has Bluetooth LE
|
||||
#define CHIP_FEATURE_BT BIT(5) //!< Chip has Bluetooth Classic
|
||||
|
||||
/**
|
||||
* @brief The structure represents information about the chip
|
||||
*/
|
||||
typedef struct {
|
||||
esp_chip_model_t model; //!< chip model, one of esp_chip_model_t
|
||||
uint32_t features; //!< bit mask of CHIP_FEATURE_x feature flags
|
||||
uint8_t cores; //!< number of CPU cores
|
||||
uint8_t revision; //!< chip revision number
|
||||
} esp_chip_info_t;
|
||||
|
||||
/**
|
||||
* @brief Fill an esp_chip_info_t structure with information about the chip
|
||||
* @param[out] out_info structure to be filled
|
||||
*/
|
||||
void esp_chip_info(esp_chip_info_t* out_info);
|
||||
|
||||
|
||||
#if CONFIG_ESP32_ECO3_CACHE_LOCK_FIX
|
||||
/**
|
||||
* @brief Cache lock bug exists or not
|
||||
*
|
||||
* @return
|
||||
* - ture : bug exists
|
||||
* - false : bug not exists
|
||||
*/
|
||||
bool soc_has_cache_lock_bug(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_SYSTEM_H__ */
|
60
tools/sdk/esp32c3/include/esp_system/include/esp_task.h
Normal file
60
tools/sdk/esp32c3/include/esp_system/include/esp_task.h
Normal file
@ -0,0 +1,60 @@
|
||||
// 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.
|
||||
|
||||
/* Notes:
|
||||
* 1. Put all task priority and stack size definition in this file
|
||||
* 2. If the task priority is less than 10, use ESP_TASK_PRIO_MIN + X style,
|
||||
* otherwise use ESP_TASK_PRIO_MAX - X style
|
||||
* 3. If this is a daemon task, the macro prefix is ESP_TASKD_, otherwise
|
||||
* it's ESP_TASK_
|
||||
* 4. If the configMAX_PRIORITIES is modified, please make all priority are
|
||||
* greater than 0
|
||||
* 5. Make sure esp_task.h is consistent between wifi lib and idf
|
||||
*/
|
||||
|
||||
#ifndef _ESP_TASK_H_
|
||||
#define _ESP_TASK_H_
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/FreeRTOSConfig.h"
|
||||
|
||||
#define ESP_TASK_PRIO_MAX (configMAX_PRIORITIES)
|
||||
#define ESP_TASK_PRIO_MIN (0)
|
||||
|
||||
/* Bt contoller Task */
|
||||
/* controller */
|
||||
#define ESP_TASK_BT_CONTROLLER_PRIO (ESP_TASK_PRIO_MAX - 2)
|
||||
#ifdef CONFIG_NEWLIB_NANO_FORMAT
|
||||
#define TASK_EXTRA_STACK_SIZE (0)
|
||||
#else
|
||||
#define TASK_EXTRA_STACK_SIZE (512)
|
||||
#endif
|
||||
|
||||
#define BT_TASK_EXTRA_STACK_SIZE TASK_EXTRA_STACK_SIZE
|
||||
#define ESP_TASK_BT_CONTROLLER_STACK (3584 + TASK_EXTRA_STACK_SIZE)
|
||||
|
||||
|
||||
/* idf task */
|
||||
#define ESP_TASK_TIMER_PRIO (ESP_TASK_PRIO_MAX - 3)
|
||||
#define ESP_TASK_TIMER_STACK (CONFIG_ESP_TIMER_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE)
|
||||
#define ESP_TASKD_EVENT_PRIO (ESP_TASK_PRIO_MAX - 5)
|
||||
#define ESP_TASKD_EVENT_STACK (CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE)
|
||||
#define ESP_TASK_TCPIP_PRIO (ESP_TASK_PRIO_MAX - 7)
|
||||
#define ESP_TASK_TCPIP_STACK (CONFIG_LWIP_TCPIP_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE)
|
||||
#define ESP_TASK_MAIN_PRIO (ESP_TASK_PRIO_MIN + 1)
|
||||
#define ESP_TASK_MAIN_STACK (CONFIG_ESP_MAIN_TASK_STACK_SIZE + TASK_EXTRA_STACK_SIZE)
|
||||
#define ESP_TASK_MAIN_CORE CONFIG_ESP_MAIN_TASK_AFFINITY
|
||||
|
||||
#endif
|
147
tools/sdk/esp32c3/include/esp_system/include/esp_task_wdt.h
Normal file
147
tools/sdk/esp32c3/include/esp_system/include/esp_task_wdt.h
Normal file
@ -0,0 +1,147 @@
|
||||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initialize the Task Watchdog Timer (TWDT)
|
||||
*
|
||||
* This function configures and initializes the TWDT. If the TWDT is already
|
||||
* initialized when this function is called, this function will update the
|
||||
* TWDT's timeout period and panic configurations instead. After initializing
|
||||
* the TWDT, any task can elect to be watched by the TWDT by subscribing to it
|
||||
* using esp_task_wdt_add().
|
||||
*
|
||||
* @param[in] timeout Timeout period of TWDT in seconds
|
||||
* @param[in] panic Flag that controls whether the panic handler will be
|
||||
* executed when the TWDT times out
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Initialization was successful
|
||||
* - ESP_ERR_NO_MEM: Initialization failed due to lack of memory
|
||||
*
|
||||
* @note esp_task_wdt_init() must only be called after the scheduler
|
||||
* started
|
||||
*/
|
||||
esp_err_t esp_task_wdt_init(uint32_t timeout, bool panic);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize the Task Watchdog Timer (TWDT)
|
||||
*
|
||||
* This function will deinitialize the TWDT. Calling this function whilst tasks
|
||||
* are still subscribed to the TWDT, or when the TWDT is already deinitialized,
|
||||
* will result in an error code being returned.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: TWDT successfully deinitialized
|
||||
* - ESP_ERR_INVALID_STATE: Error, tasks are still subscribed to the TWDT
|
||||
* - ESP_ERR_NOT_FOUND: Error, TWDT has already been deinitialized
|
||||
*/
|
||||
esp_err_t esp_task_wdt_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Subscribe a task to the Task Watchdog Timer (TWDT)
|
||||
*
|
||||
* This function subscribes a task to the TWDT. Each subscribed task must
|
||||
* periodically call esp_task_wdt_reset() to prevent the TWDT from elapsing its
|
||||
* timeout period. Failure to do so will result in a TWDT timeout. If the task
|
||||
* being subscribed is one of the Idle Tasks, this function will automatically
|
||||
* enable esp_task_wdt_reset() to called from the Idle Hook of the Idle Task.
|
||||
* Calling this function whilst the TWDT is uninitialized or attempting to
|
||||
* subscribe an already subscribed task will result in an error code being
|
||||
* returned.
|
||||
*
|
||||
* @param[in] handle Handle of the task. Input NULL to subscribe the current
|
||||
* running task to the TWDT
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Successfully subscribed the task to the TWDT
|
||||
* - ESP_ERR_INVALID_ARG: Error, the task is already subscribed
|
||||
* - ESP_ERR_NO_MEM: Error, could not subscribe the task due to lack of
|
||||
* memory
|
||||
* - ESP_ERR_INVALID_STATE: Error, the TWDT has not been initialized yet
|
||||
*/
|
||||
esp_err_t esp_task_wdt_add(TaskHandle_t handle);
|
||||
|
||||
/**
|
||||
* @brief Reset the Task Watchdog Timer (TWDT) on behalf of the currently
|
||||
* running task
|
||||
*
|
||||
* This function will reset the TWDT on behalf of the currently running task.
|
||||
* Each subscribed task must periodically call this function to prevent the
|
||||
* TWDT from timing out. If one or more subscribed tasks fail to reset the
|
||||
* TWDT on their own behalf, a TWDT timeout will occur. If the IDLE tasks have
|
||||
* been subscribed to the TWDT, they will automatically call this function from
|
||||
* their idle hooks. Calling this function from a task that has not subscribed
|
||||
* to the TWDT, or when the TWDT is uninitialized will result in an error code
|
||||
* being returned.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Successfully reset the TWDT on behalf of the currently
|
||||
* running task
|
||||
* - ESP_ERR_NOT_FOUND: Error, the current running task has not subscribed
|
||||
* to the TWDT
|
||||
* - ESP_ERR_INVALID_STATE: Error, the TWDT has not been initialized yet
|
||||
*/
|
||||
esp_err_t esp_task_wdt_reset(void);
|
||||
|
||||
/**
|
||||
* @brief Unsubscribes a task from the Task Watchdog Timer (TWDT)
|
||||
*
|
||||
* This function will unsubscribe a task from the TWDT. After being
|
||||
* unsubscribed, the task should no longer call esp_task_wdt_reset(). If the
|
||||
* task is an IDLE task, this function will automatically disable the calling
|
||||
* of esp_task_wdt_reset() from the Idle Hook. Calling this function whilst the
|
||||
* TWDT is uninitialized or attempting to unsubscribe an already unsubscribed
|
||||
* task from the TWDT will result in an error code being returned.
|
||||
*
|
||||
* @param[in] handle Handle of the task. Input NULL to unsubscribe the
|
||||
* current running task.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Successfully unsubscribed the task from the TWDT
|
||||
* - ESP_ERR_INVALID_ARG: Error, the task is already unsubscribed
|
||||
* - ESP_ERR_INVALID_STATE: Error, the TWDT has not been initialized yet
|
||||
*/
|
||||
esp_err_t esp_task_wdt_delete(TaskHandle_t handle);
|
||||
|
||||
/**
|
||||
* @brief Query whether a task is subscribed to the Task Watchdog Timer (TWDT)
|
||||
*
|
||||
* This function will query whether a task is currently subscribed to the TWDT,
|
||||
* or whether the TWDT is initialized.
|
||||
*
|
||||
* @param[in] handle Handle of the task. Input NULL to query the current
|
||||
* running task.
|
||||
*
|
||||
* @return:
|
||||
* - ESP_OK: The task is currently subscribed to the TWDT
|
||||
* - ESP_ERR_NOT_FOUND: The task is currently not subscribed to the TWDT
|
||||
* - ESP_ERR_INVALID_STATE: The TWDT is not initialized, therefore no tasks
|
||||
* can be subscribed
|
||||
*/
|
||||
esp_err_t esp_task_wdt_status(TaskHandle_t handle);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user