Struct gd32vf103_hal::crc::Crc[][src]

pub struct Crc { /* fields omitted */ }

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

impl Send for Crc

impl !Sync for Crc

impl Unpin for Crc

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.