diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..a19ade07 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +CHANGELOG.md merge=union diff --git a/Cargo.toml b/Cargo.toml index f31f470c..16dd7bb4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" } @@ -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 = [] diff --git a/examples/can-echo.rs b/examples/can-echo.rs index a57ca063..153bdb97 100644 --- a/examples/can-echo.rs +++ b/examples/can-echo.rs @@ -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()); @@ -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. @@ -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 diff --git a/examples/can-loopback.rs b/examples/can-loopback.rs index 010a47dd..a0c8b9c7 100644 --- a/examples/can-loopback.rs +++ b/examples/can-loopback.rs @@ -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); @@ -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] { diff --git a/examples/can-rtic.rs b/examples/can-rtic.rs index 11fe1142..2a8f3538 100644 --- a/examples/can-rtic.rs +++ b/examples/can-rtic.rs @@ -95,11 +95,11 @@ 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()); @@ -107,7 +107,7 @@ mod app { 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(); @@ -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!(), }