diff --git a/embassy-stm32/src/crc/mod.rs b/embassy-stm32/src/crc/mod.rs index 597e7cf3a..70c87ab53 100644 --- a/embassy-stm32/src/crc/mod.rs +++ b/embassy-stm32/src/crc/mod.rs @@ -3,4 +3,4 @@ #[cfg_attr(crc_v3, path = "v2.rs")] mod _version; -pub use _version::Crc; \ No newline at end of file +pub use _version::Crc; diff --git a/embassy-stm32/src/crc/v2.rs b/embassy-stm32/src/crc/v2.rs index 3336d3f75..7705b4285 100644 --- a/embassy-stm32/src/crc/v2.rs +++ b/embassy-stm32/src/crc/v2.rs @@ -33,11 +33,9 @@ impl CrcConfig { pub fn new( reverse_in: CrcInputReverseConfig, reverse_out: bool, - #[cfg(crc_v3)] - poly_size: PolySize, + #[cfg(crc_v3)] poly_size: PolySize, crc_init_value: u32, - #[cfg(crc_v3)] - crc_poly: u32, + #[cfg(crc_v3)] crc_poly: u32, ) -> Result { // As Per RM0091 (DocID018940 Rev 9), Even polynomials are not supported. #[cfg(crc_v3)] @@ -94,7 +92,7 @@ impl Crc { // Init CRC value PAC_CRC.init().write_value(self._config.crc_init_value); #[cfg(crc_v3)] - PAC_CRC.pol().write_value(self._config.crc_poly); + PAC_CRC.pol().write_value(self._config.crc_poly); // configure CR components // (reverse I/O, polysize, poly) @@ -113,7 +111,7 @@ impl Crc { }); // configure the polynomial. #[cfg(crc_v3)] - w.set_polysize(match self._config.poly_size { + w.set_polysize(match self._config.poly_size { PolySize::Width7 => vals::Polysize::POLYSIZE7, PolySize::Width8 => vals::Polysize::POLYSIZE8, PolySize::Width16 => vals::Polysize::POLYSIZE16, @@ -136,11 +134,11 @@ impl Crc { /// Feeds an slice of bytes into the CRC peripheral. Returns the computed checksum. pub fn feed_bytes(&mut self, bytes: &[u8]) -> u32 { for byte in bytes { - unsafe { PAC_CRC.dr8().write_value(*byte as u32); } - } - unsafe { - PAC_CRC.dr().read() + unsafe { + PAC_CRC.dr8().write_value(*byte as u32); + } } + unsafe { PAC_CRC.dr().read() } } /// Feeds a halfword into the CRC peripheral. Returns the computed checksum. pub fn feed_halfword(&mut self, byte: u16) -> u32 { @@ -152,11 +150,11 @@ impl Crc { /// Feeds an slice of halfwords into the CRC peripheral. Returns the computed checksum. pub fn feed_halfwords(&mut self, bytes: &[u16]) -> u32 { for byte in bytes { - unsafe { PAC_CRC.dr16().write_value(*byte as u32); } - } - unsafe { - PAC_CRC.dr().read() + unsafe { + PAC_CRC.dr16().write_value(*byte as u32); + } } + unsafe { PAC_CRC.dr().read() } } /// Feeds a halfword into the CRC peripheral. Returns the computed checksum. pub fn feed_word(&mut self, byte: u32) -> u32 { @@ -168,10 +166,10 @@ impl Crc { /// Feeds an slice of halfwords into the CRC peripheral. Returns the computed checksum. pub fn feed_words(&mut self, bytes: &[u32]) -> u32 { for byte in bytes { - unsafe { PAC_CRC.dr().write_value(*byte as u32); } - } - unsafe { - PAC_CRC.dr().read() + unsafe { + PAC_CRC.dr().write_value(*byte as u32); + } } + unsafe { PAC_CRC.dr().read() } } }