Skip to content

Commit

Permalink
Fix bus error and set GPIO pins low
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickdewid committed Feb 16, 2024
1 parent 7c04e66 commit b93eafe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions hcu/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,8 @@ mod app {

writeln!(console, "Motion locked due to bus error").ok();
});

return;
}

while let Some(frame) = ctx.shared.canbus1.lock(|canbus1| canbus1.recv()) {
Expand Down
14 changes: 11 additions & 3 deletions m-ecu/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,11 @@ mod app {

let mut power2_enable = gpioe.pe2.into_push_pull_output();

let in2 = gpiob.pb0.into_push_pull_output();
let in1 = gpiob.pb1.into_push_pull_output();
let mut in2 = gpiob.pb0.into_push_pull_output();
let mut in1 = gpiob.pb1.into_push_pull_output();

in1.set_low();
in2.set_low();

power2_enable.set_high();

Expand Down Expand Up @@ -263,6 +266,8 @@ mod app {

if is_bus_error {
ctx.shared.state.lock(|state| state.set_bus_error(true));

return;
}

while let Some(frame) = ctx.shared.canbus1.lock(|canbus1| canbus1.recv()) {
Expand Down Expand Up @@ -342,7 +347,10 @@ mod app {
}
}
PGN::TorqueSpeedControl1 => {
if frame.pdu()[0] != PDU_NOT_AVAILABLE {
// TODO: Filter on destination address until the CAN filter is implemented
if frame.id().destination_address() == Some(crate::J1939_ADDRESS)
&& frame.pdu()[0] != PDU_NOT_AVAILABLE
{
let message = spn::TorqueSpeedControlMessage::from_pdu(frame.pdu());

let rpm = message
Expand Down

0 comments on commit b93eafe

Please sign in to comment.