Compare commits
8 Commits
dbc527f759
...
main
Author | SHA1 | Date | |
---|---|---|---|
7035780beb | |||
![]() |
e82effb2e4
|
||
6a886651fc | |||
![]() |
191642d76a | ||
c1e4935d22 | |||
![]() |
e692f922a4
|
||
ce02b38ff6 | |||
993a0bcd3e |
@@ -6,7 +6,7 @@ edition = "2021"
|
||||
[dependencies]
|
||||
cortex-m = "0.7"
|
||||
cortex-m-rt = "0.7"
|
||||
defmt-rtt = "0.4"
|
||||
defmt-rtt = "1"
|
||||
defmt = "1"
|
||||
panic-probe = { version = "1", features = ["defmt"] }
|
||||
crc = "3"
|
||||
|
@@ -8,12 +8,11 @@ cortex-m = "0.7"
|
||||
cortex-m-rt = "0.7"
|
||||
cfg-if = "1"
|
||||
embedded-io = "0.6"
|
||||
embedded-can = "0.4"
|
||||
embedded-hal-async = "1"
|
||||
embedded-io-async = "0.6"
|
||||
|
||||
heapless = "0.8"
|
||||
defmt-rtt = "0.4"
|
||||
defmt-rtt = "1"
|
||||
defmt = "1"
|
||||
panic-probe = { version = "1", features = ["print-defmt"] }
|
||||
static_cell = "2"
|
||||
@@ -21,7 +20,7 @@ critical-section = "1"
|
||||
ringbuf = { version = "0.4", default-features = false }
|
||||
|
||||
nb = "1"
|
||||
embassy-sync = "0.6"
|
||||
embassy-sync = "0.7"
|
||||
embassy-time = "0.4"
|
||||
embassy-executor = { version = "0.7", features = [
|
||||
"arch-cortex-m",
|
||||
|
@@ -5,7 +5,7 @@ edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
cortex-m = { version = "0.7", features = ["critical-section-single-core"] }
|
||||
defmt-rtt = "0.4"
|
||||
defmt-rtt = "1"
|
||||
defmt = "1"
|
||||
panic-probe = { version = "1", features = ["defmt"] }
|
||||
|
||||
|
@@ -7,7 +7,7 @@ edition = "2021"
|
||||
cortex-m = { version = "0.7", features = ["critical-section-single-core"] }
|
||||
cortex-m-rt = "0.7"
|
||||
critical-section = "1"
|
||||
defmt-rtt = "0.4"
|
||||
defmt-rtt = "1"
|
||||
defmt = "1"
|
||||
panic-probe = { version = "1", features = ["defmt"] }
|
||||
embedded-hal = "1"
|
||||
|
@@ -6,15 +6,15 @@ edition = "2021"
|
||||
[dependencies]
|
||||
cortex-m = "0.7"
|
||||
embedded-io = "0.6"
|
||||
defmt-rtt = "0.4"
|
||||
defmt-rtt = "1"
|
||||
defmt = "1"
|
||||
panic-probe = { version = "1", features = ["defmt"] }
|
||||
static_cell = "2"
|
||||
satrs = { version = "0.3.0-alpha.0", default-features = false }
|
||||
satrs = { version = "0.3.0-alpha.1", default-features = false }
|
||||
ringbuf = { version = "0.4", default-features = false }
|
||||
once_cell = { version = "1", default-features = false, features = ["critical-section"] }
|
||||
spacepackets = { version = "0.13", default-features = false, features = ["defmt"] }
|
||||
cobs = { version = "0.3", default-features = false }
|
||||
spacepackets = { version = "0.15", default-features = false, features = ["defmt"] }
|
||||
cobs = { version = "0.4", default-features = false }
|
||||
|
||||
va416xx-hal = { version = "0.5", features = ["va41630", "defmt"], path = "../va416xx-hal" }
|
||||
|
||||
|
@@ -347,7 +347,7 @@ mod app {
|
||||
defmt::warn!("PUS TC error: {}", pus_tc.unwrap_err());
|
||||
return;
|
||||
}
|
||||
let (pus_tc, _) = pus_tc.unwrap();
|
||||
let pus_tc = pus_tc.unwrap();
|
||||
let mut write_and_send = |tm: &PusTmCreator| {
|
||||
let written_size = tm.write_to_bytes(cx.local.verif_buf).unwrap();
|
||||
cx.shared.tm_prod.lock(|prod| {
|
||||
@@ -356,18 +356,18 @@ mod app {
|
||||
.push_slice(&cx.local.verif_buf[0..written_size]);
|
||||
});
|
||||
};
|
||||
let token = cx.local.verif_reporter.add_tc(&pus_tc);
|
||||
let (tm, accepted_token) = cx
|
||||
let request_id = VerificationReportCreator::read_request_id_from_tc(&pus_tc);
|
||||
let tm = cx
|
||||
.local
|
||||
.verif_reporter
|
||||
.acceptance_success(cx.local.src_data_buf, token, 0, 0, &[])
|
||||
.acceptance_success(cx.local.src_data_buf, &request_id, 0, 0, &[])
|
||||
.expect("acceptance success failed");
|
||||
write_and_send(&tm);
|
||||
|
||||
let (tm, started_token) = cx
|
||||
let tm = cx
|
||||
.local
|
||||
.verif_reporter
|
||||
.start_success(cx.local.src_data_buf, accepted_token, 0, 0, &[])
|
||||
.start_success(cx.local.src_data_buf, &request_id, 0, 0, &[])
|
||||
.expect("acceptance success failed");
|
||||
write_and_send(&tm);
|
||||
|
||||
@@ -387,7 +387,7 @@ mod app {
|
||||
let tm = cx
|
||||
.local
|
||||
.verif_reporter
|
||||
.completion_success(cx.local.src_data_buf, started_token, 0, 0, &[])
|
||||
.completion_success(cx.local.src_data_buf, &request_id, 0, 0, &[])
|
||||
.expect("completion success failed");
|
||||
write_and_send(&tm);
|
||||
};
|
||||
@@ -405,7 +405,7 @@ mod app {
|
||||
let tm = cx
|
||||
.local
|
||||
.verif_reporter
|
||||
.completion_success(cx.local.src_data_buf, started_token, 0, 0, &[])
|
||||
.completion_success(cx.local.src_data_buf, &request_id, 0, 0, &[])
|
||||
.expect("completion success failed");
|
||||
write_and_send(&tm);
|
||||
} else if pus_tc.service() == PusServiceId::MemoryManagement as u8 {
|
||||
@@ -414,7 +414,7 @@ mod app {
|
||||
.verif_reporter
|
||||
.step_success(
|
||||
cx.local.src_data_buf,
|
||||
&started_token,
|
||||
&request_id,
|
||||
0,
|
||||
0,
|
||||
&[],
|
||||
@@ -460,7 +460,7 @@ mod app {
|
||||
let tm = cx
|
||||
.local
|
||||
.verif_reporter
|
||||
.completion_success(cx.local.src_data_buf, started_token, 0, 0, &[])
|
||||
.completion_success(cx.local.src_data_buf, &request_id, 0, 0, &[])
|
||||
.expect("completion success failed");
|
||||
write_and_send(&tm);
|
||||
defmt::info!("NVM operation done");
|
||||
|
@@ -11,7 +11,7 @@ keywords = ["no-std", "hal", "cortex-m", "vorago", "va416xx"]
|
||||
categories = ["aerospace", "embedded", "no-std", "hardware-support"]
|
||||
|
||||
[dependencies]
|
||||
vorago-shared-periphs = { git = "https://egit.irs.uni-stuttgart.de/rust/vorago-shared-periphs.git", features = ["vor4x"] }
|
||||
vorago-shared-periphs = { git = "https://egit.irs.uni-stuttgart.de/rust/vorago-shared-periphs.git", rev = "c8e475cbba820a4b235b46f3d284e23d72396855", features = ["vor4x"] }
|
||||
va416xx-hal = { path = "../va416xx-hal" }
|
||||
|
||||
[features]
|
||||
|
@@ -13,9 +13,9 @@ categories = ["embedded", "no-std", "hardware-support"]
|
||||
[dependencies]
|
||||
cortex-m = { version = "0.7", features = ["critical-section-single-core"] }
|
||||
va416xx = { version = "0.4", features = ["critical-section"], default-features = false }
|
||||
derive-mmio = { version = "0.4", git = "https://github.com/knurling-rs/derive-mmio.git" }
|
||||
derive-mmio = { git = "https://github.com/knurling-rs/derive-mmio.git", version = "0.6" }
|
||||
static_assertions = "1.1"
|
||||
vorago-shared-periphs = { git = "https://egit.irs.uni-stuttgart.de/rust/vorago-shared-periphs.git", features = ["vor4x"] }
|
||||
vorago-shared-periphs = { git = "https://egit.irs.uni-stuttgart.de/rust/vorago-shared-periphs.git", rev = "c8e475cbba820a4b235b46f3d284e23d72396855", features = ["vor4x"] }
|
||||
|
||||
libm = "0.2"
|
||||
nb = "1"
|
||||
@@ -26,10 +26,10 @@ bitbybit = "1.3"
|
||||
arbitrary-int = "1.3"
|
||||
fugit = "0.3"
|
||||
embedded-can = "0.4"
|
||||
embassy-sync = "0.6"
|
||||
embassy-sync = "0.7"
|
||||
thiserror = { version = "2", default-features = false }
|
||||
|
||||
defmt = { version = "0.3", optional = true }
|
||||
defmt = { version = "1", optional = true }
|
||||
|
||||
[features]
|
||||
default = ["rt", "revb"]
|
||||
|
@@ -1,6 +1,22 @@
|
||||
//! CAN driver.
|
||||
//! # CAN peripheral driver.
|
||||
//!
|
||||
//! The VA416xx CAN module is based on the CP3UB26 module.
|
||||
//!
|
||||
//! Using the CAN bus generally involves the following steps:
|
||||
//!
|
||||
//! 1. Create a [Can] instance
|
||||
//! 2. The [CanChannels] resource management singleton can be retrieved by using
|
||||
//! [Can::take_channels].
|
||||
//! 3. Individual [CanRx] and [CanTx] channels can be created using the [CanChannels::take]
|
||||
//! function. These allow to send or receive CAN frames on individual channels.
|
||||
//! 4. The [asynch::CanTxAsync] structure can be created to transmit frames asynchronously.
|
||||
//! The [asynch::on_interrupt_can] function should be called in the user interrupt handler
|
||||
//! for CAN0 and CAN1 for this to work properly. The interrupt handler can also take care of
|
||||
//! receiving frames on [CanRx] channels with enabled interrupts.
|
||||
//!
|
||||
//! # Example
|
||||
//!
|
||||
//! - [CAN example](https://egit.irs.uni-stuttgart.de/rust/va416xx-rs/src/branch/main/examples/embassy/src/bin/can.rs)
|
||||
use core::sync::atomic::AtomicBool;
|
||||
|
||||
use arbitrary_int::{u11, u15, u2, u3, u4, u7, Number};
|
||||
@@ -319,6 +335,7 @@ pub enum ClockConfigError {
|
||||
CanNotFindPrescaler,
|
||||
}
|
||||
|
||||
/// The main CAN peripheral driver.
|
||||
pub struct Can {
|
||||
regs: regs::MmioCan<'static>,
|
||||
id: CanId,
|
||||
@@ -358,6 +375,7 @@ impl Can {
|
||||
self.regs.write_gmskb(BaseId::new_with_raw_value(0));
|
||||
}
|
||||
|
||||
/// Retrieve a resource management singleton for the 15 CAN channels.
|
||||
pub fn take_channels(&self) -> Option<CanChannels> {
|
||||
if CHANNELS_TAKEN[self.id() as usize].swap(true, core::sync::atomic::Ordering::SeqCst) {
|
||||
return None;
|
||||
@@ -412,11 +430,13 @@ impl Can {
|
||||
&mut self.regs
|
||||
}
|
||||
|
||||
/// Clear all interrupts.
|
||||
#[inline]
|
||||
pub fn clear_interrupts(&mut self) {
|
||||
self.regs
|
||||
.write_iclr(regs::InterruptClear::new_with_raw_value(0xFFFF_FFFF));
|
||||
}
|
||||
|
||||
/// This function only enable the CAN interrupt vector in the NVIC.
|
||||
///
|
||||
/// The interrupts for the individual channels or errors still need to be enabled
|
||||
@@ -518,6 +538,7 @@ pub enum RxState {
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
pub struct InvalidRxStateError(pub RxState);
|
||||
|
||||
/// Driver instance to use an individual CAN channel as a transmission channel.
|
||||
#[derive(Debug)]
|
||||
pub struct CanTx {
|
||||
ll: CanChannelLowLevel,
|
||||
@@ -646,6 +667,7 @@ impl CanTx {
|
||||
}
|
||||
}
|
||||
|
||||
/// Driver instance to use an individual CAN channel as a reception channel.
|
||||
pub struct CanRx {
|
||||
ll: CanChannelLowLevel,
|
||||
mode: RxState,
|
||||
@@ -760,6 +782,7 @@ impl CanChannels {
|
||||
self.id
|
||||
}
|
||||
|
||||
/// Take the indidivual CAN channel low level driver instance.
|
||||
pub fn take(&mut self, idx: usize) -> Option<CanChannelLowLevel> {
|
||||
if idx > 14 {
|
||||
return None;
|
||||
|
@@ -261,7 +261,7 @@ pub struct ExtendedId {
|
||||
#[bitbybit::bitfield(u32, default = 0x0)]
|
||||
#[derive(Debug)]
|
||||
pub struct BaseId {
|
||||
/// This will contain ID\[10:0\] for standard frames and bits [28:18] for extended frames.
|
||||
/// This will contain ID\[10:0\] for standard frames and bits \[28:18\] for extended frames.
|
||||
#[bits(5..=15, rw)]
|
||||
mask_28_18: u11,
|
||||
/// This is the RTR bit for standard frames, and the SRR bit for extended frames.
|
||||
@@ -357,10 +357,10 @@ impl defmt::Format for DiagnosticRegister {
|
||||
#[mmio(const_inner)]
|
||||
#[repr(C)]
|
||||
pub struct Can {
|
||||
#[mmio(inner)]
|
||||
#[mmio(Inner)]
|
||||
cmbs: [CanMsgBuf; 15],
|
||||
/// Hidden CAN message buffer. Only allowed to be used internally by the peripheral.
|
||||
#[mmio(inner)]
|
||||
#[mmio(Inner)]
|
||||
_hcmb: CanMsgBuf,
|
||||
control: Control,
|
||||
timing: TimingConfig,
|
||||
|
@@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## [unreleased]
|
||||
|
||||
## [v0.4.1] 2025-07-22
|
||||
|
||||
defmt v1
|
||||
|
||||
## [v0.4.0] 2025-02-18
|
||||
|
||||
- Re-generated PAC with `svd2rust` v0.35.0 and added optional `defmt` and `Debug` implementations
|
||||
@@ -32,3 +36,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
Related issue: https://github.com/rust-embedded/svd2rust/issues/557
|
||||
Clippy is disabled in CI/CD for now.
|
||||
- Initial release
|
||||
|
||||
[unreleased]: https://egit.irs.uni-stuttgart.de/rust/va416xx-rs/compare/va416xx-v0.4.1...HEAD
|
||||
[v0.4.1]: https://egit.irs.uni-stuttgart.de/rust/va416xx-rs/compare/va416xx-v0.4.0...va416xx-v0.4.1
|
||||
[v0.4.0]: https://egit.irs.uni-stuttgart.de/rust/va416xx-rs/compare/va416xx-v0.3.0...va416xx-v0.4.0
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "va416xx"
|
||||
version = "0.4.0"
|
||||
version = "0.4.1"
|
||||
authors = ["Robin Mueller <muellerr@irs.uni-stuttgart.de>"]
|
||||
edition = "2021"
|
||||
description = "PAC for the Vorago VA416xx family of MCUs"
|
||||
@@ -16,7 +16,7 @@ categories = ["embedded", "no-std", "hardware-support"]
|
||||
cortex-m = "0.7"
|
||||
vcell = "0.1.3"
|
||||
|
||||
defmt = { version = "0.3", optional = true }
|
||||
defmt = { version = "1", optional = true }
|
||||
critical-section = { version = "1", optional = true }
|
||||
|
||||
[dependencies.cortex-m-rt]
|
||||
|
Reference in New Issue
Block a user