Add generic function to detzermine reset cuase to rcc manager
This commit is contained in:
@@ -40,11 +40,4 @@ int watchdog_setup(uint8_t prescaler);
|
||||
*/
|
||||
int watchdog_ack(uint32_t magic);
|
||||
|
||||
/**
|
||||
* @brief Check if reset was generated by the watchdog.
|
||||
* @note This also clears the relevant flag, so the function will return false when called a second time
|
||||
* @return true, if reset was generated by the watchdog
|
||||
*/
|
||||
bool watchdog_check_reset_source(void);
|
||||
|
||||
#endif /* __WATCHDOG_H__ */
|
||||
|
@@ -23,6 +23,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stm-periph/stm32-gpio-macros.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/**
|
||||
* @brief The RCC Enable Manager uses static memory with a fixed maximum
|
||||
@@ -35,6 +36,19 @@
|
||||
#error "RCC Enable Manager not yet implemented with dynamic memory"
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief The source/cause of a system reset. The values can be or'ed together as multiple flags may be possible at the same time.
|
||||
*/
|
||||
enum rcc_reset_source {
|
||||
RCC_RESET_SOURCE_LOW_POWER = (1<<0), /**< @brief System reset caused by low power reset */
|
||||
RCC_RESET_SOURCE_SOFTWARE = (1<<1), /**< @brief System reset caused by software */
|
||||
RCC_RESET_SOURCE_WWD = (1<<2), /**< @brief System reset caused by window watchdog */
|
||||
RCC_RESET_SOURCE_IWDG = (1<<3), /**< @brief System reset caused by independent watchdog */
|
||||
RCC_RESET_SOURCE_POWER_ON = (1<<4), /**< @brief System reset caused by power on reset (POR) */
|
||||
RCC_RESET_SOURCE_PIN = (1<<5), /**< @brief System reset caused by NRST pin */
|
||||
RCC_RESET_BOR_POR = (1<<6), /**< @brief System reset caused by eitehr brown out or POR */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Enable Clock for peripheral by setting the corresponding bit (@p bit_no) to one
|
||||
*
|
||||
@@ -64,4 +78,11 @@ int rcc_manager_enable_clock(volatile uint32_t *rcc_enable_register, uint8_t bit
|
||||
*/
|
||||
int rcc_manager_disable_clock(volatile uint32_t *rcc_enable_register, uint8_t bit_no);
|
||||
|
||||
/**
|
||||
* @brief Get the causes of the last system reset.
|
||||
* @param clear_flags Clear the reset cause
|
||||
* @return Reset cause
|
||||
*/
|
||||
enum rcc_reset_source rcc_manager_get_reset_cause(bool clear_flags);
|
||||
|
||||
#endif /* __RCC_MANAGER_H__ */
|
||||
|
Reference in New Issue
Block a user