Sdio {
//github.com/ Create and enable the Sdio device
- pub fn new(sdio: SDIO, pins: PINS, clocks: &Clocks) -> Self {
- unsafe {
- // Enable and reset the sdio peripheral, it's the same bit position for both registers
- SDIO::enable_unchecked();
- SDIO::reset_unchecked();
- }
+ pub fn new(sdio: SDIO, pins: PINS, rcc: &mut Rcc) -> Self {
+ // Enable and reset the sdio peripheral, it's the same bit position for both registers
+ SDIO::enable(rcc);
+ SDIO::reset(rcc);
// Configure clock
sdio.clkcr().write(|w| {
@@ -196,7 +194,7 @@ impl Sdio {
sdio,
bw: PINS::BUSWIDTH,
card: None,
- clock: clocks.sysclk(),
+ clock: rcc.clocks.sysclk(),
};
// Make sure card is powered off
diff --git a/src/serial.rs b/src/serial.rs
index 4ddc53ea..fe5e6c35 100644
--- a/src/serial.rs
+++ b/src/serial.rs
@@ -29,7 +29,7 @@ use crate::gpio::{self, PushPull};
use crate::pac;
-use crate::rcc::{self, Clocks};
+use crate::rcc::{self, Rcc};
pub mod dma;
use crate::dma::{
@@ -218,21 +218,21 @@ pub trait SerialExt: Sized + Instance {
self,
pins: (impl Into>, impl Into>),
config: impl Into,
- clocks: &Clocks,
+ rcc: &mut Rcc,
) -> Result, config::InvalidConfig>;
fn tx(
self,
tx_pin: impl Into>,
config: impl Into,
- clocks: &Clocks,
+ rcc: &mut Rcc,
) -> Result, config::InvalidConfig>;
fn rx(
self,
rx_pin: impl Into>,
config: impl Into,
- clocks: &Clocks,
+ rcc: &mut Rcc,
) -> Result, config::InvalidConfig>;
}
@@ -244,9 +244,9 @@ impl Serial {
impl Into>,
),
config: impl Into,
- clocks: &Clocks,
+ rcc: &mut Rcc,
) -> Result {
- Self::_new(uart, (Some(pins.0), Some(pins.1)), config, clocks)
+ Self::_new(uart, (Some(pins.0), Some(pins.1)), config, rcc)
}
fn _new(
uart: USART,
@@ -255,18 +255,16 @@ impl Serial {
Option>>,
),
config: impl Into,
- clocks: &Clocks,
+ rcc: &mut Rcc,
) -> Result {
use self::config::*;
let config = config.into();
- unsafe {
- // Enable clock.
- USART::enable_unchecked();
- USART::reset_unchecked();
- }
+ // Enable clock.
+ USART::enable(rcc);
+ USART::reset(rcc);
- let pclk_freq = USART::clock(clocks).raw();
+ let pclk_freq = USART::clock(&rcc.clocks).raw();
let baud = config.baudrate.0;
if !USART::RB::IRDA && config.irda != IrdaMode::None {
@@ -668,25 +666,25 @@ impl SerialExt for UART {
self,
pins: (impl Into>, impl Into>),
config: impl Into,
- clocks: &Clocks,
+ rcc: &mut Rcc,
) -> Result, config::InvalidConfig> {
- Serial::new(self, pins, config, clocks)
+ Serial::new(self, pins, config, rcc)
}
fn tx(
self,
tx_pin: impl Into>,
config: impl Into,
- clocks: &Clocks,
+ rcc: &mut Rcc,
) -> Result, config::InvalidConfig> {
- Serial::tx(self, tx_pin, config, clocks)
+ Serial::tx(self, tx_pin, config, rcc)
}
fn rx(
self,
rx_pin: impl Into>,
config: impl Into,
- clocks: &Clocks,
+ rcc: &mut Rcc,
) -> Result, config::InvalidConfig> {
- Serial::rx(self, rx_pin, config, clocks)
+ Serial::rx(self, rx_pin, config, rcc)
}
}
@@ -695,13 +693,13 @@ impl Serial {
usart: UART,
tx_pin: impl Into>,
config: impl Into,
- clocks: &Clocks,
+ rcc: &mut Rcc,
) -> Result, config::InvalidConfig> {
Self::_new(
usart,
(Some(tx_pin), None::