Skip to content

Commit

Permalink
samples: boards: stm32 power standby detect sw reset cause
Browse files Browse the repository at this point in the history
After flashing the board, the reset pin and the software
reset are detected as reset cause by the device
Put this in the sample to match the rule

Signed-off-by: Francois Ramu <[email protected]>
  • Loading branch information
FRASTM committed Oct 14, 2024
1 parent 57a6aa3 commit d99b5d4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion samples/boards/st/power_mgmt/standby_shutdown/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tests:
harness_config:
type: multi_line
regex:
- "Reset cause: Reset pin"
- "Reset cause: Reset *"
- "Device ready: .*"
- "Press and hold the user button:"
- "when LED2 is OFF to power off"
Expand Down
9 changes: 5 additions & 4 deletions samples/boards/st/power_mgmt/standby_shutdown/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,20 @@ int main(void)
hwinfo_get_reset_cause(&cause);
hwinfo_clear_reset_cause();

if (cause == RESET_LOW_POWER_WAKE) {
if (cause == RESET_LOW_POWER_WAKE) {
hwinfo_clear_reset_cause();
printk("\nReset cause: Standby mode\n\n");
}

if (cause == (RESET_PIN | RESET_BROWNOUT)) {
printk("\nReset cause: Shutdown mode or power up\n\n");
}

if (cause == RESET_PIN) {
printk("\nReset cause: Reset pin\n\n");
}

/* After flashing the reset cause is 0x3 : RESET_SOFTWARE | RESET_PIN */
if ((cause & RESET_SOFTWARE) == RESET_SOFTWARE) {
printk("\nReset cause: Reset soft\n\n");
}

__ASSERT_NO_MSG(gpio_is_ready_dt(&led));
if (!gpio_is_ready_dt(&button)) {
Expand Down

0 comments on commit d99b5d4

Please sign in to comment.