Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Nav Board Update #99

Merged
merged 48 commits into from
Feb 2, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
98f64d3
Add blink task and rename sensor_v2 to nav
NoahSprenger Mar 19, 2024
675e473
WIP: Test pinout compatibility.
NoahSprenger Jul 8, 2024
0303498
Fix: MCAN moved as STM32 introduces new CAN library causing symbol is…
NoahSprenger Jul 8, 2024
e3a0dca
Update sbg-rs crate.
NoahSprenger Jul 20, 2024
c138692
Update Cargo.toml mavlink
Jul 20, 2024
0d627fe
WIP: Fix Mavlink, Add baro (untested).
NoahSprenger Jul 23, 2024
47ee89b
WIP: Out of scope.
NoahSprenger Jul 26, 2024
8a84b44
...
NoahSprenger Aug 4, 2024
d88316d
sync
NoahSprenger Aug 5, 2024
8185265
Add command CAN to link board, auto crlf.
NoahSprenger Aug 6, 2024
6589618
WIP: SBG.
NoahSprenger Aug 6, 2024
8624b35
Modify compiler ops, and add launch config.
NoahSprenger Aug 7, 2024
7678ebb
WIP: Works, but needs cleaning.
NoahSprenger Aug 7, 2024
64b0e8b
Add NAV CAN-FD netowrks and implement channels for message passing.
NoahSprenger Aug 8, 2024
9aa7256
WIP: Abort mailbox to prevent blocking forever on CAN.
NoahSprenger Aug 9, 2024
60ef78f
WIP: Fix nominal bit timing.
NoahSprenger Aug 9, 2024
3bc62e3
Add CAN-FD to NAV board.
NoahSprenger Aug 9, 2024
634a981
Update messages crate feature flags.
NoahSprenger Aug 10, 2024
c22dbe2
Remove redundant feature flag.
NoahSprenger Aug 10, 2024
e875aae
Remove failing mavlink code.
NoahSprenger Aug 10, 2024
958b963
WIP
NoahSprenger Aug 11, 2024
62a21a6
Increase CPU and CAN speed.
NoahSprenger Aug 11, 2024
78c063d
Add command reading and sending.
NoahSprenger Aug 11, 2024
6f9ef1f
WIP
NoahSprenger Aug 12, 2024
21d169a
Add recovery sensing and cleanup.
NoahSprenger Aug 12, 2024
7f1dc91
Please work GPS :)
NoahSprenger Aug 13, 2024
b8e1cb1
Add GPS board.
NoahSprenger Aug 13, 2024
4522231
WIP
NoahSprenger Aug 14, 2024
c920181
WIP
NoahSprenger Aug 14, 2024
1313ecf
WIP
NoahSprenger Aug 15, 2024
563fa09
WIP
NoahSprenger Aug 16, 2024
54adb71
WIP
NoahSprenger Aug 17, 2024
d05fcba
Add reset reason message and convert nav to a link board.
NoahSprenger Aug 17, 2024
8b8dd24
Change timestamp to ticks from SysTick 2ms granularity.
NoahSprenger Aug 17, 2024
8180fe7
Add GPS nav message type
NoahSprenger Aug 17, 2024
9911e0f
Add online message and refactor gps board.
NoahSprenger Aug 19, 2024
8879740
WIP: GPS and Link fushion.
NoahSprenger Aug 19, 2024
bed3a92
WIP: Weird link board.
NoahSprenger Aug 20, 2024
34f3cfc
WIP: Fix baud rate.
NoahSprenger Aug 20, 2024
5f3492f
Remove buggy message receiving and fix* timing of recovery algorithm.
NoahSprenger Aug 20, 2024
f4bc78a
WIP
NoahSprenger Aug 21, 2024
f31c25f
Go over recovery algorithm
NoahSprenger Aug 21, 2024
15e3b44
Go over recovery algorithm
NoahSprenger Aug 21, 2024
c08a2d2
?
NoahSprenger Aug 21, 2024
8268798
Post comp update.
NoahSprenger Aug 25, 2024
d275eea
Remove unused boards.
NoahSprenger Aug 25, 2024
edabe7e
Update lock
NoahSprenger Sep 14, 2024
6bea4be
Merge branch 'master' into nav
NoahSprenger Sep 14, 2024
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
Prev Previous commit
Next Next commit
WIP
  • Loading branch information
NoahSprenger committed Aug 12, 2024
commit 6f9ef1f36e02d3a27a5569de28fb7624c7178e6a
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@
"coreConfigs": [
{
"programBinary": "${workspaceFolder}/target/thumbv7em-none-eabihf/release/nav",
"rttEnabled": true,
"coreIndex": 0,
// "rttEnabled": true,
// "coreIndex": 0,
}
]
},
Expand Down
2 changes: 1 addition & 1 deletion Embed.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ protocol = "Swd"
enabled = true

[default.general]
chip = "ATSAME51J20A"
chip = "STM32H733VGTx"

[default.probe]
protocol = "Swd"
Expand Down
2 changes: 1 addition & 1 deletion boards/communication/src/communication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl CanDevice0 {
for message in &mut self.can.rx_fifo_0 {
match from_bytes::<Message>(message.data()) {
Ok(data) => {
info!("Received message {}", data.clone());
// info!("Received message {}", data.clone());

data_manager.handle_data(data);
}
Expand Down
2 changes: 1 addition & 1 deletion boards/communication/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ mod app {
/// Handles the CAN0 interrupt.
#[task(priority = 3, binds = CAN0, shared = [can0, data_manager])]
fn can0(mut cx: can0::Context) {
info!("CAN0 interrupt");
// info!("CAN0 interrupt");
cx.shared.can0.lock(|can| {
cx.shared
.data_manager
Expand Down
42 changes: 34 additions & 8 deletions boards/nav/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ systick_monotonic!(Mono, 500);
#[inline(never)]
#[defmt::panic_handler]
fn panic() -> ! {
// stm32h7xx_hal::pac::SCB::sys_reset()
cortex_m::asm::udf()
}

Expand All @@ -69,12 +70,13 @@ mod app {
sbg_manager: sbg_manager::SBGManager,
can_command_manager: CanCommandManager,
can_data_manager: CanDataManager,
sbg_power: PB4<Output<PushPull>>,

}
#[local]
struct LocalResources {
led_red: PA2<Output<PushPull>>,
led_green: PA3<Output<PushPull>>,
sbg_power: PB4<Output<PushPull>>,
}

#[init]
Expand All @@ -96,12 +98,22 @@ mod app {
let backup = pwrcfg.backup().unwrap();
info!("Backup domain enabled");
// RCC
let rcc = ctx.device.RCC.constrain();
let mut rcc = ctx.device.RCC.constrain();
let reset = rcc.get_reset_reason();
info!("Reset reason: {:?}", reset);
// match reset {
// // rcc::ResetReason::PowerOnReset => {
// // stm32h7xx_hal::pac::SCB::sys_reset();
// // info!("Power on reset");
// // }
// _ => {
// info!("Reset reason: {:?}", reset);
// }
// }
let fdcan_prec_unsafe = unsafe { rcc.steal_peripheral_rec() }
.FDCAN
.kernel_clk_mux(rec::FdcanClkSel::Pll1Q);

info!("RCC enabled");
let ccdr = rcc
.use_hse(48.MHz()) // check the clock hardware
.sys_ck(200.MHz())
Expand Down Expand Up @@ -148,7 +160,7 @@ mod app {
// c0.enable();

info!("PWM enabled");
assert_eq!(ccdr.clocks.pll1_q_ck().unwrap().raw(), 32_000_000);
// assert_eq!(ccdr.clocks.pll1_q_ck().unwrap().raw(), 32_000_000);
info!("PLL1Q:");
// https://github.com/stm32-rs/stm32h7xx-hal/issues/369 This needs to be stolen. Grrr I hate the imaturity of the stm32-hal

Expand Down Expand Up @@ -291,6 +303,7 @@ mod app {
blink::spawn().ok();
send_data_internal::spawn(r).ok();
display_data::spawn(s).ok();
// sbg_power_on::spawn().ok();

(
SharedResources {
Expand All @@ -300,11 +313,12 @@ mod app {
sbg_manager,
can_command_manager,
can_data_manager,
sbg_power,

},
LocalResources {
led_red,
led_green,
sbg_power,
},
)
}
Expand Down Expand Up @@ -384,6 +398,16 @@ mod app {
});
}

#[task(priority = 3, shared = [sbg_power])]
async fn sbg_power_on(mut cx: sbg_power_on::Context) {
loop {
cx.shared.sbg_power.lock(|sbg| {
sbg.set_high();
});
Mono::delay(10000.millis()).await;
}
}

// Might be the wrong interrupt
#[task(priority = 3, binds = FDCAN2_IT0, shared = [can_data_manager, data_manager])]
fn can_data(mut cx: can_data::Context) {
Expand Down Expand Up @@ -436,10 +460,12 @@ mod app {
}
}

#[task(priority = 3, local = [sbg_power], shared = [&em])]
async fn sleep_system(cx: sleep_system::Context) {
#[task(priority = 3, shared = [&em, sbg_power])]
async fn sleep_system(mut cx: sleep_system::Context) {
// Turn off the SBG and CAN, also start a timer to wake up the system. Put the chip in sleep mode.
cx.local.sbg_power.set_low();
cx.shared.sbg_power.lock(|sbg| {
sbg.set_low();
});
}

extern "Rust" {
Expand Down
3 changes: 2 additions & 1 deletion boards/nav/src/sbg_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ impl SBGManager {
});
info!("Transfer started");

while !transfer.get_transfer_complete_flag() {}
// while !transfer.get_transfer_complete_flag() {}
// info!("Transfer complete");
// info!("{}", unsafe { SBG_BUFFER.assume_init_read() });

Expand Down Expand Up @@ -196,6 +196,7 @@ pub async fn sbg_sd_task(
* Handles the SBG data.
*/
pub fn sbg_dma(mut cx: crate::app::sbg_dma::Context) {
info!("DMA interrupt");
cx.shared.sbg_manager.lock(|sbg| {
match &mut sbg.xfer {
Some(xfer) => {
Expand Down
4 changes: 2 additions & 2 deletions boards/recovery/src/communication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl CanDevice0 {
for message in &mut self.can.rx_fifo_0 {
match from_bytes::<Message>(message.data()) {
Ok(data) => {
info!("Sender: {:?}", data.clone());
// info!("Sender: {:?}", data.clone());
data_manager.handle_data(data)?;
}
Err(e) => {
Expand All @@ -174,7 +174,7 @@ impl CanDevice0 {
for message in &mut self.can.rx_fifo_1 {
match from_bytes::<Message>(message.data()) {
Ok(data) => {
info!("CAN Command: {:?}", data.clone());
// info!("CAN Command: {:?}", data.clone());
data_manager.handle_data(data)?;
}
Err(e) => {
Expand Down
7 changes: 5 additions & 2 deletions boards/recovery/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,13 @@ mod app {
/* GPIO config */
let led_green = pins.pa03.into_push_pull_output();
let led_red = pins.pb04.into_push_pull_output();
let mut main_ematch = pins.pb12.into_push_pull_output();
main_ematch.set_high().ok();
loop {}

let gpio = GPIOManager::new(
// pins switched from schematic
pins.pb12.into_push_pull_output(),
main_ematch,
pins.pb11.into_push_pull_output(),
);
/* State Machine config */
Expand Down Expand Up @@ -323,7 +327,6 @@ mod app {
/// Handles the CAN0 interrupt.
#[task(binds = CAN0, shared = [can0, data_manager, &em])]
fn can0(mut cx: can0::Context) {
info!("CAN0 interrupt");
cx.shared.can0.lock(|can| {
cx.shared.data_manager.lock(|data_manager| {
cx.shared.em.run(|| {
Expand Down