Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Bump bxcan version from ">=0.4, <0.6" to "0.6" #158

Merged
merged 1 commit into from
Nov 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ micromath = "1.0.0"
synopsys-usb-otg = { version = "0.2.3", features = ["cortex-m"], optional = true }
stm32-fmc = { version = "0.2.0", features = ["sdram"], optional = true }
rand_core = "0.6"
bxcan = ">=0.4, <0.6"
bxcan = "0.6"

[dependencies.bare-metal]
version = "0.2.4"
Expand Down
22 changes: 9 additions & 13 deletions examples/can-echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ fn main() -> ! {
let tx = gpioa.pa12.into_alternate();

let can = Can::new(dp.CAN1, &mut rcc.apb1, (tx, rx));
bxcan::Can::new(can)

bxcan::Can::builder(can)
// APB1 (PCLK1): 130MHz, Bit rate: 512kBit/s, Sample Point 87.5%
// Value was calculated with http://www.bittiming.can-wiki.info/
.set_bit_timing(0x001e_000b)
.enable()
};
can1.configure(|config| {
// APB1 (PCLK1): 130MHz, Bit rate: 512kBit/s, Sample Point 87.5%
// Value was calculated with http://www.bittiming.can-wiki.info/
config.set_bit_timing(0x001e_000b);
});

// Configure filters so that can frames can be received.
let mut filters = can1.modify_filters();
Expand All @@ -58,12 +58,11 @@ fn main() -> ! {

let can = Can::new(dp.CAN2, &mut rcc.apb1, (tx, rx));

let mut can2 = bxcan::Can::new(can);
can2.configure(|config| {
let can2 = bxcan::Can::builder(can)
// APB1 (PCLK1): 130MHz, Bit rate: 512kBit/s, Sample Point 87.5%
// Value was calculated with http://www.bittiming.can-wiki.info/
config.set_bit_timing(0x001e_000b);
});
.set_bit_timing(0x001e_000b)
.enable();

// A total of 28 filters are shared between the two CAN instances.
// Split them equally between CAN1 and CAN2.
Expand All @@ -80,9 +79,6 @@ fn main() -> ! {
let mut can = can1;
//let mut can = can2;

// Split the peripheral into transmitter and receiver parts.
block!(can.enable()).unwrap();

// Echo back received packages in sequence.
// See the `can-rtfm` example for an echo implementation that adheres to
// correct frame ordering based on the transfer id.
Expand Down
17 changes: 6 additions & 11 deletions examples/can-loopback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,14 @@ fn main() -> ! {

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

let mut can = bxcan::Can::new(can);

// Use loopback mode: No pins need to be assigned to peripheral.
can.configure(|config| {
let mut can = bxcan::Can::builder(can)
// APB1 (PCLK1): 130MHz, Bit rate: 512kBit/s, Sample Point 87.5%
// Value was calculated with http://www.bittiming.can-wiki.info/
config.set_bit_timing(0x001e_000b);
config.set_loopback(true);
config.set_silent(true);
});
.set_bit_timing(0x001e_000b)
.set_loopback(true)
.set_silent(true)
.enable();

let mut filters = can.modify_filters();
assert!(filters.num_banks() > 3);
Expand Down Expand Up @@ -90,12 +88,9 @@ fn main() -> ! {
],
);

// Enable filters.
// Drop filters to leave filter configuraiton mode.
drop(filters);

// Sync to the bus and start normal operation.
block!(can.enable()).ok();

// Some messages shall pass the filters.
for &id in &[0, 1, 2, 8, 9, 10, 11] {
let frame_tx = Frame::new_data(StandardId::new(id).unwrap(), [id as u8]);
Expand Down