File tree Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Expand file tree Collapse file tree 2 files changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -82,10 +82,6 @@ int main(int argc, char **argv) {
8282 SCB -> SCR |= SCB_SCR_SEVONPEND_Msk ;
8383 #endif
8484
85- #if defined(MICROPY_HW_PSRAM_CS_PIN ) && MICROPY_HW_ENABLE_PSRAM
86- size_t psram_size = psram_init (MICROPY_HW_PSRAM_CS_PIN );
87- #endif
88-
8985 pendsv_init ();
9086 soft_timer_init ();
9187
@@ -98,6 +94,10 @@ int main(int argc, char **argv) {
9894 // Set the flash divisor to an appropriate value
9995 rp2_flash_set_timing ();
10096
97+ #if defined(MICROPY_HW_PSRAM_CS_PIN ) && MICROPY_HW_ENABLE_PSRAM
98+ size_t psram_size = psram_init (MICROPY_HW_PSRAM_CS_PIN );
99+ #endif
100+
101101 #if MICROPY_HW_ENABLE_UART_REPL
102102 bi_decl (bi_program_feature ("UART REPL" ))
103103 setup_default_uart ();
Original file line number Diff line number Diff line change 99size_t __no_inline_not_in_flash_func (psram_detect )() {
1010 int psram_size = 0 ;
1111
12- uint32_t intr_stash = save_and_disable_interrupts ();
13-
1412 // Try and read the PSRAM ID via direct_csr.
1513 qmi_hw -> direct_csr = 30 << QMI_DIRECT_CSR_CLKDIV_LSB | QMI_DIRECT_CSR_EN_BITS ;
1614
@@ -76,13 +74,14 @@ size_t __no_inline_not_in_flash_func(psram_detect)() {
7674 }
7775 }
7876
79- restore_interrupts (intr_stash );
8077 return psram_size ;
8178}
8279
8380size_t __no_inline_not_in_flash_func (psram_init )(uint cs_pin ) {
8481 gpio_set_function (cs_pin , GPIO_FUNC_XIP_CS1 );
8582
83+ uint32_t intr_stash = save_and_disable_interrupts ();
84+
8685 size_t psram_size = psram_detect ();
8786
8887 if (!psram_size ) {
@@ -162,5 +161,7 @@ size_t __no_inline_not_in_flash_func(psram_init)(uint cs_pin) {
162161 // Enable writes to PSRAM
163162 hw_set_bits (& xip_ctrl_hw -> ctrl , XIP_CTRL_WRITABLE_M1_BITS );
164163
164+ restore_interrupts (intr_stash );
165+
165166 return psram_size ;
166167}
You can’t perform that action at this time.
0 commit comments