Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
CPU reset cause

See Quick start guide for reset cause service.

This is a generic interface for getting and clearing the chip reset causes.

Dependencies

The reset cause interface does not depend on any other modules, as it only accesses a few registers in the device core.

On the other hand, the software reset call might depend on System Clock Management to enable the clock to the debug system, for devices doing software reset through the on-chip debug system. This applies only to the 32-bit AVR devices.

start guide

See Quick start guide for reset cause service

Modules

 SAM4L reset cause
 Driver for CPU specific features.
 

Macros

#define CHIP_RESET_CAUSE_BOD_CPU   0
 Brown-out detected on CPU power domain reset cause not available on this chip. More...
 
#define CHIP_RESET_CAUSE_BOD_IO   0
 Brown-out detected on I/O power domain reset cause not available on this chip. More...
 
#define CHIP_RESET_CAUSE_CPU_ERROR   0
 CPU error reset cause not available on this chip. More...
 
#define CHIP_RESET_CAUSE_EXTRST   0
 External reset cause not available on this chip. More...
 
#define CHIP_RESET_CAUSE_JTAG   0
 JTAG reset cause not available on this chip. More...
 
#define CHIP_RESET_CAUSE_OCD   0
 On-chip debug system reset cause not available on this chip. More...
 
#define CHIP_RESET_CAUSE_POR   0
 Power-on-reset reset cause not available on this chip. More...
 
#define CHIP_RESET_CAUSE_POR_IO   0
 Power-on-reset on I/O power domain reset cause not available on this chip. More...
 
#define CHIP_RESET_CAUSE_SLEEP   0
 Wake from Shutdown sleep mode reset cause not available on this chip. More...
 
#define CHIP_RESET_CAUSE_SOFT   0
 Software reset reset cause not available on this chip. More...
 
#define CHIP_RESET_CAUSE_SPIKE   0
 Spike detected reset cause not available on this chip. More...
 
#define CHIP_RESET_CAUSE_WDT   0
 Watchdog timeout reset cause not available on this chip. More...
 

Enumerations

enum  reset_cause {
  RESET_CAUSE_BOD_CPU = CHIP_RESET_CAUSE_BOD_CPU,
  RESET_CAUSE_BOD_IO = CHIP_RESET_CAUSE_BOD_IO,
  RESET_CAUSE_CPU_ERROR = CHIP_RESET_CAUSE_CPU_ERROR,
  RESET_CAUSE_EXTRST = CHIP_RESET_CAUSE_EXTRST,
  RESET_CAUSE_JTAG = CHIP_RESET_CAUSE_JTAG,
  RESET_CAUSE_OCD = CHIP_RESET_CAUSE_OCD,
  RESET_CAUSE_POR = CHIP_RESET_CAUSE_POR,
  RESET_CAUSE_POR_IO = CHIP_RESET_CAUSE_POR_IO,
  RESET_CAUSE_SLEEP = CHIP_RESET_CAUSE_SLEEP,
  RESET_CAUSE_SOFT = CHIP_RESET_CAUSE_SOFT,
  RESET_CAUSE_SPIKE = CHIP_RESET_CAUSE_SPIKE,
  RESET_CAUSE_WDT = CHIP_RESET_CAUSE_WDT
}
 List of reset causes in bit-mask format. More...
 

Management

static void reset_do_soft_reset (void)
 Perform a software reset of the device. More...
 
static reset_cause_t reset_cause_get_causes (void)
 Get all reset causes. More...
 
static void reset_cause_clear_causes (reset_cause_t causes)
 Clear a bit-mask of reset causes. More...
 

Specific reset cause helper functions

static bool reset_cause_is_cpu_brown_out_detected (void)
 Check if chip reset was caused by a CPU power brown-out detection. More...
 
static bool reset_cause_is_io_brown_out_detected (void)
 Check if chip reset was caused by an I/O power brown-out detection. More...
 
static bool reset_cause_is_brown_out_detected (void)
 Check if chip reset was caused by a brown-out detection on any power domain. More...
 
static bool reset_cause_is_cpu_error (void)
 Check if chip reset was caused by a CPU error, illegal access. More...
 
static bool reset_cause_is_external_reset (void)
 Check if chip reset was caused by an external reset. More...
 
static bool reset_cause_is_jtag (void)
 Check if chip reset was caused by a JTAG reset. More...
 
static bool reset_cause_is_ocd (void)
 Check if chip reset was caused by the on-chip debug system. More...
 
static bool reset_cause_is_power_on_reset (void)
 Check if chip reset was caused by a power-on-reset. More...
 
static bool reset_cause_is_io_power_on_reset (void)
 Check if chip reset was caused by an I/O power-on-reset. More...
 
static bool reset_cause_is_wake_from_shutdown_sleep (void)
 Check if chip reset was caused by a wake up from shutdown sleep mode. More...
 
static bool reset_cause_is_software_reset (void)
 Check if chip reset was caused by a software reset. More...
 
static bool reset_cause_is_spike_detected (void)
 Check if chip reset was caused by a power spike detection. More...
 
static bool reset_cause_is_watchdog (void)
 Check if chip reset was caused by a watchdog timeout. More...
 

#define CHIP_RESET_CAUSE_BOD_CPU   0

Brown-out detected on CPU power domain reset cause not available on this chip.

#define CHIP_RESET_CAUSE_BOD_IO   0

Brown-out detected on I/O power domain reset cause not available on this chip.

#define CHIP_RESET_CAUSE_CPU_ERROR   0

CPU error reset cause not available on this chip.

#define CHIP_RESET_CAUSE_EXTRST   0

External reset cause not available on this chip.

#define CHIP_RESET_CAUSE_JTAG   0

JTAG reset cause not available on this chip.

#define CHIP_RESET_CAUSE_OCD   0

On-chip debug system reset cause not available on this chip.

#define CHIP_RESET_CAUSE_POR   0

Power-on-reset reset cause not available on this chip.

#define CHIP_RESET_CAUSE_POR_IO   0

Power-on-reset on I/O power domain reset cause not available on this chip.

#define CHIP_RESET_CAUSE_SLEEP   0

Wake from Shutdown sleep mode reset cause not available on this chip.

#define CHIP_RESET_CAUSE_SOFT   0

Software reset reset cause not available on this chip.

#define CHIP_RESET_CAUSE_SPIKE   0

Spike detected reset cause not available on this chip.

#define CHIP_RESET_CAUSE_WDT   0

Watchdog timeout reset cause not available on this chip.

List of reset causes in bit-mask format.

Enumerator
RESET_CAUSE_BOD_CPU 

Brown-out detected on CPU power domain reset cause.

RESET_CAUSE_BOD_IO 

Brown-out detected on I/O power domain reset cause.

RESET_CAUSE_CPU_ERROR 

CPU error reset cause.

RESET_CAUSE_EXTRST 

External reset cause.

RESET_CAUSE_JTAG 

JTAG reset cause.

RESET_CAUSE_OCD 

On-chip debug system reset cause.

RESET_CAUSE_POR 

Power-on-reset reset cause.

RESET_CAUSE_POR_IO 

Power-on-reset reset cause.

RESET_CAUSE_SLEEP 

Wake from Shutdown sleep mode reset cause.

RESET_CAUSE_SOFT 

Software reset reset cause.

RESET_CAUSE_SPIKE 

Spike detected reset cause.

RESET_CAUSE_WDT 

Watchdog timeout reset cause.

reset_cause_clear_causes ( reset_cause_t  causes)
inlinestatic

Clear a bit-mask of reset causes.

This function will clear the provided reset causes in the reset cause register.

Parameters
causesbit-mask of reset causes to clear
Note
Reset causes are not clearable on SAM4L.

References UNUSED.

static bool reset_cause_is_brown_out_detected ( void  )
inlinestatic

Check if chip reset was caused by a brown-out detection on any power domain.

Returns
True if reset was caused by a power brown-out detection

References reset_cause_is_cpu_brown_out_detected(), and reset_cause_is_io_brown_out_detected().

static bool reset_cause_is_cpu_brown_out_detected ( void  )
inlinestatic

Check if chip reset was caused by a CPU power brown-out detection.

Returns
True if reset was caused by a CPU power brown-out detection

References RESET_CAUSE_BOD_CPU, and reset_cause_get_causes().

Referenced by main(), and reset_cause_is_brown_out_detected().

static bool reset_cause_is_cpu_error ( void  )
inlinestatic

Check if chip reset was caused by a CPU error, illegal access.

Returns
True if reset was caused by a CPU error, illegal access

References RESET_CAUSE_CPU_ERROR, and reset_cause_get_causes().

static bool reset_cause_is_external_reset ( void  )
inlinestatic

Check if chip reset was caused by an external reset.

Returns
True if reset was caused by an external reset

References RESET_CAUSE_EXTRST, and reset_cause_get_causes().

Referenced by main().

static bool reset_cause_is_io_brown_out_detected ( void  )
inlinestatic

Check if chip reset was caused by an I/O power brown-out detection.

Returns
True if reset was caused by an I/O power brown-out detection

References RESET_CAUSE_BOD_IO, and reset_cause_get_causes().

Referenced by main(), and reset_cause_is_brown_out_detected().

static bool reset_cause_is_io_power_on_reset ( void  )
inlinestatic

Check if chip reset was caused by an I/O power-on-reset.

Returns
True if reset was caused by a power-on-reset

References reset_cause_get_causes(), and RESET_CAUSE_POR_IO.

static bool reset_cause_is_jtag ( void  )
inlinestatic

Check if chip reset was caused by a JTAG reset.

Returns
True if reset was caused by a JTAG reset

References reset_cause_get_causes(), and RESET_CAUSE_JTAG.

static bool reset_cause_is_ocd ( void  )
inlinestatic

Check if chip reset was caused by the on-chip debug system.

Returns
True if reset was caused by the on-chip debug system

References reset_cause_get_causes(), and RESET_CAUSE_OCD.

Referenced by main().

static bool reset_cause_is_power_on_reset ( void  )
inlinestatic

Check if chip reset was caused by a power-on-reset.

Returns
True if reset was caused by a power-on-reset

References reset_cause_get_causes(), and RESET_CAUSE_POR.

Referenced by main().

static bool reset_cause_is_software_reset ( void  )
inlinestatic

Check if chip reset was caused by a software reset.

Returns
True if reset was caused by a software reset

References reset_cause_get_causes(), and RESET_CAUSE_SOFT.

static bool reset_cause_is_spike_detected ( void  )
inlinestatic

Check if chip reset was caused by a power spike detection.

Returns
True if reset was caused by a spike detection

References reset_cause_get_causes(), and RESET_CAUSE_SPIKE.

static bool reset_cause_is_wake_from_shutdown_sleep ( void  )
inlinestatic

Check if chip reset was caused by a wake up from shutdown sleep mode.

Returns
True if reset was caused by a wake up from shutdown sleep mode

References reset_cause_get_causes(), and RESET_CAUSE_SLEEP.

static bool reset_cause_is_watchdog ( void  )
inlinestatic

Check if chip reset was caused by a watchdog timeout.

Returns
True if reset was caused by a watchdog timeout

References reset_cause_get_causes(), and RESET_CAUSE_WDT.

Referenced by main().

void reset_do_soft_reset ( void  )
inlinestatic

Perform a software reset of the device.

Note
This function will never return.
This function does not disable interrupts, this is up to the caller to handle.

Referenced by main().