@@ -32,7 +32,7 @@ const APP: () = {
32
32
33
33
rprintln ! ( " - CAN init" ) ;
34
34
35
- let mut can = {
35
+ let can = {
36
36
let rx =
37
37
gpioa
38
38
. pa11
@@ -44,14 +44,15 @@ const APP: () = {
44
44
45
45
let can = Can :: new ( & mut rcc. apb1r1 , dp. CAN1 , ( tx, rx) ) ;
46
46
47
- bxcan:: Can :: new ( can)
48
- } ;
49
- can. configure ( |config| {
50
- // APB1 (PCLK1): 80 MHz, Bit rate: 100kBit/s, Sample Point 87.5%
51
- // Value was calculated with http://www.bittiming.can-wiki.info/
52
- config. set_bit_timing ( 0x001c_0031 ) ;
53
- config. set_loopback ( true ) ;
54
- } ) ;
47
+ bxcan:: Can :: builder ( can)
48
+ }
49
+ // APB1 (PCLK1): 80 MHz, Bit rate: 100kBit/s, Sample Point 87.5%
50
+ // Value was calculated with http://www.bittiming.can-wiki.info/
51
+ . set_bit_timing ( 0x001c_0031 )
52
+ . set_loopback ( true ) ;
53
+
54
+ // Enable and wait for bxCAN sync to bus
55
+ let mut can = can. enable ( ) ;
55
56
56
57
// Configure filters so that can frames can be received.
57
58
let mut filters = can. modify_filters ( ) ;
@@ -60,9 +61,6 @@ const APP: () = {
60
61
// Drop filters to leave filter configuraiton mode.
61
62
drop ( filters) ;
62
63
63
- // Enable and wait for bxCAN sync to bus
64
- while let Err ( _) = can. enable ( ) { }
65
-
66
64
// Send a frame
67
65
let mut test: [ u8 ; 8 ] = [ 0 ; 8 ] ;
68
66
let id: u16 = 0x500 ;
0 commit comments