use crate::pac::CRC as PAC_CRC;
use crate::peripherals::CRC;
use crate::{Peri, rcc};
pub struct Crc<'d> {
_peri: Peri<'d, CRC>,
}
impl<'d> Crc<'d> {
pub fn new(peripheral: Peri<'d, CRC>) -> Self {
rcc::enable_and_reset::<CRC>();
let mut instance = Self { _peri: peripheral };
instance.reset();
instance
}
pub fn reset(&mut self) {
PAC_CRC.cr().write(|w| w.set_reset(true));
}
pub fn feed_word(&mut self, word: u32) -> u32 {
PAC_CRC.dr().write_value(word);
self.read()
}
pub fn feed_words(&mut self, words: &[u32]) -> u32 {
for word in words {
PAC_CRC.dr().write_value(*word);
}
self.read()
}
pub fn read(&self) -> u32 {
PAC_CRC.dr().read()
}
}