Skip to main content

Crc

Struct Crc 

Source
pub struct Crc<PS> { /* private fields */ }
Expand description

Hardware CRC calculation unit.

PS (B32/B16/B8/B7) fixes the polynomial width for the lifetime of the value, selected by which constructor built it.

Construction does not seed the result: call reset_with before the first write.

Implementations§

Source§

impl Crc<B32>

Source

pub fn new_32bit(rcu: &mut Rcu, crc: Crc, poly: u32, config: CrcConfig) -> Self

Enables the peripheral’s clock and configures a 32-bit polynomial.

Source

pub fn write_32bit(&mut self, data: u32)

Feeds one 32-bit word into the running CRC, combining it with the current result rather than replacing it.

Source

pub fn read_32bit(&self) -> u32

Reads the current accumulated CRC result.

Source

pub fn reset_with(&mut self, seed: u32)

Sets IDATA to seed and pulses RST, so the result reads back as seed until the next write_32bit.

Source§

impl Crc<B16>

Source

pub fn new_16bit(rcu: &mut Rcu, crc: Crc, poly: u16, config: CrcConfig) -> Self

Enables the peripheral’s clock and configures a 16-bit polynomial.

Source

pub fn write_16bit(&mut self, data: u16)

Feeds one 16-bit word into the running CRC, combining it with the current result rather than replacing it.

Source

pub fn read_16bit(&self) -> u16

Reads the current accumulated CRC result.

Source

pub fn reset_with(&mut self, seed: u16)

Sets IDATA to seed and pulses RST, so the result reads back as seed until the next write_16bit.

Source§

impl Crc<B8>

Source

pub fn new_8bit(rcu: &mut Rcu, crc: Crc, poly: u8, config: CrcConfig) -> Self

Enables the peripheral’s clock and configures an 8-bit polynomial.

Source

pub fn write_8bit(&mut self, data: u8)

Feeds one byte into the running CRC, combining it with the current result rather than replacing it.

Source

pub fn read_8bit(&self) -> u8

Reads the current accumulated CRC result.

Source

pub fn reset_with(&mut self, seed: u8)

Sets IDATA to seed and pulses RST, so the result reads back as seed until the next write_8bit.

Source§

impl Crc<B7>

Source

pub fn new_7bit(rcu: &mut Rcu, crc: Crc, poly: u8, config: CrcConfig) -> Self

Enables the peripheral’s clock and configures a 7-bit polynomial.

Source

pub fn write_7bit(&mut self, data: u8)

Feeds the low 7 bits of data into the running CRC, combining them with the current result rather than replacing it. The top bit is ignored by hardware.

Source

pub fn read_7bit(&self) -> u8

Reads the current accumulated CRC result, in the low 7 bits.

Source

pub fn reset_with(&mut self, seed: u8)

Sets IDATA to seed and pulses RST, so the result reads back as seed until the next write_7bit.

Source§

impl<PS> Crc<PS>

Source

pub fn read(&self) -> u32

Reads the whole DATA register, not cut down to the polynomial width.

Source

pub fn release(self, rcu: &mut Rcu) -> Crc

Returns the peripheral with its clock stopped.

Source

pub fn set_fdata(&mut self, fdata: u8)

Writes an arbitrary byte to the scratch FDATA register. Unrelated to the CRC calculation — hardware never reads or modifies it on its own.

Source

pub fn fdata(&self) -> u8

Reads back the byte last written with set_fdata.

Auto Trait Implementations§

§

impl<PS> !Sync for Crc<PS>

§

impl<PS> Freeze for Crc<PS>
where PhantomData<PS>: Freeze,

§

impl<PS> RefUnwindSafe for Crc<PS>

§

impl<PS> Send for Crc<PS>
where PhantomData<PS>: Send,

§

impl<PS> Unpin for Crc<PS>
where PhantomData<PS>: Unpin,

§

impl<PS> UnsafeUnpin for Crc<PS>

§

impl<PS> UnwindSafe for Crc<PS>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.