Struct stm32_hal2::crc::Config
source · pub struct Config { /* private fields */ }
Expand description
CRC unit configuration.
Implementations§
source§impl Config
impl Config
sourcepub const fn new() -> Self
pub const fn new() -> Self
Creates the Config struct with the default configuration of the STM32H7 CRC unit:
0x04C1_1DB7
polynomial0xFFFF_FFFF
initial value- Bits not reflected
0
output XOR
This configuration is the MPEG-2 CRC.
sourcepub const fn polynomial(self, poly: Polynomial) -> Self
pub const fn polynomial(self, poly: Polynomial) -> Self
Set the polynomial.
sourcepub const fn initial_value(self, initial: u32) -> Self
pub const fn initial_value(self, initial: u32) -> Self
Set the initial value of the CRC. The CRC unit will only use the needed
bits to match the polynomial; the default initial value 0xFFFF_FFFF
will actually write 0x7F
in the case of a 7-bit CRC, for example.
sourcepub const fn reverse_input(self, reverse: Option<BitReversal>) -> Self
pub const fn reverse_input(self, reverse: Option<BitReversal>) -> Self
Set how to reverse the bits of the input. None
means no reversal.
sourcepub const fn reverse_output(self, reverse: bool) -> Self
pub const fn reverse_output(self, reverse: bool) -> Self
Set whether to reverse the bits of the output.
sourcepub fn reflect(self, reflect: bool) -> Self
pub fn reflect(self, reflect: bool) -> Self
Set whether to reflect the CRC. When enabled, reflection is
BitReversal::Byte
and output reversal enabled. This is simply
a convenience function as many CRC algorithms call for this.
sourcepub const fn output_xor(self, output_xor: u32) -> Self
pub const fn output_xor(self, output_xor: u32) -> Self
Set the value to XOR the output with. Automatically masked to the proper size.