@@ -77,28 +77,24 @@ impl Config {
77
77
/// Sets the initial value of the CRC.
78
78
pub fn initial_value ( mut self , init : u32 ) -> Self {
79
79
self . initial_value = init;
80
-
81
80
self
82
81
}
83
82
84
83
/// Sets the polynomial of the CRC.
85
84
pub fn polynomial ( mut self , polynomial : Polynomial ) -> Self {
86
85
self . polynomial = polynomial;
87
-
88
86
self
89
87
}
90
88
91
89
/// Enables bit reversal of the inputs.
92
90
pub fn input_bit_reversal ( mut self , rev : Option < BitReversal > ) -> Self {
93
91
self . input_bit_reversal = rev;
94
-
95
92
self
96
93
}
97
94
98
95
/// Enables bit reversal of the outputs.
99
96
pub fn output_bit_reversal ( mut self , rev : bool ) -> Self {
100
97
self . output_bit_reversal = rev;
101
-
102
98
self
103
99
}
104
100
@@ -147,11 +143,20 @@ impl Config {
147
143
pub struct Crc { }
148
144
149
145
impl Crc {
146
+ /// Release CRC peripheral.
147
+ pub fn release ( self ) -> Config {
148
+ Config {
149
+ initial_value : 0xffff_ffff ,
150
+ polynomial : Polynomial :: L32 ( 0x04c1_1db7 ) ,
151
+ input_bit_reversal : None ,
152
+ output_bit_reversal : false ,
153
+ }
154
+ }
155
+
150
156
/// This will reset the CRC to its initial condition.
151
157
#[ inline]
152
158
pub fn reset ( & mut self ) {
153
159
let crc = unsafe { & ( * CRC :: ptr ( ) ) } ;
154
-
155
160
crc. cr ( ) . modify ( |_, w| w. reset ( ) . set_bit ( ) ) ;
156
161
}
157
162
@@ -162,7 +167,6 @@ impl Crc {
162
167
#[ inline]
163
168
pub fn reset_with_inital_value ( & mut self , initial_value : u32 ) {
164
169
let crc = unsafe { & ( * CRC :: ptr ( ) ) } ;
165
-
166
170
crc. init ( )
167
171
. write ( |w| unsafe { w. crc_init ( ) . bits ( initial_value) } ) ;
168
172
crc. cr ( ) . modify ( |_, w| w. reset ( ) . set_bit ( ) ) ;
@@ -187,9 +191,7 @@ impl Crc {
187
191
#[ inline]
188
192
pub fn result ( & mut self ) -> u32 {
189
193
let ret = self . peek_result ( ) ;
190
-
191
194
self . reset ( ) ;
192
-
193
195
ret
194
196
}
195
197
@@ -198,7 +200,6 @@ impl Crc {
198
200
#[ inline]
199
201
pub fn peek_result ( & self ) -> u32 {
200
202
let crc = unsafe { & ( * CRC :: ptr ( ) ) } ;
201
-
202
203
crc. dr ( ) . read ( ) . bits ( )
203
204
}
204
205
}
0 commit comments