Skip to content

Commit

Permalink
Add firmware_test task to main.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickdewid committed Mar 26, 2024
1 parent 148269e commit 619ae4e
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions m-ecu/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ mod app {
>,
led: vecraft::led::Led,
watchdog: SystemWindowWatchdog,
toggle: bool,
}

#[init]
Expand Down Expand Up @@ -193,6 +194,7 @@ mod app {
power2_enable.set_high();

firmware_state::spawn().ok();
// firmware_test::spawn().ok();

watchdog.start(75.millis());

Expand Down Expand Up @@ -245,6 +247,7 @@ mod app {
gpiob.pb12.into_push_pull_output(),
),
watchdog,
toggle: false,
},
init::Monotonics(mono),
)
Expand Down Expand Up @@ -296,6 +299,19 @@ mod app {
firmware_state::spawn_after(50.millis().into()).unwrap();
}

#[task(priority = 2, shared = [state, canbus1], local = [toggle])]
fn firmware_test(mut ctx: firmware_test::Context) {
if *ctx.local.toggle {
*ctx.local.toggle = false;
ctx.shared.state.lock(|state| state.set_ident(false));
} else {
*ctx.local.toggle = true;
ctx.shared.state.lock(|state| state.set_ident(true));
}

firmware_test::spawn_after(500.millis().into()).unwrap();
}

#[task(binds = FDCAN1_IT0, priority = 2, shared = [canbus1, state, console], local = [pwm0, pwm1])]
fn can1_event(mut ctx: can1_event::Context) {
let is_bus_error = ctx.shared.canbus1.lock(|canbus1| canbus1.is_bus_error());
Expand Down

0 comments on commit 619ae4e

Please sign in to comment.