From e36d4f460a74ce9cfb55975aa9a382ed53231aca Mon Sep 17 00:00:00 2001 From: Joshua Salzedo Date: Mon, 27 Sep 2021 10:46:09 -0700 Subject: [PATCH] Fix variable names in crc_v2/v3. removed `reclaim` in crc_v1. used write instead of modify. renamed `init` to `reset` in crc_v1. --- embassy-stm32/src/crc/v1.rs | 10 ++-------- embassy-stm32/src/crc/v2v3.rs | 26 +++++++++++++------------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/embassy-stm32/src/crc/v1.rs b/embassy-stm32/src/crc/v1.rs index 8431c07f..fc6d6945 100644 --- a/embassy-stm32/src/crc/v1.rs +++ b/embassy-stm32/src/crc/v1.rs @@ -22,12 +22,12 @@ impl Crc { let mut instance = Self { _peripheral: peripheral, }; - instance.init(); + instance.reset(); instance } /// Resets the CRC unit to default value (0xFFFF_FFFF) - pub fn init(&mut self) { + pub fn reset(&mut self) { unsafe { PAC_CRC.cr().write(|w| w.set_reset(true)) }; } @@ -51,10 +51,4 @@ impl Crc { unsafe { PAC_CRC.dr().read() } } - /// Reclaims the CRC peripheral. - pub fn release(self) -> CRC { - CRC::disable(); - - self._peripheral - } } diff --git a/embassy-stm32/src/crc/v2v3.rs b/embassy-stm32/src/crc/v2v3.rs index 91c24215..78334d6c 100644 --- a/embassy-stm32/src/crc/v2v3.rs +++ b/embassy-stm32/src/crc/v2v3.rs @@ -99,7 +99,7 @@ impl Crc { // configure CR components // (reverse I/O, polysize, poly) - PAC_CRC.cr().modify(|w| { + PAC_CRC.cr().write(|w| { // configure reverse output w.set_rev_out(match self._config.reverse_out { true => vals::RevOut::REVERSED, @@ -144,33 +144,33 @@ impl Crc { 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 { + pub fn feed_halfword(&mut self, halfword: u16) -> u32 { unsafe { - PAC_CRC.dr16().write_value(byte as u32); + PAC_CRC.dr16().write_value(halfword as u32); PAC_CRC.dr().read() } } /// 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 { + pub fn feed_halfwords(&mut self, halfwords: &[u16]) -> u32 { + for halfword in halfwords { unsafe { - PAC_CRC.dr16().write_value(*byte as u32); + PAC_CRC.dr16().write_value(*halfword 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 { + /// Feeds a words into the CRC peripheral. Returns the computed checksum. + pub fn feed_word(&mut self, word: u32) -> u32 { unsafe { - PAC_CRC.dr().write_value(byte as u32); + PAC_CRC.dr().write_value(word as u32); PAC_CRC.dr().read() } } - /// 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 { + /// Feeds an slice of words into the CRC peripheral. Returns the computed checksum. + pub fn feed_words(&mut self, words: &[u32]) -> u32 { + for word in words { unsafe { - PAC_CRC.dr().write_value(*byte as u32); + PAC_CRC.dr().write_value(*word as u32); } } unsafe { PAC_CRC.dr().read() }