Skip to content

Commit

Permalink
TEMP - test powerctl_suspend
Browse files Browse the repository at this point in the history
  • Loading branch information
cepetr committed Dec 19, 2024
1 parent 0223078 commit 2e41fe6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/embed/upymod/modtrezorio/modtrezorio-poll.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
#include <io/button.h>
#endif

#ifdef USE_POWERCTL
#include <sys/powerctl.h> // --- experimental ---
#endif

#include "embed/upymod/trezorobj.h"

#ifdef TREZOR_EMULATOR
Expand Down Expand Up @@ -150,6 +154,15 @@ STATIC mp_obj_t mod_trezorio_poll(mp_obj_t ifaces, mp_obj_t list_ref,
#if USE_BUTTON
else if (iface == BUTTON_IFACE) {
const uint32_t evt = button_get_event();

// --- experimental ---
#ifdef USE_POWERCTL
if (((evt & 0xFFFF) == BTN_POWER) && ((evt & BTN_EVT_UP) != 0)) {
powerctl_suspend();
}
#endif // USE_POWERCTL
// ----

if (evt & (BTN_EVT_DOWN | BTN_EVT_UP)) {
mp_obj_tuple_t *tuple = MP_OBJ_TO_PTR(mp_obj_new_tuple(2, NULL));
uint32_t etype = (evt >> 24) & 0x3U; // button down/up
Expand Down

0 comments on commit 2e41fe6

Please sign in to comment.