Skip to content

Commit

Permalink
bump to rp2040-pac next gen
Browse files Browse the repository at this point in the history
  • Loading branch information
ithinuel committed Jul 23, 2023
1 parent 6600e44 commit f7d139d
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion rp2040-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ embedded-dma = "0.2.0"
fugit = "0.3.6"
itertools = { version = "0.10.1", default-features = false }
nb = "1.0"
rp2040-pac = "0.4.0"
rp2040-pac = { version = "0.4.0", features = ["critical-section"] }
paste = "1.0"
pio = "0.2.0"
rp2040-hal-macros = { version = "0.1.0", path = "../rp2040-hal-macros" }
Expand Down
4 changes: 2 additions & 2 deletions rp2040-hal/src/adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ impl<'a, Word> AdcFifo<'a, Word> {
pub fn is_over(&mut self) -> bool {
let over = self.adc.device.fcs.read().over().bit();
if over {
self.adc.device.fcs.modify(|_, w| w.over().set_bit());
self.adc.device.fcs.modify(|_, w| w.over().clear_bit_by_one());
}
over
}
Expand All @@ -548,7 +548,7 @@ impl<'a, Word> AdcFifo<'a, Word> {
pub fn is_under(&mut self) -> bool {
let under = self.adc.device.fcs.read().under().bit();
if under {
self.adc.device.fcs.modify(|_, w| w.under().set_bit());
self.adc.device.fcs.modify(|_, w| w.under().clear_bit_by_one());
}
under
}
Expand Down
16 changes: 8 additions & 8 deletions rp2040-hal/src/gpio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,10 +444,10 @@ impl<I: PinId, F: func::Function, P: PullType> Pin<I, F, P> {
pub fn get_drive_strength(&self) -> OutputDriveStrength {
use pac::pads_bank0::gpio::DRIVE_A;
match self.id.pad_ctrl().read().drive().variant() {
DRIVE_A::_2MA => OutputDriveStrength::TwoMilliAmps,
DRIVE_A::_4MA => OutputDriveStrength::FourMilliAmps,
DRIVE_A::_8MA => OutputDriveStrength::EightMilliAmps,
DRIVE_A::_12MA => OutputDriveStrength::TwelveMilliAmps,
DRIVE_A::_2M_A => OutputDriveStrength::TwoMilliAmps,
DRIVE_A::_4M_A => OutputDriveStrength::FourMilliAmps,
DRIVE_A::_8M_A => OutputDriveStrength::EightMilliAmps,
DRIVE_A::_12M_A => OutputDriveStrength::TwelveMilliAmps,
}
}

Expand All @@ -456,10 +456,10 @@ impl<I: PinId, F: func::Function, P: PullType> Pin<I, F, P> {
pub fn set_drive_strength(&mut self, strength: OutputDriveStrength) {
use pac::pads_bank0::gpio::DRIVE_A;
let variant = match strength {
OutputDriveStrength::TwoMilliAmps => DRIVE_A::_2MA,
OutputDriveStrength::FourMilliAmps => DRIVE_A::_4MA,
OutputDriveStrength::EightMilliAmps => DRIVE_A::_8MA,
OutputDriveStrength::TwelveMilliAmps => DRIVE_A::_12MA,
OutputDriveStrength::TwoMilliAmps => DRIVE_A::_2M_A,
OutputDriveStrength::FourMilliAmps => DRIVE_A::_4M_A,
OutputDriveStrength::EightMilliAmps => DRIVE_A::_8M_A,
OutputDriveStrength::TwelveMilliAmps => DRIVE_A::_12M_A,
};
self.id.pad_ctrl().modify(|_, w| w.drive().variant(variant))
}
Expand Down
12 changes: 6 additions & 6 deletions rp2040-hal/src/gpio/pin/pin_sealed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,12 @@ macro_rules! accessor_fns {
DynBankId::Qspi => unsafe {
let qspi = &*pac::IO_QSPI::PTR;
match pin.num {
0 => core::mem::transmute(&qspi.gpio_qspisclk.[<gpio_ $reg:lower>]),
1 => core::mem::transmute(&qspi.gpio_qspiss.[<gpio_ $reg:lower>]),
2 => core::mem::transmute(&qspi.gpio_qspisd0.[<gpio_ $reg:lower>]),
3 => core::mem::transmute(&qspi.gpio_qspisd1.[<gpio_ $reg:lower>]),
4 => core::mem::transmute(&qspi.gpio_qspisd2.[<gpio_ $reg:lower>]),
5 => core::mem::transmute(&qspi.gpio_qspisd3.[<gpio_ $reg:lower>]),
0 => core::mem::transmute(&qspi.gpio_qspisclk().[<gpio_ $reg:lower>]),
1 => core::mem::transmute(&qspi.gpio_qspiss().[<gpio_ $reg:lower>]),
2 => core::mem::transmute(&qspi.gpio_qspisd0().[<gpio_ $reg:lower>]),
3 => core::mem::transmute(&qspi.gpio_qspisd1().[<gpio_ $reg:lower>]),
4 => core::mem::transmute(&qspi.gpio_qspisd2().[<gpio_ $reg:lower>]),
5 => core::mem::transmute(&qspi.gpio_qspisd3().[<gpio_ $reg:lower>]),
_ => unreachable!("Invalid QSPI bank pin number."),
}
},
Expand Down
2 changes: 1 addition & 1 deletion rp2040-hal/src/pio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ impl<SM: ValidStateMachine, State> StateMachine<SM, State> {
/// Check if the current instruction is stalled.
pub fn stalled(&self) -> bool {
// Safety: read only access without side effect
unsafe { self.sm.sm().sm_execctrl.read().exec_stalled().bits() }
unsafe { self.sm.sm().sm_execctrl.read().exec_stalled().bit() }
}

/// Drain Tx fifo.
Expand Down
2 changes: 1 addition & 1 deletion rp2040-hal/src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ macro_rules! impl_alarm {
timer.intf.as_ptr(),
$armed_bit_mask,
);
timer.intr.write_with_zero(|w| w.$int_alarm().set_bit());
timer.intr.write_with_zero(|w| w.$int_alarm().clear_bit_by_one());
}
}

Expand Down
8 changes: 4 additions & 4 deletions rp2040-hal/src/usb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ impl Inner {
// Next packet will be on DATA1 so clear pid_0 so it gets flipped by next buf config
self.ctrl_dpram.ep_buffer_control[0].modify(|_, w| w.pid_0().clear_bit());
// clear setup request flag
self.ctrl_reg.sie_status.write(|w| w.setup_rec().set_bit());
self.ctrl_reg.sie_status.write(|w| w.setup_rec().clear_bit_by_one());

// clear any out standing out flag e.g. in case a zlp got discarded
self.ctrl_reg.buff_status.write(|w| unsafe { w.bits(2) });
Expand Down Expand Up @@ -537,7 +537,7 @@ impl UsbBusTrait for UsbBus {
let mut inner = self.inner.borrow(cs).borrow_mut();

// clear reset flag
inner.ctrl_reg.sie_status.write(|w| w.bus_reset().set_bit());
inner.ctrl_reg.sie_status.write(|w| w.bus_reset().clear_bit_by_one());
inner
.ctrl_reg
.buff_status
Expand Down Expand Up @@ -639,10 +639,10 @@ impl UsbBusTrait for UsbBus {
return PollResult::Reset;
} else if buff_status == 0 && ints.setup_req().bit_is_clear() {
if ints.dev_suspend().bit_is_set() {
inner.ctrl_reg.sie_status.write(|w| w.suspended().set_bit());
inner.ctrl_reg.sie_status.write(|w| w.suspended().clear_bit_by_one());
return PollResult::Suspend;
} else if ints.dev_resume_from_host().bit_is_set() {
inner.ctrl_reg.sie_status.write(|w| w.resume().set_bit());
inner.ctrl_reg.sie_status.write(|w| w.resume().clear_bit_by_one());
return PollResult::Resume;
}
return PollResult::None;
Expand Down

0 comments on commit f7d139d

Please sign in to comment.