Skip to content

Commit bc8aff8

Browse files
committed
Don't mention NVIC in the examples.
Because in RISC-V mode the interrupt controller is the Xh3irq. Unless its the vector-table example, which only works on Arm currently.
1 parent 8041088 commit bc8aff8

File tree

5 files changed

+36
-13
lines changed

5 files changed

+36
-13
lines changed

rp235x-hal-examples/src/bin/gpio_irq_example.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,16 @@ fn main() -> ! {
125125
GLOBAL_PINS.borrow(cs).replace(Some((led, in_pin)));
126126
});
127127

128-
// Unmask the IO_BANK0 IRQ so that the NVIC interrupt controller
129-
// will jump to the interrupt function when the interrupt occurs.
130-
// We do this last so that the interrupt can't go off while
131-
// it is in the middle of being configured
128+
// Unmask the IRQ for I/O Bank 0 so that the RP2350's interrupt controller
129+
// (NVIC in Arm mode, or Xh3irq in RISC-V mode) will jump to the interrupt
130+
// function when the interrupt occurs. We do this last so that the interrupt
131+
// can't go off while it is in the middle of being configured
132132
unsafe {
133133
hal::arch::interrupt_unmask(hal::pac::Interrupt::IO_IRQ_BANK0);
134+
}
135+
136+
// Enable interrupts on this core
137+
unsafe {
134138
hal::arch::interrupt_enable();
135139
}
136140

rp235x-hal-examples/src/bin/i2c_async.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,16 @@ async fn demo() {
9494
clocks.system_clock.freq(),
9595
);
9696

97-
// Unmask the interrupt in the NVIC to let the core wake up & enter the interrupt handler.
98-
// Each core has its own NVIC so these needs to executed from the core where the IRQ are
99-
// expected.
97+
// Unmask the IRQ for I2C0. We do this after the driver init so that the
98+
// interrupt can't go off while it is in the middle of being configured
10099
unsafe {
101100
hal::arch::interrupt_unmask(hal::pac::Interrupt::I2C0_IRQ);
102-
hal::arch::interrupt_enable();
103101
}
104102

103+
// Enable interrupts on this core
104+
unsafe {
105+
hal::arch::interrupt_enable();
106+
}
105107
// Asynchronously write three bytes to the I²C device with 7-bit address 0x2C
106108
i2c.write(0x76u8, &[1, 2, 3]).await.unwrap();
107109

rp235x-hal-examples/src/bin/i2c_async_cancelled.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,14 @@ async fn demo() {
9696
clocks.system_clock.freq(),
9797
);
9898

99-
// Unmask the interrupt in the NVIC to let the core wake up & enter the interrupt handler.
99+
// Unmask the IRQ for I2C0. We do this after the driver init so that the
100+
// interrupt can't go off while it is in the middle of being configured
100101
unsafe {
101102
hal::arch::interrupt_unmask(hal::pac::Interrupt::I2C0_IRQ);
103+
}
104+
105+
// Enable interrupts on this core
106+
unsafe {
102107
hal::arch::interrupt_enable();
103108
}
104109

rp235x-hal-examples/src/bin/powman_test.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,15 @@ fn main() -> ! {
124124
print_aot_status(&mut powman);
125125
_ = writeln!(&GLOBAL_UART, "AOT time: 0x{:016x}", powman.aot_get_time());
126126

127+
// Unmask the IRQ for POWMAN's Timer. We do this after the driver init so
128+
// that the interrupt can't go off while it is in the middle of being
129+
// configured
130+
unsafe {
131+
hal::arch::interrupt_unmask(hal::pac::Interrupt::POWMAN_IRQ_TIMER);
132+
}
133+
134+
// Enable interrupts on this core
127135
unsafe {
128-
hal::arch::interrupt_unmask(pac::Interrupt::POWMAN_IRQ_TIMER);
129136
hal::arch::interrupt_enable();
130137
}
131138

rp235x-hal-examples/src/bin/pwm_irq_input.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,16 @@ fn main() -> ! {
140140
GLOBAL_PINS.borrow(cs).replace(Some((led, input_pin, pwm)));
141141
});
142142

143-
// Unmask the IO_BANK0 IRQ so that the interrupt controller will jump to the
144-
// interrupt function when the interrupt occurs. We do this last so that the
145-
// interrupt can't go off while it is in the middle of being configured
143+
// Unmask the IRQ for I/O Bank 0 so that the RP2350's interrupt controller
144+
// (NVIC in Arm mode, or Xh3irq in RISC-V mode) will jump to the interrupt
145+
// function when the interrupt occurs. We do this last so that the interrupt
146+
// can't go off while it is in the middle of being configured
146147
unsafe {
147148
hal::arch::interrupt_unmask(hal::pac::Interrupt::IO_IRQ_BANK0);
149+
}
150+
151+
// Enable interrupts on this core
152+
unsafe {
148153
hal::arch::interrupt_enable();
149154
}
150155

0 commit comments

Comments
 (0)