1use crate::pac::{CRC, RCC};
4use crate::rcc::Enable;
5
6pub trait CrcExt {
8 #[allow(clippy::wrong_self_convention, clippy::new_ret_no_self)]
10 fn new(self, rcc: &mut RCC) -> Crc;
11}
12
13impl CrcExt for CRC {
14 fn new(self, rcc: &mut RCC) -> Crc {
15 CRC::enable(rcc);
16
17 Crc { crc: self }
18 }
19}
20
21pub struct Crc {
23 crc: CRC,
24}
25
26impl Crc {
27 pub fn read(&self) -> u32 {
28 self.crc.dr().read().bits()
29 }
30
31 pub fn write(&mut self, val: u32) {
32 self.crc.dr().write(|w| w.dr().set(val));
33 }
34
35 pub fn reset(&self) {
36 self.crc.cr().write(|w| w.reset().set_bit());
37 cortex_m::asm::nop();
40 }
41}