|
27 | 27 | #include "py/mphal.h" |
28 | 28 | #include "ospi_ext.h" |
29 | 29 | #include "ospi_flash.h" |
| 30 | +#include "se_services.h" |
30 | 31 |
|
31 | 32 | const ospi_pin_settings_t ospi_pin_settings = { |
32 | 33 | .peripheral_number = 1, |
@@ -56,6 +57,38 @@ const ospi_flash_settings_t ospi_flash_settings[] = { |
56 | 57 | const size_t ospi_flash_settings_len = 1; |
57 | 58 |
|
58 | 59 | 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 | + |
59 | 92 | // Configure the joystick buttons as an input with pull-up enabled. |
60 | 93 | mp_hal_pin_config(pin_JOY_LEFT, MP_HAL_PIN_MODE_INPUT, MP_HAL_PIN_PULL_UP, 0, 0, 0, true); |
61 | 94 | mp_hal_pin_config(pin_JOY_RIGHT, MP_HAL_PIN_MODE_INPUT, MP_HAL_PIN_PULL_UP, 0, 0, 0, true); |
|
0 commit comments