Skip to content

Commit 7f5be23

Browse files
authored
Merge pull request #102 from jannic-dev-forks/rp2040-hal-0-10
Update rp2040-hal to v0.10
2 parents a366c2c + b7d5974 commit 7f5be23

File tree

6 files changed

+166
-92
lines changed

6 files changed

+166
-92
lines changed

Cargo.lock

Lines changed: 91 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ version = "0.7.0"
1111
# Useful Cortex-M specific functions (e.g. SysTick)
1212
cortex-m = "0.7"
1313
# The Raspberry Pi Pico BSP
14-
rp-pico = { version = "0.8", default-features = false, features = [
14+
rp-pico = { version = "0.9", default-features = false, features = [
1515
"rt",
1616
"critical-section-impl",
1717
"rom-func-cache"
1818
] }
1919
# The Raspberry Pi RP2040 HAL (so we can turn defmt on)
20-
rp2040-hal = { version = "0.9", features = [ "defmt" ] }
20+
rp2040-hal = { version = "0.10", features = [ "defmt" ] }
2121
# Cortex-M run-time (or start-up) code
2222
cortex-m-rt = "0.7"
2323
# The BIOS to OS API

src/i2s.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ pub fn init(pio: super::pac::PIO1, resets: &mut super::pac::RESETS) -> Player {
163163

164164
let samples_installed = pio.install(&samples_program.program).unwrap();
165165
let (mut samples_sm, _sample_rx_fifo, pio_tx_fifo) =
166-
rp_pico::hal::pio::PIOBuilder::from_program(samples_installed)
166+
rp_pico::hal::pio::PIOBuilder::from_installed_program(samples_installed)
167167
.buffers(rp_pico::hal::pio::Buffers::RxTx)
168168
.out_pins(26, 1) // Data is GPIO26
169169
.in_pin_base(25)

src/main.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ fn main() -> ! {
370370
reset_dma_engine(&mut pp);
371371

372372
// Reset the spinlocks.
373-
pp.SIO.spinlock[31].reset();
373+
pp.SIO.spinlock(31).reset();
374374

375375
paint_stacks();
376376
check_stacks();
@@ -539,14 +539,16 @@ fn stuff_running(p: &mut pac::Peripherals) -> bool {
539539
// Look at scratch register 7 and see what we left ourselves. If it's zero,
540540
// this was a full clean boot-up. If it's 0xDEADC0DE, this means we were
541541
// running and Core 0 restarted without restarting everything else.
542-
let scratch = p.WATCHDOG.scratch7.read().bits();
542+
let scratch = p.WATCHDOG.scratch7().read().bits();
543543
defmt::info!("WD Scratch is 0x{:08x}", scratch);
544544
if scratch == 0xDEADC0DE {
545545
// we need a hard reset
546546
true
547547
} else {
548548
// set the marker so we know Core 0 has booted up
549-
p.WATCHDOG.scratch7.write(|w| unsafe { w.bits(0xDEADC0DE) });
549+
p.WATCHDOG
550+
.scratch7()
551+
.write(|w| unsafe { w.bits(0xDEADC0DE) });
550552
false
551553
}
552554
}
@@ -555,12 +557,11 @@ fn stuff_running(p: &mut pac::Peripherals) -> bool {
555557
/// next boot.
556558
fn clear_scratch() {
557559
let p = unsafe { pac::Peripherals::steal() };
558-
p.WATCHDOG.scratch7.write(|w| unsafe { w.bits(0) });
560+
p.WATCHDOG.scratch7().write(|w| unsafe { w.bits(0) });
559561
}
560562

561563
/// Do a full watchdog reboot
562564
fn watchdog_reboot() -> ! {
563-
use embedded_hal::watchdog::WatchdogEnable;
564565
clear_scratch();
565566
if let Some(hw) = HARDWARE.lock().as_mut() {
566567
hw.watchdog
@@ -730,10 +731,10 @@ fn paint_stacks() {
730731

731732
/// Reset the DMA Peripheral.
732733
fn reset_dma_engine(pp: &mut pac::Peripherals) {
733-
pp.RESETS.reset.modify(|_r, w| w.dma().set_bit());
734+
pp.RESETS.reset().modify(|_r, w| w.dma().set_bit());
734735
cortex_m::asm::nop();
735-
pp.RESETS.reset.modify(|_r, w| w.dma().clear_bit());
736-
while pp.RESETS.reset_done.read().dma().bit_is_clear() {}
736+
pp.RESETS.reset().modify(|_r, w| w.dma().clear_bit());
737+
while pp.RESETS.reset_done().read().dma().bit_is_clear() {}
737738
}
738739

739740
/// Measure how much stack space remains unused.
@@ -843,7 +844,7 @@ impl Hardware {
843844
// pin 25 to track render loop timing. This avoids trying to 'move' the pin
844845
// over to Core 1.
845846
let _pico_led = hal_pins.gpio25.into_push_pull_output();
846-
let raw_i2c = hal::i2c::I2C::i2c1(
847+
let raw_i2c = hal::i2c::I2C::i2c1_with_external_pull_up(
847848
i2c,
848849
{
849850
let mut pin = hal_pins.gpio14.reconfigure();

src/multicore.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,11 @@ pub fn launch_core1_with_stack(
7272
) {
7373
defmt::debug!("Resetting CPU1...");
7474

75-
psm.frce_off.modify(|_, w| w.proc1().set_bit());
76-
while !psm.frce_off.read().proc1().bit_is_set() {
75+
psm.frce_off().modify(|_, w| w.proc1().set_bit());
76+
while !psm.frce_off().read().proc1().bit_is_set() {
7777
cortex_m::asm::nop();
7878
}
79-
psm.frce_off.modify(|_, w| w.proc1().clear_bit());
79+
psm.frce_off().modify(|_, w| w.proc1().clear_bit());
8080

8181
defmt::debug!("Setting up stack...");
8282

@@ -106,7 +106,7 @@ pub fn launch_core1_with_stack(
106106
0,
107107
0,
108108
1,
109-
ppb.vtor.read().bits() as usize as u32,
109+
ppb.vtor().read().bits() as usize as u32,
110110
stack_ptr as usize as u32,
111111
// Have to add 1 to convert from an array pointer to a thumb instruction pointer
112112
(CORE1_ENTRY_FUNCTION.as_ptr() as usize as u32) + 1,

0 commit comments

Comments
 (0)