Provide a way for a peripheral to query its clock frequency

Currently this looks up the frequency in the global singleton that must
be initialized by the per-chip RCC implementation. At present, this is
only done for the L0 family of chips.
This commit is contained in:
Ulf Lilleengen
2021-06-11 09:19:02 +02:00
parent 85f172dd93
commit 952f525af5
6 changed files with 44 additions and 28 deletions

View File

@ -37,7 +37,6 @@ pub struct Spi<'d, T: Instance> {
impl<'d, T: Instance> Spi<'d, T> {
pub fn new<F>(
pclk: Hertz,
_peri: impl Unborrow<Target = T> + 'd,
sck: impl Unborrow<Target = impl SckPin<T>>,
mosi: impl Unborrow<Target = impl MosiPin<T>>,
@ -60,6 +59,7 @@ impl<'d, T: Instance> Spi<'d, T> {
let mosi = mosi.degrade();
let miso = miso.degrade();
let pclk = T::frequency();
let br = Self::compute_baud_rate(pclk, freq.into());
unsafe {