Start work on CRC_v1

This commit is contained in:
Joshua Salzedo 2021-09-26 16:29:22 -07:00
parent f8d833e0c5
commit e527892d89
No known key found for this signature in database
GPG key ID: C3D0EB484493B731
5 changed files with 27 additions and 0 deletions

View file

@ -0,0 +1,4 @@
#[cfg_attr(crc_v1, path = "v1.rs")]
#[cfg_attr(crc_v2, path = "v2.rs")]
#[cfg_attr(crc_v3, path = "v3.rs")]
mod _version;

View file

@ -0,0 +1,21 @@
use crate::pac::{CRC as PAC_CRC, RCC};
use crate::peripherals::CRC;
use crate::rcc::sealed::RccPeripheral;
pub struct Crc {
_peripheral: CRC
}
impl Crc{
pub fn new(peripheral: CRC) -> Self{
// enable CRC clock in RCC.
CRC::enable();
// Reset CRC to default values.
CRC::reset();
Self { _peripheral: peripheral}
}
pub fn reset() {
unsafe { PAC_CRC.cr().modify(|w| w.set_reset(true)) };
}
}

View file

View file

View file

@ -49,6 +49,8 @@ pub mod sdmmc;
pub mod spi;
#[cfg(usart)]
pub mod usart;
#[cfg(crc)]
pub mod crc;
#[cfg(feature = "subghz")]
pub mod subghz;