Skip to content

Commit a496153

Browse files
authored
Merge pull request #71: Fix CI: source of PACs matrix + clippy satisfaction
2 parents 6aef6a2 + dc767a8 commit a496153

File tree

17 files changed

+43
-50
lines changed

17 files changed

+43
-50
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Checkout sources
1515
uses: actions/checkout@v2
1616
- id: pacs
17-
run: echo "::set-output name=pac_matrix::$(ls ./pac --indicator-style=none | grep atsam | cut -c 3- | jq -ncR '[inputs]')"
17+
run: echo "::set-output name=pac_matrix::$(grep -o '^sam\w*' hal/Cargo.toml | uniq | jq -ncR '[inputs]')"
1818
- id: boards
1919
run: echo "::set-output name=board_matrix::$(ls ./boards --indicator-style=none | jq -ncR '[inputs]')"
2020
- id: features

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
- Examples now build and link again
2020
- [#62] Remove ambiguous reexports from `src/serial/mod.rs`.
2121
- TWIHS: Fix issue with clock frequency calculation.
22+
- Fix CI: source of PACs matrix + clippy satisfaction
2223

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

hal/src/afec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This implementation presumes that VREFP is 3.3V.
2020
# use hal::efc::*;
2121
# use hal::afec::*;
2222
# use hal::fugit::RateExtU32;
23-
# let pac = hal::pac::Peripherals::take().unwrap();
23+
# let pac = unsafe{ hal::pac::Peripherals::steal() };
2424
# let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
2525
2626
let banka = BankA::new(pac.PIOA, &mut mck, &slck, BankConfiguration::default());

hal/src/clocks/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ For example, if we want to configure the [`MainClock`]:
2828
use atsamx7x_hal as hal;
2929
use hal::fugit::RateExtU32;
3030
31-
let pac = hal::pac::Peripherals::take().unwrap();
31+
let pac = unsafe{hal::pac::Peripherals::steal()};
3232
let clocks = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into());
3333
let mainck = clocks
3434
.mainck
@@ -72,7 +72,7 @@ use hal::efc::{Efc, VddioLevel};
7272
use hal::fugit::RateExtU32;
7373
7474
// configure the clock hierarchy
75-
let pac = hal::pac::Peripherals::take().unwrap();
75+
let pac = unsafe{hal::pac::Peripherals::steal()};
7676
let clocks = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into());
7777
let slck = clocks.slck.configure_external_normal();
7878
let mainck = clocks

hal/src/pio/bank.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl<B: PinBank> BankInterrupts<B> {
4242
/// # use hal::pio::*;
4343
/// # use hal::clocks::*;
4444
/// # use hal::efc::*;
45-
/// # let pac = hal::pac::Peripherals::take().unwrap();
45+
/// # let pac = unsafe{hal::pac::Peripherals::steal()};
4646
/// # let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
4747
/// let mut banka = BankA::new(pac.PIOA, &mut mck, &slck, BankConfiguration::default());
4848
/// for pin in banka.interrupts.iter() {

hal/src/pio/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ The below example configures [`Pin<PA11, Input>`] to trigger on
8686
# use hal::pio::*;
8787
# use hal::clocks::*;
8888
# use hal::efc::*;
89-
# let pac = hal::pac::Peripherals::take().unwrap();
89+
# let pac = unsafe{hal::pac::Peripherals::steal()};
9090
# let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
9191
9292
let banka = BankA::new(

hal/src/pio/reg.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ pub(in crate::pio) trait RegisterInterface {
150150
}
151151

152152
fn set_interrupt(&mut self, cfg: Option<InterruptType>) {
153-
if cfg == None {
153+
if cfg.is_none() {
154154
// Disable pin interrupt
155155
//
156156
// XXX The peripheral clock is not disabled because it
@@ -191,7 +191,7 @@ pub(in crate::pio) trait RegisterInterface {
191191
}
192192

193193
fn set_filter(&mut self, cfg: Option<InputFilter>) {
194-
if cfg == None {
194+
if cfg.is_none() {
195195
// disable the input filter
196196
self.reg().ifdr.write(|w| unsafe { w.bits(self.mask()) });
197197
} else {

hal/src/pwm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Refer to §51 for a full description of the PWM peripheral.
1717
# use hal::efc::*;
1818
# use hal::pwm::*;
1919
# use hal::fugit::RateExtU32;
20-
# let pac = hal::pac::Peripherals::take().unwrap();
20+
# let pac = unsafe{hal::pac::Peripherals::steal()};
2121
# let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
2222
use hal::ehal::PwmPin;
2323

hal/src/rtt.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ via [`Rtt::new_8192Hz`].
2323
# use hal::rtt::*;
2424
# use hal::fugit::RateExtU32;
2525
# use rtic_monotonic::*;
26-
# let pac = hal::pac::Peripherals::take().unwrap();
26+
# let pac = unsafe{hal::pac::Peripherals::steal()};
2727
# let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
2828
2929
let mono: Mono<100> = Rtt::new(pac.RTT, &slck, 100.Hz()).unwrap().into_monotonic();
@@ -37,7 +37,7 @@ or
3737
# use hal::rtt::*;
3838
# use hal::fugit::RateExtU32;
3939
# use rtic_monotonic::Monotonic;
40-
# let pac = hal::pac::Peripherals::take().unwrap();
40+
# let pac = unsafe{hal::pac::Peripherals::steal()};
4141
# let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
4242
4343
use hal::ehal::{blocking::delay::DelayMs, timer::{CountDown, Cancel}};
@@ -83,7 +83,7 @@ pub enum RttError {
8383
/// # use hal::efc::*;
8484
/// # use hal::rtt::*;
8585
/// # use hal::fugit::RateExtU32;
86-
/// # let pac = hal::pac::Peripherals::take().unwrap();
86+
/// # let pac = unsafe{hal::pac::Peripherals::steal()};
8787
/// # let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
8888
/// let rtt: Rtt<100> = Rtt::new(pac.RTT, &slck, 100.Hz()).unwrap();
8989
/// ```

hal/src/serial/spi.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Interrupt event management is handled by the [`event system`](crate::generics::e
2323
# use hal::serial::spi::*;
2424
# use hal::serial::ExtBpsU32;
2525
# use hal::fugit::ExtU32;
26-
# let pac = hal::pac::Peripherals::take().unwrap();
26+
# let pac = unsafe{hal::pac::Peripherals::steal()};
2727
# let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
2828
2929
let bankd = BankD::new(pac.PIOD, &mut mck, &slck, BankConfiguration::default());
@@ -203,18 +203,20 @@ pub struct SpiConfiguration {
203203
}
204204

205205
impl SpiConfiguration {
206-
/// Generates a default [`Spi`] configuration: test mode inactive.
207-
pub fn default() -> Self {
208-
SpiConfiguration { test_mode: false }
209-
}
210-
211206
/// [`SpiConfiguration::test_mode`] override.
212207
pub fn test_mode(mut self, bit: bool) -> Self {
213208
self.test_mode = bit;
214209
self
215210
}
216211
}
217212

213+
/// Generates a default [`Spi`] configuration: test mode inactive.
214+
impl Default for SpiConfiguration {
215+
fn default() -> Self {
216+
SpiConfiguration { test_mode: false }
217+
}
218+
}
219+
218220
/// SPI peripheral abstraction.
219221
pub struct Spi<M: SpiMeta> {
220222
meta: PhantomData<M>,
@@ -639,10 +641,7 @@ impl<'spi, M: SpiMeta> blocking::spi::Transactional<u8> for Client<'spi, M> {
639641

640642
/// Execute the provided transactions, deasserting the select line
641643
/// after the last transmitted word.
642-
fn exec<'a>(
643-
&mut self,
644-
operations: &mut [blocking::spi::Operation<'a, u8>],
645-
) -> Result<(), Self::Error> {
644+
fn exec(&mut self, operations: &mut [blocking::spi::Operation<u8>]) -> Result<(), Self::Error> {
646645
use blocking::spi::Operation;
647646

648647
let len = operations.len();

hal/src/serial/twi.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ implemented.
2020
# use hal::efc::*;
2121
# use hal::serial::twi::*;
2222
# use hal::fugit::RateExtU32;
23-
# let pac = hal::pac::Peripherals::take().unwrap();
23+
# let pac = unsafe{hal::pac::Peripherals::steal()};
2424
# let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
2525
let banka = BankA::new(pac.PIOA, &mut mck, &slck, BankConfiguration::default());
2626
@@ -367,10 +367,10 @@ enum TransactionalState {
367367
impl<M: TwiMeta> blocking::i2c::Transactional for Twi<M> {
368368
type Error = TwiError;
369369

370-
fn exec<'a>(
370+
fn exec(
371371
&mut self,
372372
address: u8,
373-
operations: &mut [blocking::i2c::Operation<'a>],
373+
operations: &mut [blocking::i2c::Operation],
374374
) -> Result<(), Self::Error> {
375375
let mut state = TransactionalState::Uninitialized;
376376

hal/src/serial/uart.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Interrupt event management is handled by the [`event system`](crate::generics::e
2626
# use hal::serial::uart::*;
2727
# use hal::serial::ExtBpsU32;
2828
# use hal::fugit::{ExtU32, RateExtU32};
29-
# let pac = hal::pac::Peripherals::take().unwrap();
29+
# let pac = unsafe{hal::pac::Peripherals::steal()};
3030
let clocks = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into());
3131
let slck = clocks.slck.configure_external_normal();
3232
let mainck = clocks

hal/src/serial/usart/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Mode support depends on what [`Pin`]s that are available for the
3232
# use hal::serial::usart::*;
3333
# use hal::serial::ExtBpsU32;
3434
# use hal::fugit::{ExtU32, RateExtU32};
35-
# let pac = hal::pac::Peripherals::take().unwrap();
35+
# let pac = unsafe{hal::pac::Peripherals::steal()};
3636
# let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
3737
use hal::generics::events::EventHandler;
3838
use hal::ehal::serial::{Read, Write};

hal/src/serial/usart/spi.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,7 @@ impl<M: UsartMeta, R: SpiRole> ehal::spi::FullDuplex<u8> for Spi<M, R> {
227227
impl<M: UsartMeta, R: SpiRole> blocking::spi::Transactional<u8> for Spi<M, R> {
228228
type Error = SpiError;
229229

230-
fn exec<'a>(
231-
&mut self,
232-
operations: &mut [blocking::spi::Operation<'a, u8>],
233-
) -> Result<(), Self::Error> {
230+
fn exec(&mut self, operations: &mut [blocking::spi::Operation<u8>]) -> Result<(), Self::Error> {
234231
use blocking::spi::Operation;
235232

236233
for o in operations.iter_mut() {

hal/src/tc/generate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ where
144144
// integer.
145145
//
146146
// Safe: driver was consumed in Channel::chain.
147-
let mut driver = unsafe { Channel::<M, J, _>::new::<Generate<C, DRIVER_FREQ_HZ>>() };
147+
let mut driver = unsafe { Channel::<M, J, _>::new() };
148148
// The 16-bit counter is incremented only at each positive
149149
// input clock edge. When chaining channels, this then results
150150
// in a static /2 prescaler. Refer to §50.6.2.

hal/src/tc/mod.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Refer to §50 for a full description on the capabilities offered by a [`Tc`].
2222
# use hal::efc::*;
2323
# use hal::tc::*;
2424
# use hal::fugit::ExtU32;
25-
# let pac = hal::pac::Peripherals::take().unwrap();
25+
# let pac = unsafe{hal::pac::Peripherals::steal()};
2626
# let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
2727
let banka = hal::pio::BankA::new(
2828
pac.PIOA,
@@ -54,7 +54,7 @@ counter.sample_freq(100.millis());
5454
# use hal::clocks::*;
5555
# use hal::efc::*;
5656
# use hal::tc::*;
57-
# let pac = hal::pac::Peripherals::take().unwrap();
57+
# let pac = unsafe{hal::pac::Peripherals::steal()};
5858
# let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
5959
let tc = Tc::new_tc0(pac.TC0, &mut mck);
6060
let driver = tc
@@ -80,7 +80,7 @@ let mono: Monotonic<Tc0, Ch1, Channel<Tc0, Ch0, Generate<HostClock, 12_000_000>>
8080
# use hal::clocks::*;
8181
# use hal::efc::*;
8282
# use hal::tc::*;
83-
# let pac = hal::pac::Peripherals::take().unwrap();
83+
# let pac = unsafe{hal::pac::Peripherals::steal()};
8484
# let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
8585
let tc = Tc::new_tc0(pac.TC0, &mut mck);
8686
let driver = tc
@@ -410,7 +410,7 @@ pub enum TcError {
410410
/// # use hal::clocks::*;
411411
/// # use hal::efc::*;
412412
/// # use hal::tc::*;
413-
/// # let pac = hal::pac::Peripherals::take().unwrap();
413+
/// # let pac = unsafe{hal::pac::Peripherals::steal()};
414414
/// # let (slck, mut mck) = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into()).por_state(&mut Efc::new(pac.EFC, VddioLevel::V3));
415415
/// let tc = Tc::new_tc0(pac.TC0, &mut mck);
416416
/// let ch = tc.channel_0.generate::<15_000_000>(&mck).unwrap();
@@ -452,7 +452,7 @@ impl<M: TcMeta, I: ChannelId, S: ChannelState> Channel<M, I, S> {
452452
///
453453
/// A [`Channel`] can modify hardware, but can be created without
454454
/// consuming a corresponding singleton.
455-
const unsafe fn new<So: ChannelState>() -> Self {
455+
const unsafe fn new() -> Self {
456456
Self {
457457
_meta: PhantomData,
458458
_id: PhantomData,
@@ -601,9 +601,9 @@ impl<M: TcMeta> Tc<M> {
601601
// Safe: the TC block has been consumed.
602602
let mut tc = Self {
603603
_meta: PhantomData,
604-
channel_0: unsafe { Channel::new::<Inactive>() },
605-
channel_1: unsafe { Channel::new::<Inactive>() },
606-
channel_2: unsafe { Channel::new::<Inactive>() },
604+
channel_0: unsafe { Channel::new() },
605+
channel_1: unsafe { Channel::new() },
606+
channel_2: unsafe { Channel::new() },
607607
};
608608

609609
// Ensure channels are disabled.

hal/src/usb.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extensively tested, and should be considered unstable at the moment.
1616
# use hal::efc::*;
1717
# use hal::usb::*;
1818
# use hal::fugit::RateExtU32;
19-
# let pac = hal::pac::Peripherals::take().unwrap();
19+
# let pac = unsafe{hal::pac::Peripherals::steal()};
2020
# let clocks = Tokens::new((pac.PMC, pac.SUPC, pac.UTMI), &pac.WDT.into());
2121
# let slck = clocks.slck.configure_external_normal();
2222
# let mainck = clocks
@@ -108,7 +108,7 @@ impl Endpoints {
108108
fn find_free_endpoint(&self) -> UsbResult<usize> {
109109
// start with 1 because 0 is reserved for Control
110110
for idx in 1..NUM_ENDPOINTS {
111-
if self.ep_config[idx] == None {
111+
if self.ep_config[idx].is_none() {
112112
return Ok(idx);
113113
}
114114
}
@@ -124,7 +124,7 @@ impl Endpoints {
124124
max_packet_size: u16,
125125
_interval: u8,
126126
) -> UsbResult<EndpointAddress> {
127-
if idx != 0 && self.ep_config[idx] != None {
127+
if idx != 0 && self.ep_config[idx].is_some() {
128128
return Err(UsbError::EndpointOverflow);
129129
}
130130

@@ -221,11 +221,7 @@ impl Inner {
221221
#[inline(always)]
222222
fn write_fifo(&self, ep: usize, buf: &[u8]) {
223223
unsafe {
224-
core::ptr::copy_nonoverlapping(
225-
buf.as_ptr() as *const u8,
226-
self.fifo_addr(ep) as *mut u8,
227-
buf.len(),
228-
);
224+
core::ptr::copy_nonoverlapping(buf.as_ptr(), self.fifo_addr(ep) as *mut u8, buf.len());
229225
}
230226
}
231227

@@ -235,7 +231,7 @@ impl Inner {
235231
unsafe {
236232
core::ptr::copy_nonoverlapping(
237233
self.fifo_addr(ep) as *const u8,
238-
buf.as_mut_ptr() as *mut u8,
234+
buf.as_mut_ptr(),
239235
buf.len(),
240236
);
241237
}
@@ -431,7 +427,7 @@ impl Inner {
431427
const DEVISR_PEPS_MASK: u32 = 0x3ff000;
432428
const DEVISR_PEPS_OFFSET: u8 = 12;
433429
for ep in BitIter::from((dev_isr.bits() & DEVISR_PEPS_MASK) >> DEVISR_PEPS_OFFSET) {
434-
let sr = self.reg().deveptisr_ctrl_mode()[ep as usize].read();
430+
let sr = self.reg().deveptisr_ctrl_mode()[ep].read();
435431

436432
// SETUP packet?
437433
if sr.rxstpi().bit_is_set() {

0 commit comments

Comments
 (0)