Skip to content

Commit 8c88ace

Browse files
authored
fix: Remove GCLK from can::Dependencies (#919)
#919
1 parent d38de76 commit 8c88ace

2 files changed

Lines changed: 16 additions & 38 deletions

File tree

boards/atsame54_xpro/examples/mcan.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,8 @@ mod app {
161161

162162
let (pclk_can1, gclk0) = clock::pclk::Pclk::enable(tokens.pclks.can1, gclk0);
163163

164-
let (dependencies, _gclk0) = hal::can::Dependencies::new(
165-
gclk0,
166-
pclk_can1,
167-
clocks.ahbs.can1,
168-
can1_rx,
169-
can1_tx,
170-
device.can1,
171-
);
164+
let dependencies =
165+
hal::can::Dependencies::new(pclk_can1, clocks.ahbs.can1, can1_rx, can1_tx, device.can1);
172166

173167
let mut can =
174168
mcan::bus::CanConfigurable::new(375.kHz(), dependencies, ctx.local.can_memory).unwrap();

hal/src/peripherals/can.rs

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,17 @@ use crate::{
1515
ahb::{AhbClk, AhbId},
1616
pclk::{Pclk, PclkId, PclkSourceId},
1717
types::Can0,
18-
Source,
1918
},
2019
gpio::*,
21-
typelevel::{Decrement, Increment, Sealed},
20+
typelevel::Sealed,
2221
};
2322
use atsamd_hal_macros::hal_cfg;
2423

2524
#[hal_cfg("can1")]
2625
use crate::clock::v2::types::Can1;
2726

28-
use mcan_core::fugit::HertzU32;
2927
use mcan_core::CanId;
28+
use mcan_core::fugit::HertzU32;
3029

3130
/// Struct enclosing all the dependencies required to bootstrap `ID` instance of
3231
/// MCAN.
@@ -47,37 +46,22 @@ impl<ID: PclkId + AhbId, PS: PclkSourceId, RX, TX, CAN> Dependencies<ID, PS, RX,
4746
///
4847
/// This struct implements [`mcan_core::Dependencies`] trait, making it
4948
/// possible to construct an instance of `mcan::bus::CanConfigurable`.
50-
pub fn new<S>(
51-
gclk: S,
52-
pclk: Pclk<ID, PS>,
53-
ahbclk: AhbClk<ID>,
54-
rx: RX,
55-
tx: TX,
56-
can: CAN,
57-
) -> (Self, S::Inc)
58-
where
59-
S: Source + Increment,
60-
{
61-
(
62-
Self {
63-
pclk,
64-
host_freq: gclk.freq(),
65-
ahbclk,
66-
rx,
67-
tx,
68-
can,
69-
},
70-
gclk.inc(),
71-
)
49+
pub fn new(pclk: Pclk<ID, PS>, ahbclk: AhbClk<ID>, rx: RX, tx: TX, can: CAN) -> Self {
50+
let host_freq = pclk.freq();
51+
Self {
52+
pclk,
53+
host_freq,
54+
ahbclk,
55+
rx,
56+
tx,
57+
can,
58+
}
7259
}
7360
/// Destroy an instance of `Dependencies` struct.
7461
///
7562
/// Releases all enclosed objects back to the user.
7663
#[allow(clippy::type_complexity)]
77-
pub fn free<S>(self, gclk: S) -> (Pclk<ID, PS>, HertzU32, AhbClk<ID>, RX, TX, CAN, S::Dec)
78-
where
79-
S: Source + Decrement,
80-
{
64+
pub fn free(self) -> (Pclk<ID, PS>, HertzU32, AhbClk<ID>, RX, TX, CAN) {
8165
let Self {
8266
pclk,
8367
host_freq,
@@ -86,7 +70,7 @@ impl<ID: PclkId + AhbId, PS: PclkSourceId, RX, TX, CAN> Dependencies<ID, PS, RX,
8670
tx,
8771
can,
8872
} = self;
89-
(pclk, host_freq, ahbclk, rx, tx, can, gclk.dec())
73+
(pclk, host_freq, ahbclk, rx, tx, can)
9074
}
9175
}
9276

0 commit comments

Comments
 (0)