diff --git a/CHANGELOG.md b/CHANGELOG.md index b392951..e4f6636 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - PWM output on complementary channels only for single channel timers (TIM16 + TIM17) - impl embedded_hal_1::spi::SpiBus for SPI - impl embedded_hal_1::digital traits for Pins +- impl core::{Deref, DerefMut} for Rcc ### Fixed diff --git a/src/rcc.rs b/src/rcc.rs index b396ad6..3a38b00 100644 --- a/src/rcc.rs +++ b/src/rcc.rs @@ -1,5 +1,6 @@ use crate::pac::RCC; use crate::time::Hertz; +use core::ops::{Deref, DerefMut}; /// Extension trait that sets up the `RCC` peripheral pub trait RccExt { @@ -45,6 +46,20 @@ pub struct Rcc { pub(crate) regs: RCC, } +impl Deref for Rcc { + type Target = RCC; + + fn deref(&self) -> &Self::Target { + &self.regs + } +} + +impl DerefMut for Rcc { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.regs + } +} + pub enum HSEBypassMode { /// Not bypassed: for crystals NotBypassed,