Skip to content

Commit 0451b8f

Browse files
committed
add rcc::Resets
1 parent 25724cb commit 0451b8f

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

src/crc32.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//! to calculate. This operation stalls the AHB bus for that time.
99
1010
use crate::pac::{CRC, RCC};
11-
use crate::rcc::Enable;
11+
use crate::rcc::{Enable, Reset};
1212
use core::mem::MaybeUninit;
1313
use core::ptr::copy_nonoverlapping;
1414

@@ -25,6 +25,7 @@ impl Crc32 {
2525
let rcc = &(*RCC::ptr());
2626
// enable CRC clock.
2727
CRC::enable(rcc);
28+
CRC::reset(rcc);
2829
}
2930

3031
let mut new = Self { periph: crc };

src/gpio.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ macro_rules! gpio {
667667
/// GPIO
668668
pub mod $gpiox {
669669
use crate::pac::{$GPIOX, RCC};
670-
use crate::rcc::Enable;
670+
use crate::rcc::{Enable, Reset};
671671
use super::{
672672
Floating, Input,
673673
};
@@ -690,6 +690,7 @@ macro_rules! gpio {
690690

691691
// Enable clock.
692692
$GPIOX::enable(rcc);
693+
$GPIOX::reset(rcc);
693694
}
694695
Parts {
695696
$(

src/serial.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
use core::fmt;
2020
use core::marker::PhantomData;
2121

22-
use crate::rcc::Enable;
22+
use crate::rcc;
2323
use embedded_hal::blocking;
2424
use embedded_hal::prelude::*;
2525
use embedded_hal::serial;
@@ -591,6 +591,7 @@ where
591591

592592
// Enable clock.
593593
USART::enable(rcc);
594+
USART::reset(rcc);
594595
}
595596

596597
let pclk_freq = USART::pclk_freq(&clocks);
@@ -1183,7 +1184,7 @@ mod private {
11831184
}
11841185

11851186
// Implemented by all USART instances
1186-
pub trait Instance: private::Sealed + Enable {
1187+
pub trait Instance: private::Sealed + rcc::Enable + rcc::Reset {
11871188
#[doc(hidden)]
11881189
fn ptr() -> *const uart_base::RegisterBlock;
11891190
#[doc(hidden)]

src/spi.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use crate::gpio::gpioi;
2424
use crate::gpio::{gpioa, gpiob, gpioc};
2525

2626
use crate::pac::{spi1, RCC, SPI1, SPI2};
27-
use crate::rcc::Enable;
27+
use crate::rcc;
2828

2929
#[cfg(feature = "spi3")]
3030
use crate::pac::SPI3;
@@ -379,7 +379,9 @@ mod private {
379379
}
380380

381381
// Implemented by all SPI instances
382-
pub trait Instance: private::Sealed + Deref<Target = spi1::RegisterBlock> + Enable {
382+
pub trait Instance:
383+
private::Sealed + Deref<Target = spi1::RegisterBlock> + rcc::Enable + rcc::Reset
384+
{
383385
#[doc(hidden)]
384386
fn pclk_freq(clocks: &Clocks) -> Hertz;
385387
}
@@ -431,6 +433,7 @@ where
431433
// NOTE(unsafe) this reference will only be used for atomic writes with no side effects.
432434
let rcc = &(*RCC::ptr());
433435
SPI::enable(rcc);
436+
SPI::reset(rcc);
434437
}
435438

436439
Spi { spi, pins }.init(mode, freq, SPI::pclk_freq(&clocks))

0 commit comments

Comments
 (0)