Hardware Information
Overview
The HW Info API provides access to hardware information such as device identifiers and reset cause flags.
Reset cause flags can be used to determine why the device was reset; for
example due to a watchdog timeout or due to power cycling. Different devices
support different subset of flags. Use
hwinfo_get_supported_reset_cause() to retrieve the flags that are
supported by that device.
Configuration Options
Related configuration options:
API Reference
- group hwinfo_interface
- Hardware Information Interface. - Since
- 1.14 
- Version
- 1.0.0 
 - Reset cause flags - 
RESET_PIN
- External pin. 
 - 
RESET_SOFTWARE
- Software reset. 
 - 
RESET_BROWNOUT
- Brownout (drop in voltage) 
 - 
RESET_POR
- Power-on reset (POR) 
 - 
RESET_WATCHDOG
- Watchdog timer expiration. 
 - 
RESET_DEBUG
- Debug event. 
 - 
RESET_SECURITY
- Security violation. 
 - 
RESET_LOW_POWER_WAKE
- Waking up from low power mode. 
 - 
RESET_CPU_LOCKUP
- CPU lock-up detected. 
 - 
RESET_PARITY
- Parity error. 
 - 
RESET_PLL
- PLL error. 
 - 
RESET_CLOCK
- Clock error. 
 - 
RESET_HARDWARE
- Hardware reset. 
 - 
RESET_USER
- User reset. 
 - 
RESET_TEMPERATURE
- Temperature reset. 
 - Functions - 
ssize_t hwinfo_get_device_id(uint8_t *buffer, size_t length)
- Copy the device id to a buffer. - This routine copies “length” number of bytes of the device ID to the buffer. If the device ID is smaller than length, the rest of the buffer is left unchanged. The ID depends on the hardware and is not guaranteed unique. - Drivers are responsible for ensuring that the ID data structure is a sequence of bytes. The returned ID value is not supposed to be interpreted based on vendor-specific assumptions of byte order. It should express the identifier as a raw byte sequence, doing any endian conversion necessary so that a hex representation of the bytes produces the intended serial number. - Parameters:
- buffer – Buffer to write the ID to. 
- length – Max length of the buffer. 
 
- Return values:
- size – of the device ID copied. 
- -ENOSYS – if there is no implementation for the particular device. 
- any – negative value on driver specific errors. 
 
 
 - 
int hwinfo_get_device_eui64(uint8_t *buffer)
- Copy the device EUI64 to a buffer. - This routine copies the device EUI64 (8 bytes) to the buffer. The EUI64 depends on the hardware and is guaranteed unique. - Parameters:
- buffer – Buffer of 8 bytes to write the ID to. 
 
- Return values:
- zero – if successful. 
- -ENOSYS – if there is no implementation for the particular device. 
- any – negative value on driver specific errors. 
 
 
 - 
int hwinfo_get_reset_cause(uint32_t *cause)
- Retrieve cause of device reset. - This routine retrieves the flags that indicate why the device was reset. - On some platforms the reset cause flags accumulate between successive resets and this routine may return multiple flags indicating all reset causes since the device was powered on. If you need to retrieve the cause only for the most recent reset call - hwinfo_clear_reset_causeafter calling this routine to clear the hardware flags before the next reset event.- Successive calls to this routine will return the same value, unless - hwinfo_clear_reset_causehas been called.- Parameters:
- cause – OR’d reset cause flags 
 
- Return values:
- zero – if successful. 
- -ENOSYS – if there is no implementation for the particular device. 
- any – negative value on driver specific errors. 
 
 
 - 
int hwinfo_clear_reset_cause(void)
- Clear cause of device reset. - Clears reset cause flags. - Return values:
- zero – if successful. 
- -ENOSYS – if there is no implementation for the particular device. 
- any – negative value on driver specific errors. 
 
 
 - 
int hwinfo_get_supported_reset_cause(uint32_t *supported)
- Get supported reset cause flags. - Retrieves all - reset_causeflags that are supported by this device.- Parameters:
- supported – OR’d reset cause flags that are supported 
 
- Return values:
- zero – if successful. 
- -ENOSYS – if there is no implementation for the particular device. 
- any – negative value on driver specific errors.