Skip to content

Commit 04bf835

Browse files
committed
alif/boards/ALIF_ENSEMBLE: Add an off-profile.
The buttons can now wake the device from deepsleep. Signed-off-by: Damien George <damien@micropython.org>
1 parent 58d2610 commit 04bf835

File tree

1 file changed

+33
-0
lines changed
  • ports/alif/boards/ALIF_ENSEMBLE

1 file changed

+33
-0
lines changed

ports/alif/boards/ALIF_ENSEMBLE/board.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "py/mphal.h"
2828
#include "ospi_ext.h"
2929
#include "ospi_flash.h"
30+
#include "se_services.h"
3031

3132
const ospi_pin_settings_t ospi_pin_settings = {
3233
.peripheral_number = 1,
@@ -56,6 +57,38 @@ const ospi_flash_settings_t ospi_flash_settings[] = {
5657
const size_t ospi_flash_settings_len = 1;
5758

5859
void board_early_init(void) {
60+
// Set default off profile
61+
off_profile_t off_profile = {
62+
.dcdc_mode = DCDC_MODE_PWM,
63+
.dcdc_voltage = DCDC_VOUT_0825,
64+
// CLK_SRC_LFRC or CLK_SRC_LFXO
65+
.aon_clk_src = CLK_SRC_LFXO,
66+
// CLK_SRC_HFRC, CLK_SRC_HFXO or CLK_SRC_PLL
67+
.stby_clk_src = CLK_SRC_HFRC,
68+
.stby_clk_freq = SCALED_FREQ_RC_STDBY_76_8_MHZ,
69+
// Disable all power domains except AON.
70+
.power_domains = PD_VBAT_AON_MASK,
71+
// Keep SERAM, MRAM and backup SRAM on.
72+
// (SRAM0 also needs to stay on because it's used for .bss.sram0 which is zerod
73+
// by the runtime before the run profile is configured.)
74+
.memory_blocks = SERAM_MASK | SRAM0_MASK | MRAM_MASK | BACKUP4K_MASK,
75+
// Gate the clocks of IP blocks.
76+
.ip_clock_gating = 0x3ffb,
77+
// Gate PHY power (saves 0.5uA).
78+
.phy_pwr_gating = LDO_PHY_MASK | USB_PHY_MASK | MIPI_TX_DPHY_MASK | MIPI_RX_DPHY_MASK |
79+
MIPI_PLL_DPHY_MASK,
80+
.vdd_ioflex_3V3 = IOFLEX_LEVEL_3V3,
81+
.vtor_address = SCB->VTOR,
82+
.vtor_address_ns = SCB->VTOR,
83+
// Configure wake-up sources.
84+
.ewic_cfg = EWIC_VBAT_GPIO | EWIC_RTC_A,
85+
.wakeup_events = WE_LPGPIO7 | WE_LPGPIO6 | WE_LPGPIO5 | WE_LPGPIO4 | WE_LPRTC,
86+
};
87+
88+
if (se_services_set_off_profile(&off_profile)) {
89+
MICROPY_BOARD_FATAL_ERROR("se_services_set_off_profile");
90+
}
91+
5992
// Configure the joystick buttons as an input with pull-up enabled.
6093
mp_hal_pin_config(pin_JOY_LEFT, MP_HAL_PIN_MODE_INPUT, MP_HAL_PIN_PULL_UP, 0, 0, 0, true);
6194
mp_hal_pin_config(pin_JOY_RIGHT, MP_HAL_PIN_MODE_INPUT, MP_HAL_PIN_PULL_UP, 0, 0, 0, true);

0 commit comments

Comments
 (0)