Skip to content

Commit

Permalink
Disable FIFO IRQ when doing reset of core1 (same as with launching) (#…
Browse files Browse the repository at this point in the history
…1447)

* fifo irq disabled during core1 reset

* silence warning about unused variable in multicore.c
  • Loading branch information
MrJake222 authored May 19, 2024
1 parent 5941969 commit f1f3bd6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/rp2_common/pico_multicore/multicore.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,23 @@ void multicore_reset_core1() {
*power_off_set = PSM_FRCE_OFF_PROC1_BITS;
while (!(*power_off & PSM_FRCE_OFF_PROC1_BITS)) tight_loop_contents();

// Allow for the fact that the caller may have already enabled the FIFO IRQ for their
// own purposes (expecting FIFO content after core 1 is launched). We must disable
// the IRQ during the handshake, then restore afterwards.
bool enabled = irq_is_enabled(SIO_IRQ_PROC0);
irq_set_enabled(SIO_IRQ_PROC0, false);

// Bring core 1 back out of reset. It will drain its own mailbox FIFO, then push
// a 0 to our mailbox to tell us it has done this.
*power_off_clr = PSM_FRCE_OFF_PROC1_BITS;

// check the pushed value
uint32_t value = multicore_fifo_pop_blocking();
assert(value == 0);
(void) value; // silence warning

// restore interrupt state
irq_set_enabled(SIO_IRQ_PROC0, enabled);
}

void multicore_launch_core1_with_stack(void (*entry)(void), uint32_t *stack_bottom, size_t stack_size_bytes) {
Expand Down

0 comments on commit f1f3bd6

Please sign in to comment.