@@ -95,19 +95,19 @@ mod app {
9595 let mut afio = cx. device . AFIO . constrain ( ) ;
9696 can. assign_pins ( ( can_tx_pin, can_rx_pin) , & mut afio. mapr ) ;
9797
98- let mut can = bxcan:: Can :: new ( can) ;
99-
10098 // APB1 (PCLK1): 16MHz, Bit rate: 1000kBit/s, Sample Point 87.5%
10199 // Value was calculated with http://www.bittiming.can-wiki.info/
102- can. modify_config ( ) . set_bit_timing ( 0x001c_0000 ) ;
100+ let mut can = bxcan:: Can :: builder ( can)
101+ . set_bit_timing ( 0x001c_0000 )
102+ . leave_disabled ( ) ;
103103
104104 can. modify_filters ( ) . enable_bank ( 0 , Mask32 :: accept_all ( ) ) ;
105105
106106 // Sync to the bus and start normal operation.
107107 can. enable_interrupts (
108108 Interrupts :: TRANSMIT_MAILBOX_EMPTY | Interrupts :: FIFO0_MESSAGE_PENDING ,
109109 ) ;
110- nb:: block!( can. enable ( ) ) . unwrap ( ) ;
110+ nb:: block!( can. enable_non_blocking ( ) ) . unwrap ( ) ;
111111
112112 let ( can_tx, can_rx) = can. split ( ) ;
113113
@@ -213,17 +213,19 @@ mod app {
213213 ( & mut tx_queue, & mut tx_count) . lock ( |tx_queue, tx_count| {
214214 while let Some ( frame) = tx_queue. peek ( ) {
215215 match tx. transmit ( & frame. 0 ) {
216- Ok ( None ) => {
217- // Frame was successfully placed into a transmit buffer.
218- tx_queue. pop ( ) ;
219- * tx_count += 1 ;
220- }
221- Ok ( Some ( pending_frame) ) => {
222- // A lower priority frame was replaced with our high priority frame.
223- // Put the low priority frame back in the transmit queue.
224- tx_queue. pop ( ) ;
225- enqueue_frame ( tx_queue, pending_frame) ;
226- }
216+ Ok ( status) => match status. dequeued_frame ( ) {
217+ None => {
218+ // Frame was successfully placed into a transmit buffer.
219+ tx_queue. pop ( ) ;
220+ * tx_count += 1 ;
221+ }
222+ Some ( pending_frame) => {
223+ // A lower priority frame was replaced with our high priority frame.
224+ // Put the low priority frame back in the transmit queue.
225+ tx_queue. pop ( ) ;
226+ enqueue_frame ( tx_queue, pending_frame. clone ( ) ) ;
227+ }
228+ } ,
227229 Err ( nb:: Error :: WouldBlock ) => break ,
228230 Err ( _) => unreachable ! ( ) ,
229231 }
0 commit comments