Struct stm32f4xx_hal::crc32::Crc32

source ·
pub struct Crc32 { /* private fields */ }
Expand description

A handle to a HAL CRC32 peripheral

Implementations§

source§

impl Crc32

source

pub fn new(crc: CRC) -> Self

Create a new Crc32 HAL peripheral

source

pub fn init(&mut self)

Reset the internal CRC32 state to the default value (0xFFFF_FFFF)

source

pub fn update(&mut self, data: &[u32]) -> u32

Feed words into the CRC engine.

The resulting calculated CRC (including this and prior data since the last call to init() is returned.

source

pub fn update_bytes(&mut self, data: &[u8]) -> u32

Feed bytes into the CRC engine.

The resulting calculated CRC (including this and prior data since the last call to init() is returned.

NOTE: Each four-byte chunk will be copied into a scratch buffer. This is done to ensure alignment of the data (the CRC engine only processes full words at a time). If the number of bytes passed in are not a multiple of four, the MOST significant bytes of the remaining word will be zeroes.

This should be taken into consideration if attempting to feed bytes across multiple parts (that spurious zeroes will be inserted)! To avoid this, only feed multiples of 4 bytes in before the “final” part of the message.

Example: Given the following 7 bytes:

[0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77]

The following two words will be fed into the CRC engine:

  1. 0x4433_2211
  2. 0x0077_6655
source

pub fn release(self) -> CRC

Consume the HAL peripheral, returning the PAC peripheral

Auto Trait Implementations§

§

impl Freeze for Crc32

§

impl RefUnwindSafe for Crc32

§

impl Send for Crc32

§

impl !Sync for Crc32

§

impl Unpin for Crc32

§

impl UnwindSafe for Crc32

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>,

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.