mirror of
https://github.com/0xFEEDC0DE64/arduino-esp32.git
synced 2025-07-04 22:36:32 +02:00
IDF release/v4.0 08219f3cf
This commit is contained in:
37
tools/sdk/include/esp_common/esp_assert.h
Normal file
37
tools/sdk/include/esp_common/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__ */
|
57
tools/sdk/include/esp_common/esp_bit_defs.h
Normal file
57
tools/sdk/include/esp_common/esp_bit_defs.h
Normal file
@ -0,0 +1,57 @@
|
||||
// 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__
|
||||
#define BIT(nr) (1UL << (nr))
|
||||
#define BIT64(nr) (1ULL << (nr))
|
||||
#else
|
||||
#define BIT(nr) (1 << (nr))
|
||||
#endif
|
149
tools/sdk/include/esp_common/esp_err.h
Normal file
149
tools/sdk/include/esp_common/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
|
131
tools/sdk/include/esp_common/esp_freertos_hooks.h
Normal file
131
tools/sdk/include/esp_common/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)();
|
||||
typedef void (*esp_freertos_tick_cb_t)();
|
||||
|
||||
/**
|
||||
* @brief Register a callback to be called from the specified core's idle hook.
|
||||
* The callback should return true if it should be called by the idle hook
|
||||
* once per interrupt (or FreeRTOS tick), and return false if it should
|
||||
* be called repeatedly as fast as possible by the idle hook.
|
||||
*
|
||||
* @warning Idle callbacks MUST NOT, UNDER ANY CIRCUMSTANCES, CALL
|
||||
* A FUNCTION THAT MIGHT BLOCK.
|
||||
*
|
||||
* @param[in] new_idle_cb Callback to be called
|
||||
* @param[in] cpuid id of the core
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Callback registered to the specified core's idle hook
|
||||
* - ESP_ERR_NO_MEM: No more space on the specified core's idle hook to register callback
|
||||
* - ESP_ERR_INVALID_ARG: cpuid is invalid
|
||||
*/
|
||||
esp_err_t esp_register_freertos_idle_hook_for_cpu(esp_freertos_idle_cb_t new_idle_cb, UBaseType_t cpuid);
|
||||
|
||||
/**
|
||||
* @brief Register a callback to the idle hook of the core that calls this function.
|
||||
* The callback should return true if it should be called by the idle hook
|
||||
* once per interrupt (or FreeRTOS tick), and return false if it should
|
||||
* be called repeatedly as fast as possible by the idle hook.
|
||||
*
|
||||
* @warning Idle callbacks MUST NOT, UNDER ANY CIRCUMSTANCES, CALL
|
||||
* A FUNCTION THAT MIGHT BLOCK.
|
||||
*
|
||||
* @param[in] new_idle_cb Callback to be called
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Callback registered to the calling core's idle hook
|
||||
* - ESP_ERR_NO_MEM: No more space on the calling core's idle hook to register callback
|
||||
*/
|
||||
esp_err_t esp_register_freertos_idle_hook(esp_freertos_idle_cb_t new_idle_cb);
|
||||
|
||||
/**
|
||||
* @brief Register a callback to be called from the specified core's tick hook.
|
||||
*
|
||||
* @param[in] new_tick_cb Callback to be called
|
||||
* @param[in] cpuid id of the core
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Callback registered to specified core's tick hook
|
||||
* - ESP_ERR_NO_MEM: No more space on the specified core's tick hook to register the callback
|
||||
* - ESP_ERR_INVALID_ARG: cpuid is invalid
|
||||
*/
|
||||
esp_err_t esp_register_freertos_tick_hook_for_cpu(esp_freertos_tick_cb_t new_tick_cb, UBaseType_t cpuid);
|
||||
|
||||
/**
|
||||
* @brief Register a callback to be called from the calling core's tick hook.
|
||||
*
|
||||
* @param[in] new_tick_cb Callback to be called
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: Callback registered to the calling core's tick hook
|
||||
* - ESP_ERR_NO_MEM: No more space on the calling core's tick hook to register the callback
|
||||
*/
|
||||
esp_err_t esp_register_freertos_tick_hook(esp_freertos_tick_cb_t new_tick_cb);
|
||||
|
||||
/**
|
||||
* @brief Unregister an idle callback from the idle hook of the specified core
|
||||
*
|
||||
* @param[in] old_idle_cb Callback to be unregistered
|
||||
* @param[in] cpuid id of the core
|
||||
*/
|
||||
void esp_deregister_freertos_idle_hook_for_cpu(esp_freertos_idle_cb_t old_idle_cb, UBaseType_t cpuid);
|
||||
|
||||
/**
|
||||
* @brief Unregister an idle callback. If the idle callback is registered to
|
||||
* the idle hooks of both cores, the idle hook will be unregistered from
|
||||
* both cores
|
||||
*
|
||||
* @param[in] old_idle_cb Callback to be unregistered
|
||||
*/
|
||||
void esp_deregister_freertos_idle_hook(esp_freertos_idle_cb_t old_idle_cb);
|
||||
|
||||
/**
|
||||
* @brief Unregister a tick callback from the tick hook of the specified core
|
||||
*
|
||||
* @param[in] old_tick_cb Callback to be unregistered
|
||||
* @param[in] cpuid id of the core
|
||||
*/
|
||||
void esp_deregister_freertos_tick_hook_for_cpu(esp_freertos_tick_cb_t old_tick_cb, UBaseType_t cpuid);
|
||||
|
||||
/**
|
||||
* @brief Unregister a tick callback. If the tick callback is registered to the
|
||||
* tick hooks of both cores, the tick hook will be unregistered from
|
||||
* both cores
|
||||
*
|
||||
* @param[in] old_tick_cb Callback to be unregistered
|
||||
*/
|
||||
void esp_deregister_freertos_tick_hook(esp_freertos_tick_cb_t old_tick_cb);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
58
tools/sdk/include/esp_common/esp_idf_version.h
Normal file
58
tools/sdk/include/esp_common/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 0
|
||||
/** 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/include/esp_common/esp_int_wdt.h
Normal file
67
tools/sdk/include/esp_common/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();
|
||||
|
||||
/**
|
||||
* @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();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
37
tools/sdk/include/esp_common/esp_interface.h
Normal file
37
tools/sdk/include/esp_common/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/include/esp_common/esp_ipc.h
Normal file
93
tools/sdk/include/esp_common/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__ */
|
179
tools/sdk/include/esp_common/esp_pm.h
Normal file
179
tools/sdk/include/esp_common/esp_pm.h
Normal file
@ -0,0 +1,179 @@
|
||||
// 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 SoC-specific definitions. Only ESP32 supported for now.
|
||||
#include "esp32/pm.h"
|
||||
|
||||
#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
|
54
tools/sdk/include/esp_common/esp_private/crosscore_int.h
Normal file
54
tools/sdk/include/esp_common/esp_private/crosscore_int.h
Normal file
@ -0,0 +1,54 @@
|
||||
// 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();
|
||||
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
#endif
|
50
tools/sdk/include/esp_common/esp_private/dbg_stubs.h
Normal file
50
tools/sdk/include/esp_common/esp_private/dbg_stubs.h
Normal file
@ -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_
|
101
tools/sdk/include/esp_common/esp_private/esp_timer_impl.h
Normal file
101
tools/sdk/include/esp_common/esp_private/esp_timer_impl.h
Normal file
@ -0,0 +1,101 @@
|
||||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file esp_private/esp_timer_impl.h
|
||||
*
|
||||
* @brief Interface between common and platform-specific parts of esp_timer.
|
||||
*
|
||||
* The functions in this header file are implemented for each supported SoC.
|
||||
* High level functions defined in esp_timer.c call the functions here to
|
||||
* interact with the hardware.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "esp_err.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize platform specific layer of esp_timer
|
||||
* @param alarm_handler function to call on timer interrupt
|
||||
* @return ESP_OK, ESP_ERR_NO_MEM, or one of the errors from interrupt allocator
|
||||
*/
|
||||
esp_err_t esp_timer_impl_init(intr_handler_t alarm_handler);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize platform specific layer of esp_timer
|
||||
*/
|
||||
void esp_timer_impl_deinit();
|
||||
|
||||
/**
|
||||
* @brief Set up the timer interrupt to fire at a particular time
|
||||
*
|
||||
* If the alarm time is too close in the future, implementation should set the
|
||||
* alarm to the earliest time possible.
|
||||
*
|
||||
* @param timestamp time in microseconds when interrupt should fire (relative to
|
||||
* boot time, i.e. as returned by esp_timer_impl_get_time)
|
||||
*/
|
||||
void esp_timer_impl_set_alarm(uint64_t timestamp);
|
||||
|
||||
/**
|
||||
* @brief Notify esp_timer implementation that APB frequency has changed
|
||||
*
|
||||
* Called by the frequency switching code.
|
||||
*
|
||||
* @param apb_ticks_per_us new number of APB clock ticks per microsecond
|
||||
*/
|
||||
void esp_timer_impl_update_apb_freq(uint32_t apb_ticks_per_us);
|
||||
|
||||
/**
|
||||
* @brief Adjust current esp_timer time by a certain value
|
||||
*
|
||||
* Called from light sleep code to synchronize esp_timer time with RTC time.
|
||||
*
|
||||
* @param time_us adjustment to apply to esp_timer time, in microseconds
|
||||
*/
|
||||
void esp_timer_impl_advance(int64_t time_us);
|
||||
|
||||
/**
|
||||
* @brief Get time, in microseconds, since esp_timer_impl_init was called
|
||||
* @return timestamp in microseconds
|
||||
*/
|
||||
uint64_t esp_timer_impl_get_time();
|
||||
|
||||
/**
|
||||
* @brief Get minimal timer period, in microseconds
|
||||
* Periods shorter than the one returned may not be possible to achieve due to
|
||||
* interrupt latency and context switch time. Short period of periodic timer may
|
||||
* cause the system to spend all the time servicing the interrupt and timer
|
||||
* callback, preventing other tasks from running.
|
||||
* @return minimal period of periodic timer, in microseconds
|
||||
*/
|
||||
uint64_t esp_timer_impl_get_min_period_us();
|
||||
|
||||
/**
|
||||
* @brief obtain internal critical section used esp_timer implementation
|
||||
* This can be used when a sequence of calls to esp_timer has to be made,
|
||||
* and it is necessary that the state of the timer is consistent between
|
||||
* the calls. Should be treated in the same way as a spinlock.
|
||||
* Call esp_timer_impl_unlock to release the lock
|
||||
*/
|
||||
void esp_timer_impl_lock();
|
||||
|
||||
|
||||
/**
|
||||
* @brief counterpart of esp_timer_impl_lock
|
||||
*/
|
||||
void esp_timer_impl_unlock();
|
22
tools/sdk/include/esp_common/esp_private/gdbstub.h
Normal file
22
tools/sdk/include/esp_common/esp_private/gdbstub.h
Normal file
@ -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/include/esp_common/esp_private/pm_impl.h
Normal file
121
tools/sdk/include/esp_common/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();
|
||||
|
||||
/**
|
||||
* @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();
|
||||
|
||||
/**
|
||||
* @brief Hook function for the interrupt dispatcher
|
||||
* Must be called soon after entering the ISR
|
||||
*/
|
||||
void esp_pm_impl_isr_hook();
|
||||
|
||||
/**
|
||||
* @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();
|
||||
|
||||
#ifdef CONFIG_PM_PROFILING
|
||||
#define WITH_PROFILING
|
||||
#endif
|
||||
|
||||
#ifdef WITH_PROFILING
|
||||
static inline pm_time_t IRAM_ATTR pm_get_time()
|
||||
{
|
||||
return esp_timer_get_time();
|
||||
}
|
||||
#endif // WITH_PROFILING
|
45
tools/sdk/include/esp_common/esp_private/pm_trace.h
Normal file
45
tools/sdk/include/esp_common/esp_private/pm_trace.h
Normal file
@ -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 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
|
56
tools/sdk/include/esp_common/esp_private/system_internal.h
Normal file
56
tools/sdk/include/esp_common/esp_private/system_internal.h
Normal file
@ -0,0 +1,56 @@
|
||||
// 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"
|
||||
|
||||
/**
|
||||
* @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() __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
|
264
tools/sdk/include/esp_common/esp_system.h
Normal file
264
tools/sdk/include/esp_common/esp_system.h
Normal file
@ -0,0 +1,264 @@
|
||||
// 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
|
||||
#define UNIVERSAL_MAC_ADDR_NUM CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES
|
||||
/** @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 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.
|
||||
*
|
||||
* @param mac base MAC address, length: 6 bytes.
|
||||
*
|
||||
* @return ESP_OK on success
|
||||
*/
|
||||
esp_err_t esp_base_mac_addr_set(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 Chip models
|
||||
*/
|
||||
typedef enum {
|
||||
CHIP_ESP32 = 1, //!< ESP32
|
||||
} 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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ESP_SYSTEM_H__ */
|
58
tools/sdk/include/esp_common/esp_task.h
Normal file
58
tools/sdk/include/esp_common/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
|
146
tools/sdk/include/esp_common/esp_task_wdt.h
Normal file
146
tools/sdk/include/esp_common/esp_task_wdt.h
Normal file
@ -0,0 +1,146 @@
|
||||
// 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();
|
||||
|
||||
/**
|
||||
* @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();
|
||||
|
||||
/**
|
||||
* @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
|
233
tools/sdk/include/esp_common/esp_timer.h
Normal file
233
tools/sdk/include/esp_common/esp_timer.h
Normal file
@ -0,0 +1,233 @@
|
||||
// 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.
|
||||
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @file esp_timer.h
|
||||
* @brief microsecond-precision 64-bit timer API, replacement for ets_timer
|
||||
*
|
||||
* esp_timer APIs allow components to receive callbacks when a hardware timer
|
||||
* reaches certain value. The timer provides microsecond accuracy and
|
||||
* up to 64 bit range. Note that while the timer itself provides microsecond
|
||||
* accuracy, callbacks are dispatched from an auxiliary task. Some time is
|
||||
* needed to notify this task from timer ISR, and then to invoke the callback.
|
||||
* If more than one callback needs to be dispatched at any particular time,
|
||||
* each subsequent callback will be dispatched only when the previous callback
|
||||
* returns. Therefore, callbacks should not do much work; instead, they should
|
||||
* use RTOS notification mechanisms (queues, semaphores, event groups, etc.) to
|
||||
* pass information to other tasks.
|
||||
*
|
||||
* To be implemented: it should be possible to request the callback to be called
|
||||
* directly from the ISR. This reduces the latency, but has potential impact on
|
||||
* all other callbacks which need to be dispatched. This option should only be
|
||||
* used for simple callback functions, which do not take longer than a few
|
||||
* microseconds to run.
|
||||
*
|
||||
* Implementation note: on the ESP32, esp_timer APIs use the "legacy" FRC2
|
||||
* timer. Timer callbacks are called from a task running on the PRO CPU.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include "esp_err.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Opaque type representing a single esp_timer
|
||||
*/
|
||||
typedef struct esp_timer* esp_timer_handle_t;
|
||||
|
||||
/**
|
||||
* @brief Timer callback function type
|
||||
* @param arg pointer to opaque user-specific data
|
||||
*/
|
||||
typedef void (*esp_timer_cb_t)(void* arg);
|
||||
|
||||
|
||||
/**
|
||||
* @brief Method for dispatching timer callback
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_TIMER_TASK, //!< Callback is called from timer task
|
||||
|
||||
/* Not supported for now, provision to allow callbacks to run directly
|
||||
* from an ISR:
|
||||
|
||||
ESP_TIMER_ISR, //!< Callback is called from timer ISR
|
||||
|
||||
*/
|
||||
} esp_timer_dispatch_t;
|
||||
|
||||
/**
|
||||
* @brief Timer configuration passed to esp_timer_create
|
||||
*/
|
||||
typedef struct {
|
||||
esp_timer_cb_t callback; //!< Function to call when timer expires
|
||||
void* arg; //!< Argument to pass to the callback
|
||||
esp_timer_dispatch_t dispatch_method; //!< Call the callback from task or from ISR
|
||||
const char* name; //!< Timer name, used in esp_timer_dump function
|
||||
} esp_timer_create_args_t;
|
||||
|
||||
/**
|
||||
* @brief Initialize esp_timer library
|
||||
*
|
||||
* @note This function is called from startup code. Applications do not need
|
||||
* to call this function before using other esp_timer APIs.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NO_MEM if allocation has failed
|
||||
* - ESP_ERR_INVALID_STATE if already initialized
|
||||
* - other errors from interrupt allocator
|
||||
*/
|
||||
esp_err_t esp_timer_init();
|
||||
|
||||
/**
|
||||
* @brief De-initialize esp_timer library
|
||||
*
|
||||
* @note Normally this function should not be called from applications
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE if not yet initialized
|
||||
*/
|
||||
esp_err_t esp_timer_deinit();
|
||||
|
||||
/**
|
||||
* @brief Create an esp_timer instance
|
||||
*
|
||||
* @note When done using the timer, delete it with esp_timer_delete function.
|
||||
*
|
||||
* @param create_args Pointer to a structure with timer creation arguments.
|
||||
* Not saved by the library, can be allocated on the stack.
|
||||
* @param[out] out_handle Output, pointer to esp_timer_handle_t variable which
|
||||
* will hold the created timer handle.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if some of the create_args are not valid
|
||||
* - ESP_ERR_INVALID_STATE if esp_timer library is not initialized yet
|
||||
* - ESP_ERR_NO_MEM if memory allocation fails
|
||||
*/
|
||||
esp_err_t esp_timer_create(const esp_timer_create_args_t* create_args,
|
||||
esp_timer_handle_t* out_handle);
|
||||
|
||||
/**
|
||||
* @brief Start one-shot timer
|
||||
*
|
||||
* Timer should not be running when this function is called.
|
||||
*
|
||||
* @param timer timer handle created using esp_timer_create
|
||||
* @param timeout_us timer timeout, in microseconds relative to the current moment
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if the handle is invalid
|
||||
* - ESP_ERR_INVALID_STATE if the timer is already running
|
||||
*/
|
||||
esp_err_t esp_timer_start_once(esp_timer_handle_t timer, uint64_t timeout_us);
|
||||
|
||||
/**
|
||||
* @brief Start a periodic timer
|
||||
*
|
||||
* Timer should not be running when this function is called. This function will
|
||||
* start the timer which will trigger every 'period' microseconds.
|
||||
*
|
||||
* @param timer timer handle created using esp_timer_create
|
||||
* @param period timer period, in microseconds
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if the handle is invalid
|
||||
* - ESP_ERR_INVALID_STATE if the timer is already running
|
||||
*/
|
||||
esp_err_t esp_timer_start_periodic(esp_timer_handle_t timer, uint64_t period);
|
||||
|
||||
/**
|
||||
* @brief Stop the timer
|
||||
*
|
||||
* This function stops the timer previously started using esp_timer_start_once
|
||||
* or esp_timer_start_periodic.
|
||||
*
|
||||
* @param timer timer handle created using esp_timer_create
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE if the timer is not running
|
||||
*/
|
||||
esp_err_t esp_timer_stop(esp_timer_handle_t timer);
|
||||
|
||||
/**
|
||||
* @brief Delete an esp_timer instance
|
||||
*
|
||||
* The timer must be stopped before deleting. A one-shot timer which has expired
|
||||
* does not need to be stopped.
|
||||
*
|
||||
* @param timer timer handle allocated using esp_timer_create
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE if the timer is not running
|
||||
*/
|
||||
esp_err_t esp_timer_delete(esp_timer_handle_t timer);
|
||||
|
||||
/**
|
||||
* @brief Get time in microseconds since boot
|
||||
* @return number of microseconds since esp_timer_init was called (this normally
|
||||
* happens early during application startup).
|
||||
*/
|
||||
int64_t esp_timer_get_time();
|
||||
|
||||
/**
|
||||
* @brief Get the timestamp when the next timeout is expected to occur
|
||||
* @return Timestamp of the nearest timer event, in microseconds.
|
||||
* The timebase is the same as for the values returned by esp_timer_get_time.
|
||||
*/
|
||||
int64_t esp_timer_get_next_alarm();
|
||||
|
||||
/**
|
||||
* @brief Dump the list of timers to a stream
|
||||
*
|
||||
* If CONFIG_ESP_TIMER_PROFILING option is enabled, this prints the list of all
|
||||
* the existing timers. Otherwise, only the list active timers is printed.
|
||||
*
|
||||
* The format is:
|
||||
*
|
||||
* name period alarm times_armed times_triggered total_callback_run_time
|
||||
*
|
||||
* where:
|
||||
*
|
||||
* name — timer name (if CONFIG_ESP_TIMER_PROFILING is defined), or timer pointer
|
||||
* period — period of timer, in microseconds, or 0 for one-shot timer
|
||||
* alarm - time of the next alarm, in microseconds since boot, or 0 if the timer
|
||||
* is not started
|
||||
*
|
||||
* The following fields are printed if CONFIG_ESP_TIMER_PROFILING is defined:
|
||||
*
|
||||
* times_armed — number of times the timer was armed via esp_timer_start_X
|
||||
* times_triggered - number of times the callback was called
|
||||
* total_callback_run_time - total time taken by callback to execute, across all calls
|
||||
*
|
||||
* @param stream stream (such as stdout) to dump the information to
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_NO_MEM if can not allocate temporary buffer for the output
|
||||
*/
|
||||
esp_err_t esp_timer_dump(FILE* stream);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
25
tools/sdk/include/esp_common/esp_types.h
Normal file
25
tools/sdk/include/esp_common/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