Skip to content

Commit f11d4a4

Browse files
andyblarblareldruin
authored andcommitted
Update CAN examples.
1 parent 02cc2e2 commit f11d4a4

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

examples/can-echo.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![no_main]
55
#![no_std]
66

7+
use bxcan::Fifo::Fifo0;
78
use panic_halt as _;
89

910
use bxcan::filter::Mask32;
@@ -50,7 +51,7 @@ fn main() -> ! {
5051

5152
// Configure filters so that can frames can be received.
5253
let mut filters = can1.modify_filters();
53-
filters.enable_bank(0, Mask32::accept_all());
54+
filters.enable_bank(0, Fifo0, Mask32::accept_all());
5455

5556
let _can2 = {
5657
let rx = gpiob.pb5.into_alternate();
@@ -68,20 +69,18 @@ fn main() -> ! {
6869
// Split them equally between CAN1 and CAN2.
6970
filters.set_split(14);
7071
let mut slave_filters = filters.slave_filters();
71-
slave_filters.enable_bank(14, Mask32::accept_all());
72+
slave_filters.enable_bank(14, Fifo0, Mask32::accept_all());
7273
can2
7374
};
7475

75-
// Drop filters to leave filter configuraiton mode.
76+
// Drop filters to leave filter configuration mode.
7677
drop(filters);
7778

7879
// Select the interface.
7980
let mut can = can1;
8081
//let mut can = can2;
8182

8283
// Echo back received packages in sequence.
83-
// See the `can-rtfm` example for an echo implementation that adheres to
84-
// correct frame ordering based on the transfer id.
8584
loop {
8685
if let Ok(frame) = block!(can.receive()) {
8786
block!(can.transmit(&frame)).unwrap();

examples/can-loopback.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#![no_main]
55
#![no_std]
66

7+
use bxcan::Fifo::Fifo0;
78
use bxcan::{
89
filter::{ListEntry16, ListEntry32, Mask16},
910
ExtendedId, Frame, StandardId,
@@ -57,9 +58,9 @@ fn main() -> ! {
5758
// of the `split_filters_advanced()` method.
5859

5960
// 2x 11bit id + mask filter bank: Matches 0, 1, 2
60-
// TODO: Make this accept also ID 2
6161
filters.enable_bank(
6262
0,
63+
Fifo0,
6364
[
6465
// accepts 0 and 1
6566
Mask16::frames_with_std_id(StandardId::new(0).unwrap(), StandardId::new(1).unwrap()),
@@ -71,6 +72,7 @@ fn main() -> ! {
7172
// 2x 29bit id filter bank: Matches 4, 5
7273
filters.enable_bank(
7374
1,
75+
Fifo0,
7476
[
7577
ListEntry32::data_frames_with_id(ExtendedId::new(4).unwrap()),
7678
ListEntry32::data_frames_with_id(ExtendedId::new(5).unwrap()),
@@ -80,6 +82,7 @@ fn main() -> ! {
8082
// 4x 11bit id filter bank: Matches 8, 9, 10, 11
8183
filters.enable_bank(
8284
2,
85+
Fifo0,
8386
[
8487
ListEntry16::data_frames_with_id(StandardId::new(8).unwrap()),
8588
ListEntry16::data_frames_with_id(StandardId::new(9).unwrap()),
@@ -88,7 +91,7 @@ fn main() -> ! {
8891
],
8992
);
9093

91-
// Drop filters to leave filter configuraiton mode.
94+
// Drop filters to leave filter configuration mode.
9295
drop(filters);
9396

9497
// Some messages shall pass the filters.

0 commit comments

Comments
 (0)