aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Salzedo <[email protected]>2021-09-27 10:46:09 -0700
committerJoshua Salzedo <[email protected]>2021-09-27 10:46:09 -0700
commite36d4f460a74ce9cfb55975aa9a382ed53231aca (patch)
treeecdc3a2d0e48f0391e626579ec99e11175790896
parent43ad28b9f9b25f2b7369be33dfd1f7db5d34e330 (diff)
Fix variable names in crc_v2/v3.
removed `reclaim` in crc_v1. used write instead of modify. renamed `init` to `reset` in crc_v1.
-rw-r--r--embassy-stm32/src/crc/v1.rs10
-rw-r--r--embassy-stm32/src/crc/v2v3.rs26
2 files changed, 15 insertions, 21 deletions
diff --git a/embassy-stm32/src/crc/v1.rs b/embassy-stm32/src/crc/v1.rs
index 8431c07f6..fc6d6945d 100644
--- a/embassy-stm32/src/crc/v1.rs
+++ b/embassy-stm32/src/crc/v1.rs
@@ -22,12 +22,12 @@ impl Crc {
22 let mut instance = Self { 22 let mut instance = Self {
23 _peripheral: peripheral, 23 _peripheral: peripheral,
24 }; 24 };
25 instance.init(); 25 instance.reset();
26 instance 26 instance
27 } 27 }
28 28
29 /// Resets the CRC unit to default value (0xFFFF_FFFF) 29 /// Resets the CRC unit to default value (0xFFFF_FFFF)
30 pub fn init(&mut self) { 30 pub fn reset(&mut self) {
31 unsafe { PAC_CRC.cr().write(|w| w.set_reset(true)) }; 31 unsafe { PAC_CRC.cr().write(|w| w.set_reset(true)) };
32 } 32 }
33 33
@@ -51,10 +51,4 @@ impl Crc {
51 unsafe { PAC_CRC.dr().read() } 51 unsafe { PAC_CRC.dr().read() }
52 } 52 }
53 53
54 /// Reclaims the CRC peripheral.
55 pub fn release(self) -> CRC {
56 CRC::disable();
57
58 self._peripheral
59 }
60} 54}
diff --git a/embassy-stm32/src/crc/v2v3.rs b/embassy-stm32/src/crc/v2v3.rs
index 91c24215c..78334d6cf 100644
--- a/embassy-stm32/src/crc/v2v3.rs
+++ b/embassy-stm32/src/crc/v2v3.rs
@@ -99,7 +99,7 @@ impl Crc {
99 99
100 // configure CR components 100 // configure CR components
101 // (reverse I/O, polysize, poly) 101 // (reverse I/O, polysize, poly)
102 PAC_CRC.cr().modify(|w| { 102 PAC_CRC.cr().write(|w| {
103 // configure reverse output 103 // configure reverse output
104 w.set_rev_out(match self._config.reverse_out { 104 w.set_rev_out(match self._config.reverse_out {
105 true => vals::RevOut::REVERSED, 105 true => vals::RevOut::REVERSED,
@@ -144,33 +144,33 @@ impl Crc {
144 unsafe { PAC_CRC.dr().read() } 144 unsafe { PAC_CRC.dr().read() }
145 } 145 }
146 /// Feeds a halfword into the CRC peripheral. Returns the computed checksum. 146 /// Feeds a halfword into the CRC peripheral. Returns the computed checksum.
147 pub fn feed_halfword(&mut self, byte: u16) -> u32 { 147 pub fn feed_halfword(&mut self, halfword: u16) -> u32 {
148 unsafe { 148 unsafe {
149 PAC_CRC.dr16().write_value(byte as u32); 149 PAC_CRC.dr16().write_value(halfword as u32);
150 PAC_CRC.dr().read() 150 PAC_CRC.dr().read()
151 } 151 }
152 } 152 }
153 /// Feeds an slice of halfwords into the CRC peripheral. Returns the computed checksum. 153 /// Feeds an slice of halfwords into the CRC peripheral. Returns the computed checksum.
154 pub fn feed_halfwords(&mut self, bytes: &[u16]) -> u32 { 154 pub fn feed_halfwords(&mut self, halfwords: &[u16]) -> u32 {
155 for byte in bytes { 155 for halfword in halfwords {
156 unsafe { 156 unsafe {
157 PAC_CRC.dr16().write_value(*byte as u32); 157 PAC_CRC.dr16().write_value(*halfword as u32);
158 } 158 }
159 } 159 }
160 unsafe { PAC_CRC.dr().read() } 160 unsafe { PAC_CRC.dr().read() }
161 } 161 }
162 /// Feeds a halfword into the CRC peripheral. Returns the computed checksum. 162 /// Feeds a words into the CRC peripheral. Returns the computed checksum.
163 pub fn feed_word(&mut self, byte: u32) -> u32 { 163 pub fn feed_word(&mut self, word: u32) -> u32 {
164 unsafe { 164 unsafe {
165 PAC_CRC.dr().write_value(byte as u32); 165 PAC_CRC.dr().write_value(word as u32);
166 PAC_CRC.dr().read() 166 PAC_CRC.dr().read()
167 } 167 }
168 } 168 }
169 /// Feeds an slice of halfwords into the CRC peripheral. Returns the computed checksum. 169 /// Feeds an slice of words into the CRC peripheral. Returns the computed checksum.
170 pub fn feed_words(&mut self, bytes: &[u32]) -> u32 { 170 pub fn feed_words(&mut self, words: &[u32]) -> u32 {
171 for byte in bytes { 171 for word in words {
172 unsafe { 172 unsafe {
173 PAC_CRC.dr().write_value(*byte as u32); 173 PAC_CRC.dr().write_value(*word as u32);
174 } 174 }
175 } 175 }
176 unsafe { PAC_CRC.dr().read() } 176 unsafe { PAC_CRC.dr().read() }