Struct gd32vf103_hal::crc::Crc [−][src]
CRC module abstraction
Owns CRC_DATA
and CRC_CTL
.
Implementations
impl Crc
[src]
pub fn crc(crc: CRC, ahb: &mut AHB) -> Self
[src]
Take ownership of CRC and enable CRC clock.
To create struct Crc
, it’s need to pass the peripheral CRC
and a mutable
reference of AHB
peripheral bus. Get the ownership of CRC
from the device
peripheral struct pac::Peripherals
(may already exists in your code) as dp
then use dp.CRC
. To get AHB you need to constrain RCU
module using
dp.RCU.constrain()
, then use &mut rcu.ahb
to get its mutable reference.
Examples
Basic usage:
// Prepare CRC peripheral for calculation let crc = Crc::crc(dp.CRC, &mut rcu.ahb);
pub fn new_digest(self) -> Digest
[src]
Create new Digest struct for CRC calculation.
The underlying CRC buffer is cleaned to prepare for incoming values. Write
operations could be later performed using functions in Digest
. You may
refer to digest.write_u32(value)
for how to write the value for CRC
calculation.
Examples
Basic usage:
// Prepare CRC peripheral for calculation let crc = Crc::crc(dp.CRC, &mut rcu.ahb); // Create a Digest instance to write values for calculation let mut digest = crc.new_digest();
pub fn release(self, ahb: &mut AHB) -> CRC
[src]
Disable the CRC clock and release the peripheral.
The clock is switched off using AHB; you must provide a mutable referrence of AHB to release the CRC peripheral. After release, the peripheral is freed for further use.
Examples
Basic usage:
// Prepare CRC peripheral for calculation let crc = Crc::crc(dp.CRC, &mut rcu.ahb); // ... actual calculations with `crc` // Release the wrapper and get CRC peripheral back let crc = crc.release(&mut rcu.ahb);
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,