Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upate to rp2040-pac version 0.5.0 #662

Merged
merged 5 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,13 @@ jobs:
with:
crate: cargo-hack
- name: Test
run: cargo hack test --tests --target x86_64-unknown-linux-gnu --optional-deps --each-feature
run: cargo hack test -p rp2040-hal --tests --target x86_64-unknown-linux-gnu --optional-deps --each-feature --features critical-section-impl
- name: Test docs
run: cargo hack test --doc --target x86_64-unknown-linux-gnu --optional-deps --each-feature
run: cargo hack test -p rp2040-hal --doc --target x86_64-unknown-linux-gnu --optional-deps --each-feature --features critical-section-impl
- name: Test macros
run: cargo hack test -p rp2040-hal-macros --tests --target x86_64-unknown-linux-gnu --optional-deps --each-feature
- name: Test macro docs
run: cargo hack test -p rp2040-hal-macros --doc --target x86_64-unknown-linux-gnu --optional-deps --each-feature
- name: Clean
run: cargo clean
udeps:
Expand Down Expand Up @@ -72,7 +76,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
- uses: dtolnay/rust-toolchain@master
with:
toolchain: 1.63
target: thumbv6m-none-eabi
Expand Down
94 changes: 93 additions & 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.5.0", features = ["critical-section"] }
paste = "1.0"
pio = "0.2.0"
rp2040-hal-macros = { version = "0.1.0", path = "../rp2040-hal-macros" }
Expand Down Expand Up @@ -102,3 +102,95 @@ required-features = ["rt", "critical-section-impl"]
# adc_fifo_dma example uses cortex-m-rt::interrupt, need rt feature for that
name = "adc_fifo_dma"
required-features = ["rt", "critical-section-impl"]

[[example]]
name = "adc"
required-features = ["critical-section-impl"]

[[example]]
name = "adc_fifo_poll"
required-features = ["critical-section-impl"]

[[example]]
name = "blinky"
required-features = ["critical-section-impl"]

[[example]]
name = "dht11"
required-features = ["critical-section-impl"]

[[example]]
name = "gpio_in_out"
required-features = ["critical-section-impl"]

[[example]]
name = "i2c"
required-features = ["critical-section-impl"]

[[example]]
name = "lcd_display"
required-features = ["critical-section-impl"]

[[example]]
name = "mem_to_mem_dma"
required-features = ["critical-section-impl"]

[[example]]
name = "multicore_fifo_blink"
required-features = ["critical-section-impl"]

[[example]]
name = "multicore_polyblink"
required-features = ["critical-section-impl"]

[[example]]
name = "pio_blink"
required-features = ["critical-section-impl"]

[[example]]
name = "pio_dma"
required-features = ["critical-section-impl"]

[[example]]
name = "pio_proc_blink"
required-features = ["critical-section-impl"]

[[example]]
name = "pio_side_set"
required-features = ["critical-section-impl"]

[[example]]
name = "pio_synchronized"
required-features = ["critical-section-impl"]

[[example]]
name = "pwm_blink"
required-features = ["critical-section-impl"]

[[example]]
name = "rom_funcs"
required-features = ["critical-section-impl"]

[[example]]
name = "rosc_as_system_clock"
required-features = ["critical-section-impl"]

[[example]]
name = "spi"
required-features = ["critical-section-impl"]

[[example]]
name = "spi_dma"
required-features = ["critical-section-impl"]

[[example]]
name = "uart"
required-features = ["critical-section-impl"]

[[example]]
name = "uart_dma"
required-features = ["critical-section-impl"]

[[example]]
name = "watchdog"
required-features = ["critical-section-impl"]
10 changes: 8 additions & 2 deletions rp2040-hal/src/adc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,10 @@ 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 @@ -546,7 +549,10 @@ 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 @@ -445,10 +445,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 @@ -457,10 +457,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 @@ -62,12 +62,12 @@ macro_rules! accessor_fns {
DynBankId::Qspi => unsafe {
let qspi = &*$crate::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
4 changes: 3 additions & 1 deletion rp2040-hal/src/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,9 @@ 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
19 changes: 15 additions & 4 deletions rp2040-hal/src/usb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,9 @@ 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 @@ -536,7 +538,10 @@ 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 @@ -638,10 +643,16 @@ 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
Loading