Skip to content

Commit

Permalink
Merge pull request #379 from stm32-rs/update-deps
Browse files Browse the repository at this point in the history
update & clean deps
  • Loading branch information
burrbull authored Dec 29, 2021
2 parents 1f799bd + 9ad8da0 commit 85eb0fd
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 41 deletions.
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CHANGELOG.md merge=union
17 changes: 5 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cortex-m-rt = "0.7"
nb = "1"
stm32f1 = "0.14.0"
embedded-dma = "0.1.2"
bxcan = ">=0.4, <0.6"
bxcan = "0.6"
cast = { default-features = false, version = "0.3.0" }
void = { default-features = false, version = "1.0.2" }
embedded-hal = { features = ["unproven"], version = "0.2.6" }
Expand All @@ -32,21 +32,14 @@ optional = true

[dev-dependencies]
panic-halt = "0.2.0"
panic-semihosting = "0.5.2"
panic-semihosting = "0.5.6"
panic-itm = "0.4.1"
cortex-m-rtic = "0.6.0-rc.2"
cortex-m-semihosting = "0.3.3"
heapless = "0.7.7"
m = "0.1.1"
cortex-m-rtic = "1.0.0"
cortex-m-semihosting = "0.3.7"
heapless = "0.7.9"
mfrc522 = "0.2.0"
usb-device = "0.2.8"
usbd-serial = "0.1.1"
byteorder = { default-features = false, version = "1.4.3" }
cobs = { default-features = false, version = "0.1.4" }
crc16 = { default-features = false, version = "0.4.0" }
either = { default-features = false, version = "1.6.1" }
serde = { default-features = false, version = "1.0.130"}
serde_derive = "1.0.130"

[features]
device-selected = []
Expand Down
18 changes: 9 additions & 9 deletions examples/can-echo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ fn main() -> ! {
let tx = gpioa.pa12.into_alternate_push_pull(&mut gpioa.crh);
can.assign_pins((tx, rx), &mut afio.mapr);

bxcan::Can::new(can)
// APB1 (PCLK1): 8MHz, Bit rate: 125kBit/s, Sample Point 87.5%
// Value was calculated with http://www.bittiming.can-wiki.info/
bxcan::Can::builder(can)
.set_bit_timing(0x001c_0003)
.leave_disabled()
};

// APB1 (PCLK1): 8MHz, Bit rate: 125kBit/s, Sample Point 87.5%
// Value was calculated with http://www.bittiming.can-wiki.info/
can1.modify_config().set_bit_timing(0x001c_0003);

// Configure filters so that can frames can be received.
let mut filters = can1.modify_filters();
filters.enable_bank(0, Mask32::accept_all());
Expand All @@ -56,11 +56,11 @@ fn main() -> ! {
let tx = gpiob.pb6.into_alternate_push_pull(&mut gpiob.crl);
can.assign_pins((tx, rx), &mut afio.mapr);

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

// APB1 (PCLK1): 8MHz, Bit rate: 125kBit/s, Sample Point 87.5%
// Value was calculated with http://www.bittiming.can-wiki.info/
can2.modify_config().set_bit_timing(0x001c_0003);
let mut can2 = bxcan::Can::builder(can)
.set_bit_timing(0x001c_0003)
.leave_disabled();

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

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

// Echo back received packages in sequence.
// See the `can-rtfm` example for an echo implementation that adheres to
Expand Down
9 changes: 4 additions & 5 deletions examples/can-loopback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@ fn main() -> ! {
#[cfg(feature = "connectivity")]
let can = Can::new(dp.CAN1);

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

// Use loopback mode: No pins need to be assigned to peripheral.
// APB1 (PCLK1): 8MHz, Bit rate: 500Bit/s, Sample Point 87.5%
// Value was calculated with http://www.bittiming.can-wiki.info/
can.modify_config()
let mut can = bxcan::Can::builder(can)
.set_bit_timing(0x001c_0000)
.set_loopback(true)
.set_silent(true);
.set_silent(true)
.leave_disabled();

let mut filters = can.modify_filters();
assert!(filters.num_banks() > 3);
Expand Down Expand Up @@ -83,7 +82,7 @@ fn main() -> ! {
drop(filters);

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

// Some messages shall pass the filters.
for &id in &[0, 1, 2, 8, 9, 10, 11] {
Expand Down
32 changes: 17 additions & 15 deletions examples/can-rtic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,19 @@ mod app {
let mut afio = cx.device.AFIO.constrain();
can.assign_pins((can_tx_pin, can_rx_pin), &mut afio.mapr);

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

// APB1 (PCLK1): 16MHz, Bit rate: 1000kBit/s, Sample Point 87.5%
// Value was calculated with http://www.bittiming.can-wiki.info/
can.modify_config().set_bit_timing(0x001c_0000);
let mut can = bxcan::Can::builder(can)
.set_bit_timing(0x001c_0000)
.leave_disabled();

can.modify_filters().enable_bank(0, Mask32::accept_all());

// Sync to the bus and start normal operation.
can.enable_interrupts(
Interrupts::TRANSMIT_MAILBOX_EMPTY | Interrupts::FIFO0_MESSAGE_PENDING,
);
nb::block!(can.enable()).unwrap();
nb::block!(can.enable_non_blocking()).unwrap();

let (can_tx, can_rx) = can.split();

Expand Down Expand Up @@ -213,17 +213,19 @@ mod app {
(&mut tx_queue, &mut tx_count).lock(|tx_queue, tx_count| {
while let Some(frame) = tx_queue.peek() {
match tx.transmit(&frame.0) {
Ok(None) => {
// Frame was successfully placed into a transmit buffer.
tx_queue.pop();
*tx_count += 1;
}
Ok(Some(pending_frame)) => {
// A lower priority frame was replaced with our high priority frame.
// Put the low priority frame back in the transmit queue.
tx_queue.pop();
enqueue_frame(tx_queue, pending_frame);
}
Ok(status) => match status.dequeued_frame() {
None => {
// Frame was successfully placed into a transmit buffer.
tx_queue.pop();
*tx_count += 1;
}
Some(pending_frame) => {
// A lower priority frame was replaced with our high priority frame.
// Put the low priority frame back in the transmit queue.
tx_queue.pop();
enqueue_frame(tx_queue, pending_frame.clone());
}
},
Err(nb::Error::WouldBlock) => break,
Err(_) => unreachable!(),
}
Expand Down

0 comments on commit 85eb0fd

Please sign in to comment.