File tree Expand file tree Collapse file tree 3 files changed +29
-27
lines changed Expand file tree Collapse file tree 3 files changed +29
-27
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ extern crate cortex_m_rt as rt;
8
8
extern crate panic_halt;
9
9
extern crate stm32g0xx_hal as hal;
10
10
11
- use cortex_m_semihosting :: hprintln ;
11
+ use defmt_rtt as _ ;
12
12
use hal:: crc:: * ;
13
13
use hal:: prelude:: * ;
14
14
use hal:: stm32;
@@ -25,24 +25,24 @@ fn main() -> ! {
25
25
. output_bit_reversal ( true )
26
26
. freeze ( ) ;
27
27
28
- loop {
29
- crc. reset ( ) ;
30
- crc . feed ( b"123456789" ) ;
31
-
32
- let hash_sum = crc . result ( ) ;
33
- hprintln ! (
34
- "crc32: 0x{:x}, crc32b: 0x{:x}" ,
35
- hash_sum ,
36
- hash_sum ^ 0xffff_ffff
37
- ) ;
38
-
39
- crc . reset ( ) ;
40
- crc. feed ( b"The quick brown fox jumps over the lazy dog" ) ;
41
- let hash_sum = crc . result ( ) ;
42
- hprintln ! (
43
- "crc32: 0x{:x}, crc32b: 0x{:x}" ,
44
- hash_sum ,
45
- hash_sum ^ 0xffff_ffff
46
- ) ;
47
- }
28
+ crc . reset ( ) ;
29
+ crc. feed ( b"123456789" ) ;
30
+
31
+ let hash_sum = crc . result ( ) ;
32
+ defmt :: info! (
33
+ "target: 0xcbf43926, crc32: 0x{:x}, crc32b: 0x{:x}" ,
34
+ hash_sum ,
35
+ hash_sum ^ 0xffff_ffff
36
+ ) ;
37
+
38
+ crc . reset ( ) ;
39
+ crc . feed ( b"The quick brown fox jumps over the lazy dog" ) ;
40
+ let hash_sum = crc. result ( ) ;
41
+ defmt :: info! (
42
+ "target: 0x414fa339, crc32: 0x{:x}, crc32b: 0x{:x}" ,
43
+ hash_sum ,
44
+ hash_sum ^ 0xffff_ffff
45
+ ) ;
46
+
47
+ loop { }
48
48
}
Original file line number Diff line number Diff line change @@ -173,7 +173,12 @@ impl Crc {
173
173
pub fn feed ( & mut self , data : & [ u8 ] ) {
174
174
let crc = unsafe { & ( * CRC :: ptr ( ) ) } ;
175
175
for byte in data {
176
- crc. dr ( ) . write ( |w| unsafe { w. dr ( ) . bits ( ( * byte) . into ( ) ) } ) ;
176
+ unsafe {
177
+ core:: ptr:: write_volatile (
178
+ core:: cell:: UnsafeCell :: < u8 > :: raw_get ( crc. dr ( ) . as_ptr ( ) as _ ) ,
179
+ * byte,
180
+ )
181
+ }
177
182
}
178
183
}
179
184
Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ use crate::rcc::*;
3
3
use crate :: stm32:: { SPI1 , SPI2 } ;
4
4
use crate :: time:: Hertz ;
5
5
use core:: convert:: Infallible ;
6
- use core:: ptr;
7
6
use embedded_hal:: delay:: DelayNs ;
8
7
use hal:: digital;
9
8
use hal:: digital:: OutputPin ;
@@ -310,7 +309,7 @@ macro_rules! spi {
310
309
} else if sr. crcerr( ) . bit_is_set( ) {
311
310
nb:: Error :: Other ( Error :: Crc )
312
311
} else if sr. rxne( ) . bit_is_set( ) {
313
- return Ok ( self . spi. dr ( ) . read( ) . bits( ) as u8 ) ;
312
+ return Ok ( self . spi. dr8 ( ) . read( ) . bits( ) as u8 ) ;
314
313
} else {
315
314
nb:: Error :: WouldBlock
316
315
} )
@@ -325,9 +324,7 @@ macro_rules! spi {
325
324
} else if sr. crcerr( ) . bit_is_set( ) {
326
325
nb:: Error :: Other ( Error :: Crc )
327
326
} else if sr. txe( ) . bit_is_set( ) {
328
- unsafe {
329
- ptr:: write_volatile( core:: cell:: UnsafeCell :: raw_get( self . spi. dr( ) as * const _ as _) , byte)
330
- }
327
+ self . spi. dr8( ) . write( |w| unsafe { w. dr( ) . bits( byte as _) } ) ;
331
328
return Ok ( ( ) ) ;
332
329
} else {
333
330
nb:: Error :: WouldBlock
You can’t perform that action at this time.
0 commit comments