From 512172179a1db0810b69e927eedbae6d2ce5d677 Mon Sep 17 00:00:00 2001 From: 9names <60134748+9names@users.noreply.github.com> Date: Tue, 27 Jul 2021 09:31:19 +1000 Subject: [PATCH] Add unsafe blocks around write_with_zero calls (#68) The newer version of svd2rust used in the PAC marks write_with_zero calls as unsafe, where the old one did not. This PR wraps the only 2 calls instances of this in the HAL with unsafe blocks to fix the compile errors. --- rp2040-hal/src/clocks/macros.rs | 4 +++- rp2040-hal/src/pwm.rs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/rp2040-hal/src/clocks/macros.rs b/rp2040-hal/src/clocks/macros.rs index 1b03f63..31033ea 100644 --- a/rp2040-hal/src/clocks/macros.rs +++ b/rp2040-hal/src/clocks/macros.rs @@ -27,7 +27,9 @@ macro_rules! clocks { /// Exchanges CLOCKS block against Self. pub fn new(mut clocks_block: CLOCKS) -> Self { // Disable resus that may be enabled from previous software - clocks_block.clk_sys_resus_ctrl.write_with_zero(|w| w); + unsafe { + clocks_block.clk_sys_resus_ctrl.write_with_zero(|w| w); + } let shared_clocks = ShareableClocks::new(&mut clocks_block); ClocksManager { diff --git a/rp2040-hal/src/pwm.rs b/rp2040-hal/src/pwm.rs index 2c4ef83..0b26fdd 100644 --- a/rp2040-hal/src/pwm.rs +++ b/rp2040-hal/src/pwm.rs @@ -93,7 +93,9 @@ impl $PXi { pad.gpio[self.pin].write(|w| w.ie().set_bit()); pad.gpio[self.pin].write(|w| w.od().clear_bit()); - io.gpio[self.pin].gpio_ctrl.write_with_zero(|w| w.funcsel().pwm_a_0()); + unsafe { + io.gpio[self.pin].gpio_ctrl.write_with_zero(|w| w.funcsel().pwm_a_0()); + } } fn cc(&self) -> &pac::$pwmx::ch::CC {