Skip to content

Commit a0eccf9

Browse files
committed
Update bxcan version span
1 parent 9bc1940 commit a0eccf9

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ cortex-m = "0.7"
2525
nb = "0.1.1"
2626
stm32l4 = "0.14.0"
2727
embedded-dma = "0.1"
28-
bxcan = ">=0.4, <0.6"
28+
bxcan = ">=0.4, <0.7"
2929

3030
[dependencies.rand_core]
3131
version = "0.6.2"

examples/can-loopback.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const APP: () = {
3232

3333
rprintln!(" - CAN init");
3434

35-
let mut can = {
35+
let can = {
3636
let rx =
3737
gpioa
3838
.pa11
@@ -44,14 +44,15 @@ const APP: () = {
4444

4545
let can = Can::new(&mut rcc.apb1r1, dp.CAN1, (tx, rx));
4646

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();
5556

5657
// Configure filters so that can frames can be received.
5758
let mut filters = can.modify_filters();
@@ -60,9 +61,6 @@ const APP: () = {
6061
// Drop filters to leave filter configuraiton mode.
6162
drop(filters);
6263

63-
// Enable and wait for bxCAN sync to bus
64-
while let Err(_) = can.enable() {}
65-
6664
// Send a frame
6765
let mut test: [u8; 8] = [0; 8];
6866
let id: u16 = 0x500;

0 commit comments

Comments
 (0)