nrfcxx
0.1.0
C++-17 Framework for Nordic nRF5 Devices
|
The raw data supporting cross-reset state transfer. More...
#include <nrfcxx/core.hpp>
Public Types | |
enum | reset_reas_enum : reset_reas_type { RESET_REAS_RESETPIN = 0x0001, RESET_REAS_DOG = 0x0002, RESET_REAS_SREQ = 0x004, RESET_REAS_LOCKUP = 0x0008, RESET_REAS_OFF = 0x0010, RESET_REAS_LPCOMP = 0x0020, RESET_REAS_DIF = 0x0040, RESET_REAS_NFC = 0x0080, RESET_REAS_VBUS = 0x0100, RESET_REAS_HARDWARE_Msk = 0x01FF, RESET_REAS_INTERNAL = 0x0400, RESET_REAS_PROGRAMMATIC = 0x0800, RESET_REAS_FAILSAFE = 0x1000, RESET_REAS_WDTBARKED = 0x2000, RESET_REAS_SDFAULT = 0x4000, RESET_REAS_CONTROLLED = 0x8000 } |
Defined bits in reset_reas. More... | |
using | reset_reas_type = uint16_t |
Base type underlying bits stored in reset_reas. | |
Data Fields | |
uint32_t | magic |
A magic number that is used to determine the state is valid. More... | |
unsigned int | om_updated |
Time of last change to operational mode. More... | |
uint64_t | om_total [NUM_OPERATIONAL_MODES] |
Cumulative time spent in each operational mode since restart. | |
uint64_t | last_uptime |
Duration of the last system session, in uptime clock ticks. More... | |
uint64_t | total_uptime |
Total of last_uptime values since the state was reset. More... | |
uint32_t | last_pc |
The program counter at which the reset was initiated. More... | |
unsigned int | code |
Data recording the code passed to reset() in the previous session. More... | |
unsigned int | sdfault_id |
Data recording the id of a soft-device fault. More... | |
uint16_t | reset_count |
The number of times the system has been restarted with cross-reset state successfully transferred. More... | |
reset_reas_type | reset_reas |
Captured data from NRF_POWER->RESETREAS . More... | |
uint8_t | wdt_status |
Bits identifying watchdog channels that caused a system reset. More... | |
uint8_t | om_value |
Bits identifying the current operational mode. More... | |
Static Public Attributes | |
static constexpr uint32_t | DECL_MAGIC = 0x20181013U |
Constant encoding a revision number marking the last change to the layout or interpretation of this structure. More... | |
The raw data supporting cross-reset state transfer.
An instance of this should be declared in an uninitialized data section then used as the parameter when constructing a single systemState instance. The raw state object should not be accessed directly by application code; instead use cs.state().
Defined bits in reset_reas.
Carries the defined bits from the nRF5 NRF_POWER->RESETREAS
register packed into an 8-bit value:
RESETREAS
, providing RESETPIN
, DOG
, SREQ
, and LOCKUP
reasons.RESETREAS
, providnig OFF
, LPCOMP
, DIF
, NFC
(nRF52), and VBUS
(nRF52840) reasons.Other bits provide additional information:
DOG
or SREQ
.DOG
or SREQ
.DOG
or SREQ
.DOG
or SREQ
.Enumerator | |
---|---|
RESET_REAS_RESETPIN | Bit mask for reset_reas to indicate reset due to the reset pin. This reason will probably never co-occur with RESET_REAS_CONTROLLED. |
RESET_REAS_DOG | Bit mask for reset_reas to indicate reset due to watchdog. |
RESET_REAS_SREQ | Bit mask for reset_reas to indicate reset due to AIRCR.SYSRESETRQ. |
RESET_REAS_LOCKUP | Bit mask for reset_reas to indicate reset due to CPU lock-up. |
RESET_REAS_OFF | Bit mask for reset_reas to indicate wakeup from system OFF mode due to DETECT from the GPIO peripheral. |
RESET_REAS_LPCOMP | Bit mask for reset_reas to indicate wakeup from system OFF mode due to ANADETECT from the LPCOMP peripheral. |
RESET_REAS_DIF | Bit mask for reset_reas to indicate wakeup from system OFF mode due to debug interface mode. |
RESET_REAS_NFC | Bit mask for reset_reas to indicate wakeup from system OFF mode due to NFC field detection. This is available on the nRF52 only, and is provided by the POWER peripheral. |
RESET_REAS_VBUS | Bit mask for reset_reas to indicate wakeup from system OFF mode due to VBUS becoming valid. This is available on the nRF52840 only, and is provided by the POWER peripheral. |
RESET_REAS_HARDWARE_Msk | Bit mask isolating the bits of reset_reas that are set from hardware. If RESET_REAS_CONTROLLED is not set, only the bits isolated by this mask will be defined. |
RESET_REAS_INTERNAL | Bit mask for reset_reas to indicate framework-requested reset. |
RESET_REAS_PROGRAMMATIC | Bit mask for reset_reas to indicate an application-requested reset. Resets due to invocation of reset() are flagged with this bit. The code field provides additional information. |
RESET_REAS_FAILSAFE | Bit mask for reset_reas to indicate a fatal system error from which a reset will not recover. Resets due to invocation of failsafe() are flagged with this bit. The code field provides additional information.
|
RESET_REAS_WDTBARKED | Bit mask for reset_reas to indicate a captured watchdog reset. Resets due to a watchdog that reached WDT_IRQHandler() are flagged with this bit. |
RESET_REAS_SDFAULT | Bit mask for reset_reas to indicate a soft-device fault. Resets due to invocation of sd_fault_handler() are flagged with this bit. The #code and #sdfault_id fields provide additional information. |
RESET_REAS_CONTROLLED | Bit mask for reset_reas to indicate that the reset was controlled. This bit is set if the lowest level reset function was invoked to initiate or wait out the reset. Absence of the bit on startup indicates that any state content that should have been updated during the reset process may be invalid. |
unsigned int nrfcxx::systemState::state_type::code |
Data recording the code passed to reset() in the previous session.
If RESET_REAS_FAILSAFE is set in reset_reas this field holds the value passed to failsafe() in the previous session.
If RESET_REAS_PROGRAMMATIC is set in reset_reas this field holds the value passed to reset() in the previous session.
If RESET_REAS_SDFAULT is set in reset_reas this field holds the value passed to info
in sd_fault_handler() in the previous session. This may be zero.
Otherwise this field should be zero.
|
staticconstexpr |
Constant encoding a revision number marking the last change to the layout or interpretation of this structure.
This value should be updated whenever structure content is changed in a way that would make a program inspecting an instance from a previous execution to misinterpret it.
uint32_t nrfcxx::systemState::state_type::last_pc |
The program counter at which the reset was initiated.
This may be zero if the reset cause did not provide a program counter. It should be correct if RESET_REAS_PROGRAMMATIC, RESET_REAS_SDFAULT, RESET_REAS_WDTBARKED, or RESET_REAS_FAILSAFE are set in reset_reas.
uint64_t nrfcxx::systemState::state_type::last_uptime |
Duration of the last system session, in uptime clock ticks.
This is calculated on restart by summing the individual components of om_total from the previous session.
uint32_t nrfcxx::systemState::state_type::magic |
A magic number that is used to determine the state is valid.
The value is specific to the systemState instance used to wrap the state data, allowing it to be derived from material such as a compile-time constant encoding an image version or from a program checksum. The application-provided base magic number is convolved with the size of this structure and DECL_MAGIC to increase the likelihood that changes to the content of this structure will invalidate state on a system reset.
unsigned int nrfcxx::systemState::state_type::om_updated |
Time of last change to operational mode.
This is the value of clock::uptime::now24() the last time systemState::updateOperationalMode() was invoked.
uint8_t nrfcxx::systemState::state_type::om_value |
Bits identifying the current operational mode.
This encodes the current set of capabilities that distinguish operational modes.
uint16_t nrfcxx::systemState::state_type::reset_count |
The number of times the system has been restarted with cross-reset state successfully transferred.
The value after a power-up reset should be zero.
reset_reas_type nrfcxx::systemState::state_type::reset_reas |
Captured data from NRF_POWER->RESETREAS
.
unsigned int nrfcxx::systemState::state_type::sdfault_id |
Data recording the id
of a soft-device fault.
If RESET_REAS_SDFAULT is set in reset_reas this field holds the value passed to id
in sd_fault_handler() in the previous session.
Otherwise this field should be zero.
uint64_t nrfcxx::systemState::state_type::total_uptime |
Total of last_uptime values since the state was reset.
This should be zero only when reset_count is zero. On reset, the value stored in last_uptime is added to the retained value from the previous session.
uint8_t nrfcxx::systemState::state_type::wdt_status |
Bits identifying watchdog channels that caused a system reset.
If non-zero the value contains the value of NRF_WDT->REQSTATUS
captured in the watchdog interrupt handler just before reset occurred. Set bits identify the reloads that were not made in time to inhibit the watchdog.
If zero the system was reset for reasons that did not include a watchdog timeout, or was due to systemState::reset() (systemState::failsafe()) being invoked when the watchdog was active in which case RESET_REAS_PROGRAMMATIC (RESET_REAS_FAILSAFE) should take precedence.
DOG
is set in reset_reas and RESET_REAS_PROGRAMMATIC is cleared then a watchdog reset occured at a time when the watchdog interrupt handler was blocked from recording the unloaded channels.