mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-06-17 11:54:24 +08:00
Merge branch 'feature/add_reset_reason' into 'master'
Add reset reason function See merge request sdk/ESP8266_RTOS_SDK!651
This commit is contained in:
29
components/esp8266/include/esp8266/rtc_register.h
Normal file
29
components/esp8266/include/esp8266/rtc_register.h
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright 2018-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
|
||||
|
||||
typedef enum {
|
||||
NO_MEAN = 0,
|
||||
POWERON_RESET = 1, /**<1, Vbat power on reset*/
|
||||
EXT_RESET = 2, /**<2, external system reset*/
|
||||
SW_RESET = 3, /**<3, Software reset digital core*/
|
||||
OWDT_RESET = 4, /**<4, Legacy watch dog reset digital core*/
|
||||
DEEPSLEEP_RESET = 5, /**<5, Deep Sleep reset digital core*/
|
||||
SDIO_RESET = 6, /**<6, Reset by SLC module, reset digital core*/
|
||||
} RESET_REASON;
|
||||
|
||||
#define RTC_STORE0 (REG_RTC_BASE + 0x30)
|
||||
#define RTC_STATE1 (REG_RTC_BASE + 0x14)
|
||||
#define RTC_STATE2 (REG_RTC_BASE + 0x18)
|
@ -28,6 +28,24 @@ typedef enum {
|
||||
ESP_MAC_WIFI_SOFTAP,
|
||||
} esp_mac_type_t;
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reset reasons
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_RST_UNKNOWN = 0, //!< 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 ESP8266)
|
||||
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;
|
||||
|
||||
/**
|
||||
* @brief Set base MAC address with the MAC address which is stored in EFUSE or
|
||||
* external storage e.g. flash and EEPROM.
|
||||
@ -123,6 +141,12 @@ void system_restore(void) __attribute__ ((noreturn));
|
||||
*/
|
||||
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.
|
||||
*
|
||||
|
53
components/esp8266/include/internal/esp_system_internal.h
Normal file
53
components/esp8266/include/internal/esp_system_internal.h
Normal file
@ -0,0 +1,53 @@
|
||||
// Copyright 2018-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 <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define RTC_SYS_RAM_SIZE 256
|
||||
|
||||
/**
|
||||
* The size of structure must not be larger than 256 bytes and all member varible must be uint32_t type
|
||||
*/
|
||||
struct _rtc_sys_info {
|
||||
uint32_t hint; // software reset reason
|
||||
};
|
||||
|
||||
extern struct _rtc_sys_info rtc_sys_info;
|
||||
|
||||
/**
|
||||
* @brief Internal function to get SoC reset reason at system initialization
|
||||
*/
|
||||
void esp_reset_reason_init(void);
|
||||
|
||||
/**
|
||||
* @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);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
Reference in New Issue
Block a user