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>
impl Crc<B32>
Sourcepub fn new_32bit(rcu: &mut Rcu, crc: Crc, poly: u32, config: CrcConfig) -> Self
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.
Sourcepub fn write_32bit(&mut self, data: u32)
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.
Sourcepub fn read_32bit(&self) -> u32
pub fn read_32bit(&self) -> u32
Reads the current accumulated CRC result.
Sourcepub fn reset_with(&mut self, seed: u32)
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>
impl Crc<B16>
Sourcepub fn new_16bit(rcu: &mut Rcu, crc: Crc, poly: u16, config: CrcConfig) -> Self
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.
Sourcepub fn write_16bit(&mut self, data: u16)
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.
Sourcepub fn read_16bit(&self) -> u16
pub fn read_16bit(&self) -> u16
Reads the current accumulated CRC result.
Sourcepub fn reset_with(&mut self, seed: u16)
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>
impl Crc<B8>
Sourcepub fn new_8bit(rcu: &mut Rcu, crc: Crc, poly: u8, config: CrcConfig) -> Self
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.
Sourcepub fn write_8bit(&mut self, data: u8)
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.
Sourcepub fn reset_with(&mut self, seed: u8)
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>
impl Crc<B7>
Sourcepub fn new_7bit(rcu: &mut Rcu, crc: Crc, poly: u8, config: CrcConfig) -> Self
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.
Sourcepub fn write_7bit(&mut self, data: u8)
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.
Sourcepub fn reset_with(&mut self, seed: u8)
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.