aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Salzedo <[email protected]>2021-09-26 19:20:21 -0700
committerJoshua Salzedo <[email protected]>2021-09-26 19:20:21 -0700
commit7392e33ad563642453bde20c9d33120af6b7ccbb (patch)
treec03823fdc903a73bc4c202b39baa70742b9c365d
parente67af514e921b3b28b4c20a88554c4d7cbef7951 (diff)
cargo fmt
-rw-r--r--embassy-stm32/src/crc/mod.rs2
-rw-r--r--embassy-stm32/src/crc/v2.rs34
2 files changed, 17 insertions, 19 deletions
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 @@
3#[cfg_attr(crc_v3, path = "v2.rs")] 3#[cfg_attr(crc_v3, path = "v2.rs")]
4mod _version; 4mod _version;
5 5
6pub use _version::Crc; \ No newline at end of file 6pub 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 {
33 pub fn new( 33 pub fn new(
34 reverse_in: CrcInputReverseConfig, 34 reverse_in: CrcInputReverseConfig,
35 reverse_out: bool, 35 reverse_out: bool,
36 #[cfg(crc_v3)] 36 #[cfg(crc_v3)] poly_size: PolySize,
37 poly_size: PolySize,
38 crc_init_value: u32, 37 crc_init_value: u32,
39 #[cfg(crc_v3)] 38 #[cfg(crc_v3)] crc_poly: u32,
40 crc_poly: u32,
41 ) -> Result<Self, CrcConfigError> { 39 ) -> Result<Self, CrcConfigError> {
42 // As Per RM0091 (DocID018940 Rev 9), Even polynomials are not supported. 40 // As Per RM0091 (DocID018940 Rev 9), Even polynomials are not supported.
43 #[cfg(crc_v3)] 41 #[cfg(crc_v3)]
@@ -94,7 +92,7 @@ impl Crc {
94 // Init CRC value 92 // Init CRC value
95 PAC_CRC.init().write_value(self._config.crc_init_value); 93 PAC_CRC.init().write_value(self._config.crc_init_value);
96 #[cfg(crc_v3)] 94 #[cfg(crc_v3)]
97 PAC_CRC.pol().write_value(self._config.crc_poly); 95 PAC_CRC.pol().write_value(self._config.crc_poly);
98 96
99 // configure CR components 97 // configure CR components
100 // (reverse I/O, polysize, poly) 98 // (reverse I/O, polysize, poly)
@@ -113,7 +111,7 @@ impl Crc {
113 }); 111 });
114 // configure the polynomial. 112 // configure the polynomial.
115 #[cfg(crc_v3)] 113 #[cfg(crc_v3)]
116 w.set_polysize(match self._config.poly_size { 114 w.set_polysize(match self._config.poly_size {
117 PolySize::Width7 => vals::Polysize::POLYSIZE7, 115 PolySize::Width7 => vals::Polysize::POLYSIZE7,
118 PolySize::Width8 => vals::Polysize::POLYSIZE8, 116 PolySize::Width8 => vals::Polysize::POLYSIZE8,
119 PolySize::Width16 => vals::Polysize::POLYSIZE16, 117 PolySize::Width16 => vals::Polysize::POLYSIZE16,
@@ -136,11 +134,11 @@ impl Crc {
136 /// Feeds an slice of bytes into the CRC peripheral. Returns the computed checksum. 134 /// Feeds an slice of bytes into the CRC peripheral. Returns the computed checksum.
137 pub fn feed_bytes(&mut self, bytes: &[u8]) -> u32 { 135 pub fn feed_bytes(&mut self, bytes: &[u8]) -> u32 {
138 for byte in bytes { 136 for byte in bytes {
139 unsafe { PAC_CRC.dr8().write_value(*byte as u32); } 137 unsafe {
140 } 138 PAC_CRC.dr8().write_value(*byte as u32);
141 unsafe { 139 }
142 PAC_CRC.dr().read()
143 } 140 }
141 unsafe { PAC_CRC.dr().read() }
144 } 142 }
145 /// Feeds a halfword into the CRC peripheral. Returns the computed checksum. 143 /// Feeds a halfword into the CRC peripheral. Returns the computed checksum.
146 pub fn feed_halfword(&mut self, byte: u16) -> u32 { 144 pub fn feed_halfword(&mut self, byte: u16) -> u32 {
@@ -152,11 +150,11 @@ impl Crc {
152 /// Feeds an slice of halfwords into the CRC peripheral. Returns the computed checksum. 150 /// Feeds an slice of halfwords into the CRC peripheral. Returns the computed checksum.
153 pub fn feed_halfwords(&mut self, bytes: &[u16]) -> u32 { 151 pub fn feed_halfwords(&mut self, bytes: &[u16]) -> u32 {
154 for byte in bytes { 152 for byte in bytes {
155 unsafe { PAC_CRC.dr16().write_value(*byte as u32); } 153 unsafe {
156 } 154 PAC_CRC.dr16().write_value(*byte as u32);
157 unsafe { 155 }
158 PAC_CRC.dr().read()
159 } 156 }
157 unsafe { PAC_CRC.dr().read() }
160 } 158 }
161 /// Feeds a halfword into the CRC peripheral. Returns the computed checksum. 159 /// Feeds a halfword into the CRC peripheral. Returns the computed checksum.
162 pub fn feed_word(&mut self, byte: u32) -> u32 { 160 pub fn feed_word(&mut self, byte: u32) -> u32 {
@@ -168,10 +166,10 @@ impl Crc {
168 /// Feeds an slice of halfwords into the CRC peripheral. Returns the computed checksum. 166 /// Feeds an slice of halfwords into the CRC peripheral. Returns the computed checksum.
169 pub fn feed_words(&mut self, bytes: &[u32]) -> u32 { 167 pub fn feed_words(&mut self, bytes: &[u32]) -> u32 {
170 for byte in bytes { 168 for byte in bytes {
171 unsafe { PAC_CRC.dr().write_value(*byte as u32); } 169 unsafe {
172 } 170 PAC_CRC.dr().write_value(*byte as u32);
173 unsafe { 171 }
174 PAC_CRC.dr().read()
175 } 172 }
173 unsafe { PAC_CRC.dr().read() }
176 } 174 }
177} 175}