@@ -40,13 +40,13 @@ fn main() -> ! {
40
40
let tx = gpioa. pa12 . into_alternate ( ) ;
41
41
42
42
let can = Can :: new ( dp. CAN1 , & mut rcc. apb1 , ( tx, rx) ) ;
43
- bxcan:: Can :: new ( can)
43
+
44
+ bxcan:: Can :: builder ( can)
45
+ // APB1 (PCLK1): 130MHz, Bit rate: 512kBit/s, Sample Point 87.5%
46
+ // Value was calculated with http://www.bittiming.can-wiki.info/
47
+ . set_bit_timing ( 0x001e_000b )
48
+ . enable ( )
44
49
} ;
45
- can1. configure ( |config| {
46
- // APB1 (PCLK1): 130MHz, Bit rate: 512kBit/s, Sample Point 87.5%
47
- // Value was calculated with http://www.bittiming.can-wiki.info/
48
- config. set_bit_timing ( 0x001e_000b ) ;
49
- } ) ;
50
50
51
51
// Configure filters so that can frames can be received.
52
52
let mut filters = can1. modify_filters ( ) ;
@@ -58,12 +58,11 @@ fn main() -> ! {
58
58
59
59
let can = Can :: new ( dp. CAN2 , & mut rcc. apb1 , ( tx, rx) ) ;
60
60
61
- let mut can2 = bxcan:: Can :: new ( can) ;
62
- can2. configure ( |config| {
61
+ let can2 = bxcan:: Can :: builder ( can)
63
62
// APB1 (PCLK1): 130MHz, Bit rate: 512kBit/s, Sample Point 87.5%
64
63
// Value was calculated with http://www.bittiming.can-wiki.info/
65
- config . set_bit_timing ( 0x001e_000b ) ;
66
- } ) ;
64
+ . set_bit_timing ( 0x001e_000b )
65
+ . enable ( ) ;
67
66
68
67
// A total of 28 filters are shared between the two CAN instances.
69
68
// Split them equally between CAN1 and CAN2.
@@ -80,9 +79,6 @@ fn main() -> ! {
80
79
let mut can = can1;
81
80
//let mut can = can2;
82
81
83
- // Split the peripheral into transmitter and receiver parts.
84
- block ! ( can. enable( ) ) . unwrap ( ) ;
85
-
86
82
// Echo back received packages in sequence.
87
83
// See the `can-rtfm` example for an echo implementation that adheres to
88
84
// correct frame ordering based on the transfer id.
0 commit comments