mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-23 06:58:13 +00:00
feat(core/prodtest): improve pm-suspend command
[no changelog]
This commit is contained in:
parent
efa64647f4
commit
4672745a5b
@ -833,19 +833,30 @@ OK
|
||||
Enters low-power mode.
|
||||
|
||||
In low-power mode, the CPU retains its state, including SRAM content.
|
||||
The device can be woken by pressing the power button and will continue
|
||||
operation from the point where it was suspended.
|
||||
|
||||
The following wake-up reasons are currently possible:
|
||||
- BUTTON - the power button was pressed
|
||||
- POWER - USB or WPC power was detected
|
||||
- BLE - BLE communication was detected
|
||||
- RTC - the RTC wake-up timer expired
|
||||
|
||||
```
|
||||
pm-suspend [<wakeup-time>]
|
||||
```
|
||||
|
||||
The command returns OK followed by a list of wake-up reasons, separated
|
||||
by spaces.
|
||||
|
||||
Example:
|
||||
```
|
||||
pm-suspend
|
||||
# Suspending the device to low-power mode...
|
||||
# Press the POWER button to resume.
|
||||
# Press a button button to resume.
|
||||
|
||||
....
|
||||
|
||||
# Resumed to active mode.
|
||||
OK
|
||||
OK BUTTON
|
||||
```
|
||||
|
||||
### pm-hibernate
|
||||
|
@ -19,17 +19,18 @@
|
||||
|
||||
#ifdef USE_POWER_MANAGER
|
||||
|
||||
#include <trezor_rtl.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <rtl/cli.h>
|
||||
#include <rtl/mini_printf.h>
|
||||
#include <rtl/unit_test.h>
|
||||
#include <rust_ui_prodtest.h>
|
||||
#include <sys/power_manager.h>
|
||||
#include <sys/rtc.h>
|
||||
#include <sys/systick.h>
|
||||
|
||||
#include <trezor_rtl.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "prodtest.h"
|
||||
|
||||
void prodtest_pm_hibernate(cli_t* cli) {
|
||||
@ -62,15 +63,43 @@ void prodtest_pm_suspend(cli_t* cli) {
|
||||
}
|
||||
|
||||
cli_trace(cli, "Suspending the device to low-power mode...");
|
||||
cli_trace(cli, "Press the POWER button to resume.");
|
||||
cli_trace(cli, "Press a button to resume.");
|
||||
systick_delay_ms(1000);
|
||||
|
||||
pm_suspend(NULL);
|
||||
wakeup_flags_t wakeup_flags = 0;
|
||||
|
||||
pm_suspend(&wakeup_flags);
|
||||
|
||||
systick_delay_ms(1500);
|
||||
cli_trace(cli, "Resumed to active mode.");
|
||||
|
||||
cli_ok(cli, "");
|
||||
char flags_str[128] = "";
|
||||
|
||||
if (wakeup_flags & WAKEUP_FLAG_BUTTON) {
|
||||
strcat(flags_str, "BUTTON ");
|
||||
}
|
||||
|
||||
if (wakeup_flags & WAKEUP_FLAG_POWER) {
|
||||
strcat(flags_str, "POWER ");
|
||||
}
|
||||
|
||||
if (wakeup_flags & WAKEUP_FLAG_BLE) {
|
||||
strcat(flags_str, "BLE ");
|
||||
}
|
||||
|
||||
if (wakeup_flags & WAKEUP_FLAG_NFC) {
|
||||
strcat(flags_str, "NFC ");
|
||||
}
|
||||
|
||||
if (wakeup_flags & WAKEUP_FLAG_RTC) {
|
||||
strcat(flags_str, "RTC ");
|
||||
}
|
||||
|
||||
if (wakeup_flags == 0) {
|
||||
cli_trace(cli, "Woken up by unknown reason.");
|
||||
}
|
||||
|
||||
cli_ok(cli, "%s", flags_str);
|
||||
}
|
||||
|
||||
void prodtest_pm_charge_disable(cli_t* cli) {
|
||||
@ -387,7 +416,7 @@ PRODTEST_CLI_CMD(
|
||||
.name = "pm-suspend",
|
||||
.func = prodtest_pm_suspend,
|
||||
.info = "Suspend the device to low-power mode",
|
||||
.args = ""
|
||||
.args = "[<wakeup-time>]"
|
||||
);
|
||||
|
||||
PRODTEST_CLI_CMD(
|
||||
|
@ -21,6 +21,8 @@
|
||||
|
||||
#include <trezor_types.h>
|
||||
|
||||
#include <sys/suspend.h>
|
||||
|
||||
/* power manager status codes */
|
||||
typedef enum {
|
||||
PM_OK = 0,
|
||||
|
@ -242,7 +242,7 @@ pm_status_t pm_suspend(wakeup_flags_t* wakeup_reason) {
|
||||
wakeup_flags_t wakeup_flags = system_suspend();
|
||||
|
||||
// TODO: Handle wake-up flags
|
||||
UNUSED(wakeup_flags);
|
||||
// UNUSED(wakeup_flags);
|
||||
|
||||
// Exit hibernation state if it was requested
|
||||
irq_key = irq_lock();
|
||||
|
Loading…
Reference in New Issue
Block a user