Skip to content

Commit

Permalink
[Fixes #72] All examples back to take()
Browse files Browse the repository at this point in the history
```
let pac = hal::pac::Peripherals::take().unwrap();
```
instead of
```
let pac = hal::pac::Peripherals::take().unwrap();
```
  • Loading branch information
michalfita committed Dec 23, 2023
1 parent 56ee0f9 commit 6552571
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 20 deletions.
11 changes: 7 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,24 @@

- [Integration](https://crates.io/crates/mcan-core) with the [`mcan`](https://crates.io/crates/mcan) crate.
- Implementation of blocking::i2c::Transactional trait from [embedded-hal](https://crates.io/crates/embedded-hal) for TWI device.
- Support for `critical-section` feature, falling down to PAC optional dependency.

### Changed
- Remove `rust-toolchain.toml` and control MSRV from .github/workflow/ files instead.
- Remove `rust-toolchain.toml` and control MSRV from `.github/workflow/` files instead.
- Update `cortex-m-rt` version in examples to `0.7.3`.
- Switched from AFE0_AD6 to AFE0_AD8 for the atsamv71_xult board ADC example code.
- The `rt` separated to don't act as part of chip selection feature anymore.

### Removed
- Huge generated source code for PACs removed, new location for them [`atsamx7x-pac`](/atsams-rs/atsamx7x-pac) (user side generated)

### Fixed
- Examples now build and link again
- Examples now build again again
- Examples now build and link again.
- Examples now build again again.
- [#62] Remove ambiguous reexports from `src/serial/mod.rs`.
- TWIHS: Fix issue with clock frequency calculation.
- Fix CI: source of PACs matrix + clippy satisfaction
- Fix CI: source of PACs matrix + clippy satisfaction.
- Fixes doctest use of `take()` which now require `critical-section`.

## [v0.4.2] 2022-11-06

Expand Down
4 changes: 2 additions & 2 deletions hal/src/clocks/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ For example, if we want to configure the [`MainClock`]:
use atsamx7x_hal as hal;
use hal::fugit::RateExtU32;
let pac = unsafe{hal::pac::Peripherals::steal()};
let pac = hal::pac::Peripherals::take().unwrap();
let clocks = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into());
let mainck = clocks
.mainck
Expand Down Expand Up @@ -72,7 +72,7 @@ use hal::efc::{Efc, VddioLevel};
use hal::fugit::RateExtU32;
// configure the clock hierarchy
let pac = unsafe{hal::pac::Peripherals::steal()};
let pac = hal::pac::Peripherals::take().unwrap();
let clocks = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into());
let slck = clocks.slck.configure_external_normal();
let mainck = clocks
Expand Down
2 changes: 1 addition & 1 deletion hal/src/pio/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl<B: PinBank> BankInterrupts<B> {
/// # use hal::pio::*;
/// # use hal::clocks::*;
/// # use hal::efc::*;
/// # let pac = unsafe{hal::pac::Peripherals::steal()};
/// # let pac = hal::pac::Peripherals::take().unwrap();
/// # let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
/// let mut banka = BankA::new(pac.PIOA, &mut mck, &slck, BankConfiguration::default());
/// for pin in banka.interrupts.iter() {
Expand Down
2 changes: 1 addition & 1 deletion hal/src/pio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ The below example configures [`Pin<PA11, Input>`] to trigger on
# use hal::pio::*;
# use hal::clocks::*;
# use hal::efc::*;
# let pac = unsafe{hal::pac::Peripherals::steal()};
# let pac = hal::pac::Peripherals::take().unwrap();
# let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
let banka = BankA::new(
Expand Down
6 changes: 3 additions & 3 deletions hal/src/rtt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ via [`Rtt::new_8192Hz`].
# use hal::rtt::*;
# use hal::fugit::RateExtU32;
# use rtic_monotonic::*;
# let pac = unsafe{hal::pac::Peripherals::steal()};
# let pac = hal::pac::Peripherals::take().unwrap();
# let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
let mono: Mono<100> = Rtt::new(pac.RTT, &slck, 100.Hz()).unwrap().into_monotonic();
Expand All @@ -37,7 +37,7 @@ or
# use hal::rtt::*;
# use hal::fugit::RateExtU32;
# use rtic_monotonic::Monotonic;
# let pac = unsafe{hal::pac::Peripherals::steal()};
# let pac = hal::pac::Peripherals::take().unwrap();
# let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
use hal::ehal::{blocking::delay::DelayMs, timer::{CountDown, Cancel}};
Expand Down Expand Up @@ -83,7 +83,7 @@ pub enum RttError {
/// # use hal::efc::*;
/// # use hal::rtt::*;
/// # use hal::fugit::RateExtU32;
/// # let pac = unsafe{hal::pac::Peripherals::steal()};
/// # let pac = hal::pac::Peripherals::take().unwrap();
/// # let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
/// let rtt: Rtt<100> = Rtt::new(pac.RTT, &slck, 100.Hz()).unwrap();
/// ```
Expand Down
2 changes: 1 addition & 1 deletion hal/src/serial/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Interrupt event management is handled by the [`event system`](crate::generics::e
# use hal::serial::spi::*;
# use hal::serial::ExtBpsU32;
# use hal::fugit::ExtU32;
# let pac = unsafe{hal::pac::Peripherals::steal()};
# let pac = hal::pac::Peripherals::take().unwrap();
# let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
let bankd = BankD::new(pac.PIOD, &mut mck, &slck, BankConfiguration::default());
Expand Down
2 changes: 1 addition & 1 deletion hal/src/serial/twi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ implemented.
# use hal::efc::*;
# use hal::serial::twi::*;
# use hal::fugit::RateExtU32;
# let pac = unsafe{hal::pac::Peripherals::steal()};
# let pac = hal::pac::Peripherals::take().unwrap();
# let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
let banka = BankA::new(pac.PIOA, &mut mck, &slck, BankConfiguration::default());
Expand Down
2 changes: 1 addition & 1 deletion hal/src/serial/uart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Interrupt event management is handled by the [`event system`](crate::generics::e
# use hal::serial::uart::*;
# use hal::serial::ExtBpsU32;
# use hal::fugit::{ExtU32, RateExtU32};
# let pac = unsafe{hal::pac::Peripherals::steal()};
# let pac = hal::pac::Peripherals::take().unwrap();
let clocks = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into());
let slck = clocks.slck.configure_external_normal();
let mainck = clocks
Expand Down
2 changes: 1 addition & 1 deletion hal/src/serial/usart/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Mode support depends on what [`Pin`]s that are available for the
# use hal::serial::usart::*;
# use hal::serial::ExtBpsU32;
# use hal::fugit::{ExtU32, RateExtU32};
# let pac = unsafe{hal::pac::Peripherals::steal()};
# let pac = hal::pac::Peripherals::take().unwrap();
# let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
use hal::generics::events::EventHandler;
use hal::ehal::serial::{Read, Write};
Expand Down
8 changes: 4 additions & 4 deletions hal/src/tc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Refer to §50 for a full description on the capabilities offered by a [`Tc`].
# use hal::efc::*;
# use hal::tc::*;
# use hal::fugit::ExtU32;
# let pac = unsafe{hal::pac::Peripherals::steal()};
# let pac = hal::pac::Peripherals::take().unwrap();
# let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
let banka = hal::pio::BankA::new(
pac.PIOA,
Expand Down Expand Up @@ -54,7 +54,7 @@ counter.sample_freq(100.millis());
# use hal::clocks::*;
# use hal::efc::*;
# use hal::tc::*;
# let pac = unsafe{hal::pac::Peripherals::steal()};
# let pac = hal::pac::Peripherals::take().unwrap();
# let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
let tc = Tc::new_tc0(pac.TC0, &mut mck);
let driver = tc
Expand All @@ -80,7 +80,7 @@ let mono: Monotonic<Tc0, Ch1, Channel<Tc0, Ch0, Generate<HostClock, 12_000_000>>
# use hal::clocks::*;
# use hal::efc::*;
# use hal::tc::*;
# let pac = unsafe{hal::pac::Peripherals::steal()};
# let pac = hal::pac::Peripherals::take().unwrap();
# let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
let tc = Tc::new_tc0(pac.TC0, &mut mck);
let driver = tc
Expand Down Expand Up @@ -410,7 +410,7 @@ pub enum TcError {
/// # use hal::clocks::*;
/// # use hal::efc::*;
/// # use hal::tc::*;
/// # let pac = unsafe{hal::pac::Peripherals::steal()};
/// # let pac = hal::pac::Peripherals::take().unwrap();
/// # let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
/// let tc = Tc::new_tc0(pac.TC0, &mut mck);
/// let ch = tc.channel_0.generate::<15_000_000>(&mck).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion hal/src/usb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ extensively tested, and should be considered unstable at the moment.
# use hal::efc::*;
# use hal::usb::*;
# use hal::fugit::RateExtU32;
# let pac = unsafe{hal::pac::Peripherals::steal()};
# let pac = hal::pac::Peripherals::take().unwrap();
# let clocks = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into());
# let slck = clocks.slck.configure_external_normal();
# let mainck = clocks
Expand Down

0 comments on commit 6552571

Please sign in to comment.