forked from espressif/arduino-esp32
Initial Commit
This commit is contained in:
37
tools/sdk/esp32/include/esp_common/include/esp_assert.h
Normal file
37
tools/sdk/esp32/include/esp_common/include/esp_assert.h
Normal file
@ -0,0 +1,37 @@
|
||||
// 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.
|
||||
#ifndef __ESP_ASSERT_H__
|
||||
#define __ESP_ASSERT_H__
|
||||
|
||||
#include "assert.h"
|
||||
|
||||
/* Assert at compile time if possible, runtime otherwise */
|
||||
#ifndef __cplusplus
|
||||
/* __builtin_choose_expr() is only in C, makes this a lot cleaner */
|
||||
#define TRY_STATIC_ASSERT(CONDITION, MSG) do { \
|
||||
_Static_assert(__builtin_choose_expr(__builtin_constant_p(CONDITION), (CONDITION), 1), #MSG); \
|
||||
assert(#MSG && (CONDITION)); \
|
||||
} while(0)
|
||||
#else
|
||||
/* for C++, use __attribute__((error)) - works almost as well as _Static_assert */
|
||||
#define TRY_STATIC_ASSERT(CONDITION, MSG) do { \
|
||||
if (__builtin_constant_p(CONDITION) && !(CONDITION)) { \
|
||||
extern __attribute__((error(#MSG))) void failed_compile_time_assert(void); \
|
||||
failed_compile_time_assert(); \
|
||||
} \
|
||||
assert(#MSG && (CONDITION)); \
|
||||
} while(0)
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __ESP_ASSERT_H__ */
|
63
tools/sdk/esp32/include/esp_common/include/esp_bit_defs.h
Normal file
63
tools/sdk/esp32/include/esp_common/include/esp_bit_defs.h
Normal file
@ -0,0 +1,63 @@
|
||||
// Copyright 2010-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
|
||||
|
||||
//Register Bits{{
|
||||
#define BIT31 0x80000000
|
||||
#define BIT30 0x40000000
|
||||
#define BIT29 0x20000000
|
||||
#define BIT28 0x10000000
|
||||
#define BIT27 0x08000000
|
||||
#define BIT26 0x04000000
|
||||
#define BIT25 0x02000000
|
||||
#define BIT24 0x01000000
|
||||
#define BIT23 0x00800000
|
||||
#define BIT22 0x00400000
|
||||
#define BIT21 0x00200000
|
||||
#define BIT20 0x00100000
|
||||
#define BIT19 0x00080000
|
||||
#define BIT18 0x00040000
|
||||
#define BIT17 0x00020000
|
||||
#define BIT16 0x00010000
|
||||
#define BIT15 0x00008000
|
||||
#define BIT14 0x00004000
|
||||
#define BIT13 0x00002000
|
||||
#define BIT12 0x00001000
|
||||
#define BIT11 0x00000800
|
||||
#define BIT10 0x00000400
|
||||
#define BIT9 0x00000200
|
||||
#define BIT8 0x00000100
|
||||
#define BIT7 0x00000080
|
||||
#define BIT6 0x00000040
|
||||
#define BIT5 0x00000020
|
||||
#define BIT4 0x00000010
|
||||
#define BIT3 0x00000008
|
||||
#define BIT2 0x00000004
|
||||
#define BIT1 0x00000002
|
||||
#define BIT0 0x00000001
|
||||
//}}
|
||||
|
||||
#ifndef __ASSEMBLER__
|
||||
#ifndef BIT
|
||||
#define BIT(nr) (1UL << (nr))
|
||||
#endif
|
||||
#ifndef BIT64
|
||||
#define BIT64(nr) (1ULL << (nr))
|
||||
#endif
|
||||
#else
|
||||
#ifndef BIT
|
||||
#define BIT(nr) (1 << (nr))
|
||||
#endif
|
||||
#endif
|
51
tools/sdk/esp32/include/esp_common/include/esp_compiler.h
Normal file
51
tools/sdk/esp32/include/esp_common/include/esp_compiler.h
Normal file
@ -0,0 +1,51 @@
|
||||
// Copyright 2016-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.
|
||||
#ifndef __ESP_COMPILER_H
|
||||
#define __ESP_COMPILER_H
|
||||
|
||||
/*
|
||||
* The likely and unlikely macro pairs:
|
||||
* These macros are useful to place when application
|
||||
* knows the majority ocurrence of a decision paths,
|
||||
* placing one of these macros can hint the compiler
|
||||
* to reorder instructions producing more optimized
|
||||
* code.
|
||||
*/
|
||||
#if (CONFIG_COMPILER_OPTIMIZATION_PERF)
|
||||
#define likely(x) __builtin_expect(!!(x), 1)
|
||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||
#else
|
||||
#define likely(x) (x)
|
||||
#define unlikely(x) (x)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Utility macros used for designated initializers, which work differently
|
||||
* in C99 and C++ standards mainly for aggregate types.
|
||||
* The member separator, comma, is already part of the macro, please omit the trailing comma.
|
||||
* Usage example:
|
||||
* struct config_t { char* pchr; char arr[SIZE]; } config = {
|
||||
* ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(pchr)
|
||||
* ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_STR(arr, "Value")
|
||||
* };
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
#define ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_STR(member, value) { .member = value },
|
||||
#define ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(member) .member = { },
|
||||
#else
|
||||
#define ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_STR(member, value) .member = value,
|
||||
#define ESP_COMPILER_DESIGNATED_INIT_AGGREGATE_TYPE_EMPTY(member)
|
||||
#endif
|
||||
|
||||
#endif
|
113
tools/sdk/esp32/include/esp_common/include/esp_crc.h
Normal file
113
tools/sdk/esp32/include/esp_common/include/esp_crc.h
Normal file
@ -0,0 +1,113 @@
|
||||
// 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
|
||||
|
||||
#include <stdint.h>
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#if defined(CONFIG_IDF_TARGET_ESP32)
|
||||
#include "esp32/rom/crc.h"
|
||||
#endif
|
||||
|
||||
/******************* Polynomials Used in the CRC APIs ****************************
|
||||
* CRC-8 x8+x2+x1+1 0x07
|
||||
* CRC16-CCITT x16+x12+x5+1 0x1021
|
||||
* CRC32 x32+x26+x23+x22+x16+x12+x11+x10+x8+x7+x5+x4+x2+x1+1 0x04c11db7
|
||||
********************************************************************************/
|
||||
|
||||
/**
|
||||
* @brief CRC32 value in little endian.
|
||||
*
|
||||
* @param crc: Initial CRC value (result of last calculation or 0 for the first time)
|
||||
* @param buf: Data buffer that used to calculate the CRC value
|
||||
* @param len: Length of the data buffer
|
||||
* @return CRC32 value
|
||||
*/
|
||||
static inline uint32_t esp_crc32_le(uint32_t crc, uint8_t const *buf, uint32_t len)
|
||||
{
|
||||
return crc32_le(crc, buf, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CRC32 value in big endian.
|
||||
*
|
||||
* @param crc: Initial CRC value (result of last calculation or 0 for the first time)
|
||||
* @param buf: Data buffer that used to calculate the CRC value
|
||||
* @param len: Length of the data buffer
|
||||
* @return CRC32 value
|
||||
*/
|
||||
static inline uint32_t esp_crc32_be(uint32_t crc, uint8_t const *buf, uint32_t len)
|
||||
{
|
||||
return crc32_be(crc, buf, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CRC16 value in little endian.
|
||||
*
|
||||
* @param crc: Initial CRC value (result of last calculation or 0 for the first time)
|
||||
* @param buf: Data buffer that used to calculate the CRC value
|
||||
* @param len: Length of the data buffer
|
||||
* @return CRC16 value
|
||||
*/
|
||||
static inline uint16_t esp_crc16_le(uint16_t crc, uint8_t const *buf, uint32_t len)
|
||||
{
|
||||
return crc16_le(crc, buf, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CRC16 value in big endian.
|
||||
*
|
||||
* @param crc: Initial CRC value (result of last calculation or 0 for the first time)
|
||||
* @param buf: Data buffer that used to calculate the CRC value
|
||||
* @param len: Length of the data buffer
|
||||
* @return CRC16 value
|
||||
*/
|
||||
static inline uint16_t esp_crc16_be(uint16_t crc, uint8_t const *buf, uint32_t len)
|
||||
{
|
||||
return crc16_be(crc, buf, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CRC8 value in little endian.
|
||||
*
|
||||
* @param crc: Initial CRC value (result of last calculation or 0 for the first time)
|
||||
* @param buf: Data buffer that used to calculate the CRC value
|
||||
* @param len: Length of the data buffer
|
||||
* @return CRC8 value
|
||||
*/
|
||||
static inline uint8_t esp_crc8_le(uint8_t crc, uint8_t const *buf, uint32_t len)
|
||||
{
|
||||
return crc8_le(crc, buf, len);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief CRC8 value in big endian.
|
||||
*
|
||||
* @param crc: Initial CRC value (result of last calculation or 0 for the first time)
|
||||
* @param buf: Data buffer that used to calculate the CRC value
|
||||
* @param len: Length of the data buffer
|
||||
* @return CRC8 value
|
||||
*/
|
||||
static inline uint8_t esp_crc8_be(uint8_t crc, uint8_t const *buf, uint32_t len)
|
||||
{
|
||||
return crc8_be(crc, buf, len);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
149
tools/sdk/esp32/include/esp_common/include/esp_err.h
Normal file
149
tools/sdk/esp32/include/esp_common/include/esp_err.h
Normal file
@ -0,0 +1,149 @@
|
||||
// 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 <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef int32_t esp_err_t;
|
||||
|
||||
/* Definitions for error constants. */
|
||||
#define ESP_OK 0 /*!< esp_err_t value indicating success (no error) */
|
||||
#define ESP_FAIL -1 /*!< Generic esp_err_t code indicating failure */
|
||||
|
||||
#define ESP_ERR_NO_MEM 0x101 /*!< Out of memory */
|
||||
#define ESP_ERR_INVALID_ARG 0x102 /*!< Invalid argument */
|
||||
#define ESP_ERR_INVALID_STATE 0x103 /*!< Invalid state */
|
||||
#define ESP_ERR_INVALID_SIZE 0x104 /*!< Invalid size */
|
||||
#define ESP_ERR_NOT_FOUND 0x105 /*!< Requested resource not found */
|
||||
#define ESP_ERR_NOT_SUPPORTED 0x106 /*!< Operation or feature not supported */
|
||||
#define ESP_ERR_TIMEOUT 0x107 /*!< Operation timed out */
|
||||
#define ESP_ERR_INVALID_RESPONSE 0x108 /*!< Received response was invalid */
|
||||
#define ESP_ERR_INVALID_CRC 0x109 /*!< CRC or checksum was invalid */
|
||||
#define ESP_ERR_INVALID_VERSION 0x10A /*!< Version was invalid */
|
||||
#define ESP_ERR_INVALID_MAC 0x10B /*!< MAC address was invalid */
|
||||
|
||||
#define ESP_ERR_WIFI_BASE 0x3000 /*!< Starting number of WiFi error codes */
|
||||
#define ESP_ERR_MESH_BASE 0x4000 /*!< Starting number of MESH error codes */
|
||||
#define ESP_ERR_FLASH_BASE 0x6000 /*!< Starting number of flash error codes */
|
||||
|
||||
/**
|
||||
* @brief Returns string for esp_err_t error codes
|
||||
*
|
||||
* This function finds the error code in a pre-generated lookup-table and
|
||||
* returns its string representation.
|
||||
*
|
||||
* The function is generated by the Python script
|
||||
* tools/gen_esp_err_to_name.py which should be run each time an esp_err_t
|
||||
* error is modified, created or removed from the IDF project.
|
||||
*
|
||||
* @param code esp_err_t error code
|
||||
* @return string error message
|
||||
*/
|
||||
const char *esp_err_to_name(esp_err_t code);
|
||||
|
||||
/**
|
||||
* @brief Returns string for esp_err_t and system error codes
|
||||
*
|
||||
* This function finds the error code in a pre-generated lookup-table of
|
||||
* esp_err_t errors and returns its string representation. If the error code
|
||||
* is not found then it is attempted to be found among system errors.
|
||||
*
|
||||
* The function is generated by the Python script
|
||||
* tools/gen_esp_err_to_name.py which should be run each time an esp_err_t
|
||||
* error is modified, created or removed from the IDF project.
|
||||
*
|
||||
* @param code esp_err_t error code
|
||||
* @param[out] buf buffer where the error message should be written
|
||||
* @param buflen Size of buffer buf. At most buflen bytes are written into the buf buffer (including the terminating null byte).
|
||||
* @return buf containing the string error message
|
||||
*/
|
||||
const char *esp_err_to_name_r(esp_err_t code, char *buf, size_t buflen);
|
||||
|
||||
/** @cond */
|
||||
void _esp_error_check_failed(esp_err_t rc, const char *file, int line, const char *function, const char *expression) __attribute__((noreturn));
|
||||
|
||||
/** @cond */
|
||||
void _esp_error_check_failed_without_abort(esp_err_t rc, const char *file, int line, const char *function, const char *expression);
|
||||
|
||||
#ifndef __ASSERT_FUNC
|
||||
/* This won't happen on IDF, which defines __ASSERT_FUNC in assert.h, but it does happen when building on the host which
|
||||
uses /usr/include/assert.h or equivalent.
|
||||
*/
|
||||
#ifdef __ASSERT_FUNCTION
|
||||
#define __ASSERT_FUNC __ASSERT_FUNCTION /* used in glibc assert.h */
|
||||
#else
|
||||
#define __ASSERT_FUNC "??"
|
||||
#endif
|
||||
#endif
|
||||
/** @endcond */
|
||||
|
||||
/**
|
||||
* Macro which can be used to check the error code,
|
||||
* and terminate the program in case the code is not ESP_OK.
|
||||
* Prints the error code, error location, and the failed statement to serial output.
|
||||
*
|
||||
* Disabled if assertions are disabled.
|
||||
*/
|
||||
#ifdef NDEBUG
|
||||
#define ESP_ERROR_CHECK(x) do { \
|
||||
esp_err_t __err_rc = (x); \
|
||||
(void) sizeof(__err_rc); \
|
||||
} while(0)
|
||||
#elif defined(CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT)
|
||||
#define ESP_ERROR_CHECK(x) do { \
|
||||
esp_err_t __err_rc = (x); \
|
||||
if (__err_rc != ESP_OK) { \
|
||||
abort(); \
|
||||
} \
|
||||
} while(0)
|
||||
#else
|
||||
#define ESP_ERROR_CHECK(x) do { \
|
||||
esp_err_t __err_rc = (x); \
|
||||
if (__err_rc != ESP_OK) { \
|
||||
_esp_error_check_failed(__err_rc, __FILE__, __LINE__, \
|
||||
__ASSERT_FUNC, #x); \
|
||||
} \
|
||||
} while(0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Macro which can be used to check the error code. Prints the error code, error location, and the failed statement to
|
||||
* serial output.
|
||||
* In comparison with ESP_ERROR_CHECK(), this prints the same error message but isn't terminating the program.
|
||||
*/
|
||||
#ifdef NDEBUG
|
||||
#define ESP_ERROR_CHECK_WITHOUT_ABORT(x) ({ \
|
||||
esp_err_t __err_rc = (x); \
|
||||
__err_rc; \
|
||||
})
|
||||
#else
|
||||
#define ESP_ERROR_CHECK_WITHOUT_ABORT(x) ({ \
|
||||
esp_err_t __err_rc = (x); \
|
||||
if (__err_rc != ESP_OK) { \
|
||||
_esp_error_check_failed_without_abort(__err_rc, __FILE__, __LINE__, \
|
||||
__ASSERT_FUNC, #x); \
|
||||
} \
|
||||
__err_rc; \
|
||||
})
|
||||
#endif //NDEBUG
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,79 @@
|
||||
// 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 "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
|
||||
|
||||
/**
|
||||
* @brief Executes a 1-line expression with a application alocated stack
|
||||
* @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 expression Expression or function to be executed using the stack
|
||||
* @note if either lock, stack or stack size is invalid, the expression will
|
||||
* be called using the current stack.
|
||||
*/
|
||||
#define ESP_EXECUTE_EXPRESSION_WITH_STACK(lock, stack, stack_size, expression) \
|
||||
({ \
|
||||
assert(lock && stack && (stack_size >= CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE)); \
|
||||
uint32_t backup; \
|
||||
xSemaphoreTake(lock, portMAX_DELAY); \
|
||||
StackType_t *top_of_stack = esp_switch_stack_setup(stack, stack_size); \
|
||||
esp_switch_stack_enter(top_of_stack, &backup); \
|
||||
{ \
|
||||
expression; \
|
||||
} \
|
||||
esp_switch_stack_exit(&backup); \
|
||||
StaticTask_t *current = (StaticTask_t *)xTaskGetCurrentTaskHandle(); \
|
||||
/* pxDummy6 is the stack base of current thread defined in TCB_t */ \
|
||||
/* place the watchpoint on current task stack after function execution*/ \
|
||||
vPortSetStackWatchpoint(current->pxDummy6); \
|
||||
xSemaphoreGive(lock); \
|
||||
})
|
||||
|
||||
/**
|
||||
* @brief Fill stack frame with CPU-specifics value before use
|
||||
* @param stack Caller allocated stack pointer
|
||||
* @param stack_size Size of stack in bytes
|
||||
* @return New pointer to the top of stack
|
||||
* @note Application must not call this function directly
|
||||
*/
|
||||
StackType_t * esp_switch_stack_setup(StackType_t *stack, size_t stack_size);
|
||||
|
||||
/**
|
||||
* @brief Changes CPU sp-register to use another stack space and save the previous one
|
||||
* @param stack Caller allocated stack pointer
|
||||
* @param backup_stack Pointer to a place to save the current stack
|
||||
* @note Application must not call this function directly
|
||||
*/
|
||||
extern void esp_switch_stack_enter(StackType_t *stack, uint32_t *backup_stack);
|
||||
|
||||
/**
|
||||
* @brief Restores the previous CPU sp-register
|
||||
* @param backup_stack Pointer to the place where stack was saved
|
||||
* @note Application must not call this function directly
|
||||
*/
|
||||
extern void esp_switch_stack_exit(uint32_t *backup_stack);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
93
tools/sdk/esp32/include/esp_common/include/esp_fault.h
Normal file
93
tools/sdk/esp32/include/esp_common/include/esp_fault.h
Normal file
@ -0,0 +1,93 @@
|
||||
// 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.
|
||||
#include "sdkconfig.h"
|
||||
#include "soc/rtc_cntl_reg.h"
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Assert a condition is true, in a way that should be resistant to fault injection for
|
||||
* single fault attacks.
|
||||
*
|
||||
* - Expands CONDITION multiple times (condition must have no side effects)
|
||||
* - Compiler is told all registers are invalid before evaluating CONDITION each time, to avoid a fault
|
||||
* causing a misread of a register used in all three evaluations of CONDITION.
|
||||
* - If CONDITION is ever false, a system reset is triggered.
|
||||
*
|
||||
* @note Place this macro after a "normal" check of CONDITION that will fail with a normal error
|
||||
* message. This is the fallback in case a fault injection attack skips or corrupts the result of
|
||||
* that check. (Although ensure that an attacker can't use fault injection to skip past the "normal"
|
||||
* error message, to avoid this check entirely.)
|
||||
*
|
||||
* @note This macro increases binary size and is slow and should be used sparingly.
|
||||
*
|
||||
* @note This macro does not guarantee fault injection resistance. In particular CONDITION must be
|
||||
* chosen carefully - a fault injection attack which sets CONDITION to true will not be detected by
|
||||
* this macro. Care must also be taken that an attacker can't use a fault to completely bypass calling
|
||||
* whatever function tests ESP_FAULT_ASSERT.
|
||||
*
|
||||
* @note This is difficult to debug as a failure triggers an instant software reset, and UART output
|
||||
* is often truncated (as FIFO is not flushed). Define the ESP_FAULT_ASSERT_DEBUG macro to debug any
|
||||
* failures of this macro due to software bugs.
|
||||
*
|
||||
* @param CONDITION A condition which will evaluate true unless an attacker used fault injection to skip or corrupt some other critical system calculation.
|
||||
*
|
||||
*/
|
||||
#define ESP_FAULT_ASSERT(CONDITION) do { \
|
||||
asm volatile ("" ::: "memory"); \
|
||||
if(!(CONDITION)) _ESP_FAULT_RESET(); \
|
||||
asm volatile ("" ::: "memory"); \
|
||||
if(!(CONDITION)) _ESP_FAULT_RESET(); \
|
||||
asm volatile ("" ::: "memory"); \
|
||||
if(!(CONDITION)) _ESP_FAULT_RESET(); \
|
||||
} while(0)
|
||||
|
||||
|
||||
// Uncomment this macro to get debug output if ESP_FAULT_ASSERT() fails
|
||||
//
|
||||
// Note that uncommenting this macro reduces the anti-FI effectiveness
|
||||
//
|
||||
//#define ESP_FAULT_ASSERT_DEBUG
|
||||
|
||||
/* Internal macro, purpose is to trigger a system reset if an inconsistency due to fault injection
|
||||
is detected.
|
||||
|
||||
Illegal instruction opcodes are there as a fallback to crash the CPU in case it doesn't
|
||||
reset as expected.
|
||||
*/
|
||||
#ifndef ESP_FAULT_ASSERT_DEBUG
|
||||
|
||||
#define _ESP_FAULT_RESET() do { \
|
||||
REG_WRITE(RTC_CNTL_OPTIONS0_REG, RTC_CNTL_SW_SYS_RST); \
|
||||
asm volatile("ill; ill; ill;"); \
|
||||
} while(0)
|
||||
|
||||
#else // ESP_FAULT_ASSERT_DEBUG
|
||||
|
||||
#warning "Enabling ESP_FAULT_ASSERT_DEBUG makes ESP_FAULT_ASSERT() less effective"
|
||||
|
||||
#define _ESP_FAULT_RESET() do { \
|
||||
ets_printf("ESP_FAULT_ASSERT %s:%d\n", __FILE__, __LINE__); \
|
||||
asm volatile("ill;"); \
|
||||
} while(0)
|
||||
|
||||
#endif // ESP_FAULT_ASSERT_DEBUG
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
131
tools/sdk/esp32/include/esp_common/include/esp_freertos_hooks.h
Normal file
131
tools/sdk/esp32/include/esp_common/include/esp_freertos_hooks.h
Normal file
@ -0,0 +1,131 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_FREERTOS_HOOKS_H__
|
||||
#define __ESP_FREERTOS_HOOKS_H__
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*
|
||||
Definitions for the tickhook and idlehook callbacks
|
||||
*/
|
||||
typedef bool (*esp_freertos_idle_cb_t)(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
|
58
tools/sdk/esp32/include/esp_common/include/esp_idf_version.h
Normal file
58
tools/sdk/esp32/include/esp_common/include/esp_idf_version.h
Normal file
@ -0,0 +1,58 @@
|
||||
// Copyright 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
|
||||
|
||||
/** Major version number (X.x.x) */
|
||||
#define ESP_IDF_VERSION_MAJOR 4
|
||||
/** Minor version number (x.X.x) */
|
||||
#define ESP_IDF_VERSION_MINOR 2
|
||||
/** Patch version number (x.x.X) */
|
||||
#define ESP_IDF_VERSION_PATCH 0
|
||||
|
||||
/**
|
||||
* Macro to convert IDF version number into an integer
|
||||
*
|
||||
* To be used in comparisons, such as ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0)
|
||||
*/
|
||||
#define ESP_IDF_VERSION_VAL(major, minor, patch) ((major << 16) | (minor << 8) | (patch))
|
||||
|
||||
/**
|
||||
* Current IDF version, as an integer
|
||||
*
|
||||
* To be used in comparisons, such as ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0)
|
||||
*/
|
||||
#define ESP_IDF_VERSION ESP_IDF_VERSION_VAL(ESP_IDF_VERSION_MAJOR, \
|
||||
ESP_IDF_VERSION_MINOR, \
|
||||
ESP_IDF_VERSION_PATCH)
|
||||
|
||||
/**
|
||||
* Return full IDF version string, same as 'git describe' output.
|
||||
*
|
||||
* @note If you are printing the ESP-IDF version in a log file or other information,
|
||||
* this function provides more information than using the numerical version macros.
|
||||
* For example, numerical version macros don't differentiate between development,
|
||||
* pre-release and release versions, but the output of this function does.
|
||||
*
|
||||
* @return constant string from IDF_VER
|
||||
*/
|
||||
const char* esp_get_idf_version(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
67
tools/sdk/esp32/include/esp_common/include/esp_int_wdt.h
Normal file
67
tools/sdk/esp32/include/esp_common/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
|
37
tools/sdk/esp32/include/esp_common/include/esp_interface.h
Normal file
37
tools/sdk/esp32/include/esp_common/include/esp_interface.h
Normal file
@ -0,0 +1,37 @@
|
||||
// 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_INTERFACE_H__
|
||||
#define __ESP_INTERFACE_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef enum {
|
||||
ESP_IF_WIFI_STA = 0, /**< ESP32 station interface */
|
||||
ESP_IF_WIFI_AP, /**< ESP32 soft-AP interface */
|
||||
ESP_IF_ETH, /**< ESP32 ethernet interface */
|
||||
ESP_IF_MAX
|
||||
} esp_interface_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __ESP_INTERFACE_TYPES_H__ */
|
93
tools/sdk/esp32/include/esp_common/include/esp_ipc.h
Normal file
93
tools/sdk/esp32/include/esp_common/include/esp_ipc.h
Normal file
@ -0,0 +1,93 @@
|
||||
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_IPC_H__
|
||||
#define __ESP_IPC_H__
|
||||
|
||||
#include <esp_err.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
/** @cond */
|
||||
typedef void (*esp_ipc_func_t)(void* arg);
|
||||
/** @endcond */
|
||||
/*
|
||||
* Inter-processor call APIs
|
||||
*
|
||||
* FreeRTOS provides several APIs which can be used to communicate between
|
||||
* different tasks, including tasks running on different CPUs.
|
||||
* This module provides additional APIs to run some code on the other CPU.
|
||||
*
|
||||
* These APIs can only be used when FreeRTOS scheduler is running.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Execute a function on the given CPU
|
||||
*
|
||||
* Run a given function on a particular CPU. The given function must accept a
|
||||
* void* argument and return void. The given function is run in the context of
|
||||
* the IPC task of the CPU specified by the cpu_id parameter. The calling task
|
||||
* will be blocked until the IPC task begins executing the given function. If
|
||||
* another IPC call is ongoing, the calling task will block until the other IPC
|
||||
* call completes. The stack size allocated for the IPC task can be configured
|
||||
* in the "Inter-Processor Call (IPC) task stack size" setting in menuconfig.
|
||||
* Increase this setting if the given function requires more stack than default.
|
||||
*
|
||||
* @note In single-core mode, returns ESP_ERR_INVALID_ARG for cpu_id 1.
|
||||
*
|
||||
* @param[in] cpu_id CPU where the given function should be executed (0 or 1)
|
||||
* @param[in] func Pointer to a function of type void func(void* arg) to be executed
|
||||
* @param[in] arg Arbitrary argument of type void* to be passed into the function
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if cpu_id is invalid
|
||||
* - ESP_ERR_INVALID_STATE if the FreeRTOS scheduler is not running
|
||||
* - ESP_OK otherwise
|
||||
*/
|
||||
esp_err_t esp_ipc_call(uint32_t cpu_id, esp_ipc_func_t func, void* arg);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Execute a function on the given CPU and blocks until it completes
|
||||
*
|
||||
* Run a given function on a particular CPU. The given function must accept a
|
||||
* void* argument and return void. The given function is run in the context of
|
||||
* the IPC task of the CPU specified by the cpu_id parameter. The calling task
|
||||
* will be blocked until the IPC task completes execution of the given function.
|
||||
* If another IPC call is ongoing, the calling task will block until the other
|
||||
* IPC call completes. The stack size allocated for the IPC task can be
|
||||
* configured in the "Inter-Processor Call (IPC) task stack size" setting in
|
||||
* menuconfig. Increase this setting if the given function requires more stack
|
||||
* than default.
|
||||
*
|
||||
* @note In single-core mode, returns ESP_ERR_INVALID_ARG for cpu_id 1.
|
||||
*
|
||||
* @param[in] cpu_id CPU where the given function should be executed (0 or 1)
|
||||
* @param[in] func Pointer to a function of type void func(void* arg) to be executed
|
||||
* @param[in] arg Arbitrary argument of type void* to be passed into the function
|
||||
*
|
||||
* @return
|
||||
* - ESP_ERR_INVALID_ARG if cpu_id is invalid
|
||||
* - ESP_ERR_INVALID_STATE if the FreeRTOS scheduler is not running
|
||||
* - ESP_OK otherwise
|
||||
*/
|
||||
esp_err_t esp_ipc_call_blocking(uint32_t cpu_id, esp_ipc_func_t func, void* arg);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_IPC_H__ */
|
182
tools/sdk/esp32/include/esp_common/include/esp_pm.h
Normal file
182
tools/sdk/esp32/include/esp_common/include/esp_pm.h
Normal file
@ -0,0 +1,182 @@
|
||||
// Copyright 2016-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 <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "sdkconfig.h"
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#include "esp32/pm.h"
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||
#include "esp32s2/pm.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Power management constraints
|
||||
*/
|
||||
typedef enum {
|
||||
/**
|
||||
* Require CPU frequency to be at the maximum value set via esp_pm_configure.
|
||||
* Argument is unused and should be set to 0.
|
||||
*/
|
||||
ESP_PM_CPU_FREQ_MAX,
|
||||
/**
|
||||
* Require APB frequency to be at the maximum value supported by the chip.
|
||||
* Argument is unused and should be set to 0.
|
||||
*/
|
||||
ESP_PM_APB_FREQ_MAX,
|
||||
/**
|
||||
* Prevent the system from going into light sleep.
|
||||
* Argument is unused and should be set to 0.
|
||||
*/
|
||||
ESP_PM_NO_LIGHT_SLEEP,
|
||||
} esp_pm_lock_type_t;
|
||||
|
||||
/**
|
||||
* @brief Set implementation-specific power management configuration
|
||||
* @param config pointer to implementation-specific configuration structure (e.g. esp_pm_config_esp32)
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if the configuration values are not correct
|
||||
* - ESP_ERR_NOT_SUPPORTED if certain combination of values is not supported,
|
||||
* or if CONFIG_PM_ENABLE is not enabled in sdkconfig
|
||||
*/
|
||||
esp_err_t esp_pm_configure(const void* config);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Opaque handle to the power management lock
|
||||
*/
|
||||
typedef struct esp_pm_lock* esp_pm_lock_handle_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Initialize a lock handle for certain power management parameter
|
||||
*
|
||||
* When lock is created, initially it is not taken.
|
||||
* Call esp_pm_lock_acquire to take the lock.
|
||||
*
|
||||
* This function must not be called from an ISR.
|
||||
*
|
||||
* @param lock_type Power management constraint which the lock should control
|
||||
* @param arg argument, value depends on lock_type, see esp_pm_lock_type_t
|
||||
* @param name arbitrary string identifying the lock (e.g. "wifi" or "spi").
|
||||
* Used by the esp_pm_dump_locks function to list existing locks.
|
||||
* May be set to NULL. If not set to NULL, must point to a string which is valid
|
||||
* for the lifetime of the lock.
|
||||
* @param[out] out_handle handle returned from this function. Use this handle when calling
|
||||
* esp_pm_lock_delete, esp_pm_lock_acquire, esp_pm_lock_release.
|
||||
* Must not be NULL.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NO_MEM if the lock structure can not be allocated
|
||||
* - ESP_ERR_INVALID_ARG if out_handle is NULL or type argument is not valid
|
||||
* - ESP_ERR_NOT_SUPPORTED if CONFIG_PM_ENABLE is not enabled in sdkconfig
|
||||
*/
|
||||
esp_err_t esp_pm_lock_create(esp_pm_lock_type_t lock_type, int arg,
|
||||
const char* name, esp_pm_lock_handle_t* out_handle);
|
||||
|
||||
/**
|
||||
* @brief Take a power management lock
|
||||
*
|
||||
* Once the lock is taken, power management algorithm will not switch to the
|
||||
* mode specified in a call to esp_pm_lock_create, or any of the lower power
|
||||
* modes (higher numeric values of 'mode').
|
||||
*
|
||||
* The lock is recursive, in the sense that if esp_pm_lock_acquire is called
|
||||
* a number of times, esp_pm_lock_release has to be called the same number of
|
||||
* times in order to release the lock.
|
||||
*
|
||||
* This function may be called from an ISR.
|
||||
*
|
||||
* This function is not thread-safe w.r.t. calls to other esp_pm_lock_*
|
||||
* functions for the same handle.
|
||||
*
|
||||
* @param handle handle obtained from esp_pm_lock_create function
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if the handle is invalid
|
||||
* - ESP_ERR_NOT_SUPPORTED if CONFIG_PM_ENABLE is not enabled in sdkconfig
|
||||
*/
|
||||
esp_err_t esp_pm_lock_acquire(esp_pm_lock_handle_t handle);
|
||||
|
||||
/**
|
||||
* @brief Release the lock taken using esp_pm_lock_acquire.
|
||||
*
|
||||
* Call to this functions removes power management restrictions placed when
|
||||
* taking the lock.
|
||||
*
|
||||
* Locks are recursive, so if esp_pm_lock_acquire is called a number of times,
|
||||
* esp_pm_lock_release has to be called the same number of times in order to
|
||||
* actually release the lock.
|
||||
*
|
||||
* This function may be called from an ISR.
|
||||
*
|
||||
* This function is not thread-safe w.r.t. calls to other esp_pm_lock_*
|
||||
* functions for the same handle.
|
||||
*
|
||||
* @param handle handle obtained from esp_pm_lock_create function
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if the handle is invalid
|
||||
* - ESP_ERR_INVALID_STATE if lock is not acquired
|
||||
* - ESP_ERR_NOT_SUPPORTED if CONFIG_PM_ENABLE is not enabled in sdkconfig
|
||||
*/
|
||||
esp_err_t esp_pm_lock_release(esp_pm_lock_handle_t handle);
|
||||
|
||||
/**
|
||||
* @brief Delete a lock created using esp_pm_lock
|
||||
*
|
||||
* The lock must be released before calling this function.
|
||||
*
|
||||
* This function must not be called from an ISR.
|
||||
*
|
||||
* @param handle handle obtained from esp_pm_lock_create function
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if the handle argument is NULL
|
||||
* - ESP_ERR_INVALID_STATE if the lock is still acquired
|
||||
* - ESP_ERR_NOT_SUPPORTED if CONFIG_PM_ENABLE is not enabled in sdkconfig
|
||||
*/
|
||||
esp_err_t esp_pm_lock_delete(esp_pm_lock_handle_t handle);
|
||||
|
||||
/**
|
||||
* Dump the list of all locks to stderr
|
||||
*
|
||||
* This function dumps debugging information about locks created using
|
||||
* esp_pm_lock_create to an output stream.
|
||||
*
|
||||
* This function must not be called from an ISR. If esp_pm_lock_acquire/release
|
||||
* are called while this function is running, inconsistent results may be
|
||||
* reported.
|
||||
*
|
||||
* @param stream stream to print information to; use stdout or stderr to print
|
||||
* to the console; use fmemopen/open_memstream to print to a
|
||||
* string buffer.
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NOT_SUPPORTED if CONFIG_PM_ENABLE is not enabled in sdkconfig
|
||||
*/
|
||||
esp_err_t esp_pm_dump_locks(FILE* stream);
|
||||
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -0,0 +1,64 @@
|
||||
// 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
|
||||
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
#endif
|
@ -0,0 +1,50 @@
|
||||
// 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_
|
||||
|
||||
#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);
|
||||
|
||||
#endif //ESP_DBG_STUBS_H_
|
@ -0,0 +1,22 @@
|
||||
// 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 GDBSTUB_H
|
||||
#define GDBSTUB_H
|
||||
|
||||
#include <xtensa/config/core.h>
|
||||
#include "freertos/xtensa_api.h"
|
||||
|
||||
void esp_gdbstub_panic_handler(XtExcFrame *frame) __attribute__((noreturn));
|
||||
|
||||
#endif
|
121
tools/sdk/esp32/include/esp_common/include/esp_private/pm_impl.h
Normal file
121
tools/sdk/esp32/include/esp_common/include/esp_private/pm_impl.h
Normal file
@ -0,0 +1,121 @@
|
||||
// Copyright 2016-2017 Espressif Systems (Shanghai) PTE LTD
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file esp_private/pm_impl.h
|
||||
*
|
||||
* This header file defines interface between PM lock functions (pm_locks.c)
|
||||
* and the chip-specific power management (DFS/light sleep) implementation.
|
||||
*/
|
||||
|
||||
#include "soc/rtc.h"
|
||||
#include "esp_pm.h"
|
||||
#include "esp_timer.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
|
||||
/**
|
||||
* This is an enum of possible power modes supported by the implementation
|
||||
*/
|
||||
typedef enum {
|
||||
PM_MODE_LIGHT_SLEEP,//!< Light sleep
|
||||
PM_MODE_APB_MIN, //!< Idle (no CPU frequency or APB frequency locks)
|
||||
PM_MODE_APB_MAX, //!< Maximum APB frequency mode
|
||||
PM_MODE_CPU_MAX, //!< Maximum CPU frequency mode
|
||||
PM_MODE_COUNT //!< Number of items
|
||||
} pm_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Get the mode corresponding to a certain lock
|
||||
* @param type lock type
|
||||
* @param arg argument value for this lock (passed to esp_pm_lock_create)
|
||||
* @return lowest power consumption mode which meets the constraints of the lock
|
||||
*/
|
||||
pm_mode_t esp_pm_impl_get_mode(esp_pm_lock_type_t type, int arg);
|
||||
|
||||
/**
|
||||
* If profiling is enabled, this data type will be used to store microsecond
|
||||
* timestamps.
|
||||
*/
|
||||
typedef int64_t pm_time_t;
|
||||
|
||||
/**
|
||||
* See \ref esp_pm_impl_switch_mode
|
||||
*/
|
||||
typedef enum {
|
||||
MODE_LOCK,
|
||||
MODE_UNLOCK
|
||||
} pm_mode_switch_t;
|
||||
|
||||
/**
|
||||
* @brief Switch between power modes when lock is taken or released
|
||||
* @param mode pm_mode_t corresponding to the lock being taken or released,
|
||||
* as returned by \ref esp_pm_impl_get_mode
|
||||
* @param lock_or_unlock
|
||||
* - MODE_LOCK: lock was taken. Implementation needs to make sure
|
||||
* that the constraints of the lock are met by switching to the
|
||||
* given 'mode' or any of the higher power ones.
|
||||
* - MODE_UNLOCK: lock was released. If all the locks for given
|
||||
* mode are released, and no locks for higher power modes are
|
||||
* taken, implementation can switch to one of lower power modes.
|
||||
* @param now timestamp when the lock was taken or released. Passed as
|
||||
* a minor optimization, so that the implementation does not need to
|
||||
* call pm_get_time again.
|
||||
*/
|
||||
void esp_pm_impl_switch_mode(pm_mode_t mode, pm_mode_switch_t lock_or_unlock, pm_time_t now);
|
||||
|
||||
/**
|
||||
* @brief Call once at startup to initialize pm implementation
|
||||
*/
|
||||
void esp_pm_impl_init(void);
|
||||
|
||||
/**
|
||||
* @brief Hook function for the idle task
|
||||
* Must be called from the IDLE task on each CPU before entering waiti state.
|
||||
*/
|
||||
void esp_pm_impl_idle_hook(void);
|
||||
|
||||
/**
|
||||
* @brief Hook function for the interrupt dispatcher
|
||||
* Must be called soon after entering the ISR
|
||||
*/
|
||||
void esp_pm_impl_isr_hook(void);
|
||||
|
||||
/**
|
||||
* @brief Dump the information about time spent in each of the pm modes.
|
||||
*
|
||||
* Prints three columns:
|
||||
* mode name, total time in mode (in microseconds), percentage of time in mode
|
||||
*
|
||||
* @param out stream to dump the information to
|
||||
*/
|
||||
void esp_pm_impl_dump_stats(FILE* out);
|
||||
|
||||
/**
|
||||
* @brief Hook function implementing `waiti` instruction, should be invoked from idle task context
|
||||
*/
|
||||
void esp_pm_impl_waiti(void);
|
||||
|
||||
#ifdef CONFIG_PM_PROFILING
|
||||
#define WITH_PROFILING
|
||||
#endif
|
||||
|
||||
#ifdef WITH_PROFILING
|
||||
static inline pm_time_t IRAM_ATTR pm_get_time(void)
|
||||
{
|
||||
return esp_timer_get_time();
|
||||
}
|
||||
#endif // WITH_PROFILING
|
@ -0,0 +1,45 @@
|
||||
// Copyright 2016-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 "sdkconfig.h"
|
||||
|
||||
typedef enum {
|
||||
ESP_PM_TRACE_IDLE,
|
||||
ESP_PM_TRACE_TICK,
|
||||
ESP_PM_TRACE_FREQ_SWITCH,
|
||||
ESP_PM_TRACE_CCOMPARE_UPDATE,
|
||||
ESP_PM_TRACE_ISR_HOOK,
|
||||
ESP_PM_TRACE_SLEEP,
|
||||
ESP_PM_TRACE_TYPE_MAX
|
||||
} esp_pm_trace_event_t;
|
||||
|
||||
void esp_pm_trace_init(void);
|
||||
void esp_pm_trace_enter(esp_pm_trace_event_t event, int core_id);
|
||||
void esp_pm_trace_exit(esp_pm_trace_event_t event, int core_id);
|
||||
|
||||
#ifdef CONFIG_PM_TRACE
|
||||
|
||||
#define ESP_PM_TRACE_ENTER(event, core_id) \
|
||||
esp_pm_trace_enter(ESP_PM_TRACE_ ## event, core_id)
|
||||
#define ESP_PM_TRACE_EXIT(event, core_id) \
|
||||
esp_pm_trace_exit(ESP_PM_TRACE_ ## event, core_id)
|
||||
|
||||
#else // CONFIG_PM_TRACE
|
||||
|
||||
#define ESP_PM_TRACE_ENTER(type, core_id) do { (void) core_id; } while(0)
|
||||
#define ESP_PM_TRACE_EXIT(type, core_id) do { (void) core_id; } while(0)
|
||||
|
||||
#endif // CONFIG_PM_TRACE
|
@ -0,0 +1,66 @@
|
||||
// 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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
58
tools/sdk/esp32/include/esp_common/include/esp_task.h
Normal file
58
tools/sdk/esp32/include/esp_common/include/esp_task.h
Normal file
@ -0,0 +1,58 @@
|
||||
// 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/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)
|
||||
|
||||
#endif
|
147
tools/sdk/esp32/include/esp_common/include/esp_task_wdt.h
Normal file
147
tools/sdk/esp32/include/esp_common/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
|
25
tools/sdk/esp32/include/esp_common/include/esp_types.h
Normal file
25
tools/sdk/esp32/include/esp_common/include/esp_types.h
Normal file
@ -0,0 +1,25 @@
|
||||
// Copyright 2010-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_TYPES_H__
|
||||
#define __ESP_TYPES_H__
|
||||
|
||||
#ifdef __GNUC__
|
||||
#include <sys/cdefs.h>
|
||||
#endif /*__GNUC__*/
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#endif /* __ESP_TYPES_H__ */
|
Reference in New Issue
Block a user