WE310F5  39.00.000
M2MB SYSTEM RESET

This section describes the M2MB APIs related to system reset functionality. More...

#define M2MB_ERR_LOG_MAX_FILE_NAME_LEN   50
 
#define M2MB_ERR_LOG_MAX_THREAD_NAME_LEN   20
 
enum  M2MB_SYSTEM_RESET_RESON_T {
  M2MB_SYSTEM_BOOT_REASON_PON_COLD_BOOT,
  M2MB_SYSTEM_BOOT_REASON_WATCHDOG_BOOT,
  M2MB_SYSTEM_BOOT_REASON_SW_BOOT,
  M2MB_SYSTEM_BOOT_REASON_EXCEPTION_HARD_FAULT,
  M2MB_SYSTEM_BOOT_REASON_EXCEPTION_MEM_FAULT,
  M2MB_SYSTEM_BOOT_REASON_EXCEPTION_USAGE_FAULT,
  M2MB_SYSTEM_BOOT_REASON_EXCEPTION_BUS_FAULT,
  M2MB_SYSTEM_BOOT_REASON_STANDBY_BOOT,
  M2MB_SYSTEM_BOOT_REASON_UNKNOWN_BOOT,
  M2MB_SYSTEM_BOOT_REASON_SIZE_ENUM = 0x7FFFFFFF
}
 Enum defining different boot reason. More...
 
typedef struct M2MB_SYSTEM_EXCEPTION_INFO M2MB_SYSTEM_EXCEPTION_INFO_T
 Structure defining details of exception information. More...
 
VOID m2mb_system_reset (VOID)
 System Reset API. More...
 
M2MB_STATUS_T m2mb_get_boot_reason (M2MB_SYSTEM_RESET_RESON_T *reason)
 Boot reason. More...
 
M2MB_STATUS_T m2mb_get_exception_info (M2MB_SYSTEM_EXCEPTION_INFO_T *excptionInfo)
 To get the details on exception. More...
 
VOID m2mb_wdog_enable (VOID)
 To enable watchdog. More...
 
VOID m2mb_wdog_disable (VOID)
 To disable watchdog. More...
 
UINT32 m2mb_wdog_is_enable (VOID)
 To find whether the watchdog is enabled or not. More...
 
VOID m2mb_wdog_kick (VOID)
 To reset the watchdog. More...
 

Detailed Description

This section describes the M2MB APIs related to system reset functionality.

WE310F5_System_Reset.png
System Reset

System reset module provides APIs to reset the system, get reset information and handling system watchdog.

Macro Definition Documentation

◆ M2MB_ERR_LOG_MAX_FILE_NAME_LEN

#define M2MB_ERR_LOG_MAX_FILE_NAME_LEN   50

Definition at line 51 of file m2mb_system_reset.h.

◆ M2MB_ERR_LOG_MAX_THREAD_NAME_LEN

#define M2MB_ERR_LOG_MAX_THREAD_NAME_LEN   20

Definition at line 52 of file m2mb_system_reset.h.

Typedef Documentation

◆ M2MB_SYSTEM_EXCEPTION_INFO_T

Structure defining details of exception information.

Exception information details.

Enumeration Type Documentation

◆ M2MB_SYSTEM_RESET_RESON_T

Enum defining different boot reason.

Enum defines different boot reason.

Enumerator
M2MB_SYSTEM_BOOT_REASON_PON_COLD_BOOT 

Power on cold boot or hardware reset.

M2MB_SYSTEM_BOOT_REASON_WATCHDOG_BOOT 

Reset from the Watchdog.

M2MB_SYSTEM_BOOT_REASON_SW_BOOT 

Software cold reset.

M2MB_SYSTEM_BOOT_REASON_EXCEPTION_HARD_FAULT 

Exception, Hard fault.

M2MB_SYSTEM_BOOT_REASON_EXCEPTION_MEM_FAULT 

Exception, Memory management fault.

M2MB_SYSTEM_BOOT_REASON_EXCEPTION_USAGE_FAULT 

Exception, Usage fault.

M2MB_SYSTEM_BOOT_REASON_EXCEPTION_BUS_FAULT 

Exception, Bus fault.

M2MB_SYSTEM_BOOT_REASON_STANDBY_BOOT 

Wakeup from Standby.

M2MB_SYSTEM_BOOT_REASON_UNKNOWN_BOOT 

Unknown software cold boot.

M2MB_SYSTEM_BOOT_REASON_SIZE_ENUM 

Definition at line 64 of file m2mb_system_reset.h.

Function Documentation

◆ m2mb_get_boot_reason()

M2MB_STATUS_T m2mb_get_boot_reason ( M2MB_SYSTEM_RESET_RESON_T reason)

Boot reason.

This API gives the boot reason.

Parameters
[out]reasonPointer to the store the boot reason.
Returns
M2MB_OK if the boot reason could be found successful. M2MB_ERROR if the boot reason could not be found.
Note

To find the boot reason and do the rest of the processing based on this.

if( M2MB_OK == m2mb_get_boot_reason( &reason ))
m2mb_dbg_consol_print("Boot Reason = %d", reason );

◆ m2mb_get_exception_info()

M2MB_STATUS_T m2mb_get_exception_info ( M2MB_SYSTEM_EXCEPTION_INFO_T excptionInfo)

To get the details on exception.

This API gives the reason of exception and the register detail when exception happened.

Parameters
[out]excptionInfoPointer to the store the boot reason.
Returns
M2MB_OK if the exception details could be found successful. M2MB_ERROR if the exception details could not be found.
Note

To find the details on exception reason for debugging purpose.

{
UINT8 i;
m2mb_dbg_consol_print("Boot Reason = %d", info.reason );
for( i = 0; i < 16; i++ )
m2mb_dbg_consol_print("R%02d: = %08x", i, info.reg[i] );
}

◆ m2mb_system_reset()

VOID m2mb_system_reset ( VOID  )

System Reset API.

Resets the system.

Returns
None
Note
Once this API is called the system gets reseted, so the call does not return back to the caller. Can be used for ASSERTING the system
//If malloc fails for any important activity which has to be done in the
//system, in that case user can choose to reset the system.
UINT8* pBuf = malloc(size);
if(pBuf == NULL)m2mb_system_reset();

◆ m2mb_wdog_disable()

VOID m2mb_wdog_disable ( VOID  )

To disable watchdog.

This API disables the watchdog.

Note
By default, watchdog is enabled and fires in 10sec. To disable the watchdog this API can be called.

VOID m2mb_wdog_disable( VOID );

while(1)
{
....
....
}

◆ m2mb_wdog_enable()

VOID m2mb_wdog_enable ( VOID  )

To enable watchdog.

This API enables the watchdog.

Note
By default watchdog is enabled and fires in 10sec. The watchdog is kicked internally by the system. If a thread executes for more than 10sec without reliquencing the CPU control watchdog will fire and system would reset.

VOID m2mb_wdog_enable( VOID );

while(1)
{
....
....
}

◆ m2mb_wdog_is_enable()

UINT32 m2mb_wdog_is_enable ( VOID  )

To find whether the watchdog is enabled or not.

This API finds out if the watchdog is enabled or not.

Returns
1 if the watchdog is enabled. 0 if the watchdog is disabled.
Note

UINT32 m2mb_wdog_is_enable( VOID );

while(1)
{
....
....
}

◆ m2mb_wdog_kick()

VOID m2mb_wdog_kick ( VOID  )

To reset the watchdog.

This API resets the watchdog timer and start again.

Note
By default, watchdog is enabled and fires in 10sec. The watchdog is kicked internally by the system. If a thread executes for more than 10sec without reliquencing the CPU control watchdog will fire and system would reset.

m2mb_wdog_kick( VOID );

while(1)
{
....
....
}