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

Reset the board when a panic occurs. #85

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 0 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ debug = true
[profile.release]
# symbols are nice and they don't increase the size on Flash
#debug = true
debug = 1
#lto = true There is an issue with this where it says the interrupts symbol is defined multiple times. Only happens for the STM32H7XX.
opt-level = 1

Expand Down
1 change: 0 additions & 1 deletion boards/camera/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ edition = "2021"
cortex-m = { workspace = true }
cortex-m-rt = "^0.7.0"
cortex-m-rtic = "1.1.3"
panic-halt = "0.2.0"
systick-monotonic = "1.0.1"
defmt = "0.3.2"
postcard = "1.0.2"
Expand Down
8 changes: 7 additions & 1 deletion boards/camera/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@
use hal::gpio::{Pin, PushPullOutput, PB16, PB17};
use hal::prelude::*;
use mcan::messageram::SharedMemory;
use panic_halt as _;
use systick_monotonic::*;

/// Custom panic handler.
/// Reset the system if a panic occurs.
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
atsamd_hal::pac::SCB::sys_reset();
}

#[rtic::app(device = hal::pac, peripherals = true, dispatchers = [EVSYS_0, EVSYS_1, EVSYS_2])]
mod app {

Expand Down Expand Up @@ -118,7 +124,7 @@
/// Idle task for when no other tasks are running.
#[idle]
fn idle(_: idle::Context) -> ! {
loop {}

Check warning on line 127 in boards/camera/src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

empty `loop {}` wastes CPU cycles

warning: empty `loop {}` wastes CPU cycles --> boards/camera/src/main.rs:127:9 | 127 | loop {} | ^^^^^^^ | = help: you should either use `panic!()` or add a call pausing or sleeping the thread to the loop body = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_loop = note: `#[warn(clippy::empty_loop)]` on by default
}

/// Handles the CAN0 interrupt.
Expand Down
1 change: 0 additions & 1 deletion boards/communication/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ edition = "2021"
cortex-m = { workspace = true }
cortex-m-rt = "^0.7.0"
cortex-m-rtic = "1.1.3"
panic-halt = "0.2.0"
systick-monotonic = "1.0.1"
defmt = "0.3.2"
postcard = "1.0.2"
Expand Down
8 changes: 4 additions & 4 deletions boards/communication/src/communication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
use atsamd_hal::pac::SERCOM5;
use atsamd_hal::prelude::_embedded_hal_serial_Read;
use atsamd_hal::sercom;
use atsamd_hal::sercom::uart;
use atsamd_hal::sercom::uart::Uart;
use atsamd_hal::sercom::uart::{RxDuplex, TxDuplex};
use atsamd_hal::sercom::uart;
use atsamd_hal::typelevel::Increment;
use common_arm::mcan;
use common_arm::mcan::message::{rx, Raw};
use common_arm::mcan::tx_buffers::DynTx;
use common_arm::{herror, HydraError};
use heapless::Vec;
use heapless::HistoryBuffer;
use heapless::Vec;
use mavlink::embedded::Read;
use mcan::bus::Can;
use mcan::embedded_can as ecan;
Expand Down Expand Up @@ -59,26 +59,26 @@
}

pub struct CanDevice0 {
pub can: Can<
'static,
Can0,
Dependencies<Can0, Gclk0Id, Pin<PA23, Alternate<I>>, Pin<PA22, Alternate<I>>, CAN0>,
Capacities,
>,

Check warning on line 67 in boards/communication/src/communication.rs

View workflow job for this annotation

GitHub Actions / clippy

very complex type used. Consider factoring parts into `type` definitions

warning: very complex type used. Consider factoring parts into `type` definitions --> boards/communication/src/communication.rs:62:14 | 62 | pub can: Can< | ______________^ 63 | | 'static, 64 | | Can0, 65 | | Dependencies<Can0, Gclk0Id, Pin<PA23, Alternate<I>>, Pin<PA22, Alternate<I>>, CAN0>, 66 | | Capacities, 67 | | >, | |_____^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity = note: `#[warn(clippy::type_complexity)]` on by default
line_interrupts: OwnedInterruptSet<Can0, EnabledLine0>,
}

impl CanDevice0 {
pub fn new<S>(
can_rx: Pin<PA23, AlternateI>,
can_tx: Pin<PA22, AlternateI>,
pclk_can: Pclk<Can0, Gclk0Id>,
ahb_clock: AhbClk<Can0>,
peripheral: CAN0,
gclk0: S,
can_memory: &'static mut SharedMemory<Capacities>,
loopback: bool,
) -> (Self, S::Inc)

Check warning on line 81 in boards/communication/src/communication.rs

View workflow job for this annotation

GitHub Actions / clippy

this function has too many arguments (8/7)

warning: this function has too many arguments (8/7) --> boards/communication/src/communication.rs:72:5 | 72 | / pub fn new<S>( 73 | | can_rx: Pin<PA23, AlternateI>, 74 | | can_tx: Pin<PA22, AlternateI>, 75 | | pclk_can: Pclk<Can0, Gclk0Id>, ... | 80 | | loopback: bool, 81 | | ) -> (Self, S::Inc) | |_______________________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments = note: `#[warn(clippy::too_many_arguments)]` on by default
where
S: Source<Id = Gclk0Id> + Increment,
{
Expand Down Expand Up @@ -296,19 +296,19 @@
self.buf.write(data);
let (_header, msg) =
mavlink::read_versioned_msg(&mut self.radio.receiver, mavlink::MavlinkVersion::V2)?;
// Do we need the header?
// Do we need the header?
match msg {
mavlink::uorocketry::MavMessage::POSTCARD_MESSAGE(msg) => {
return Ok(postcard::from_bytes::<Message>(&msg.message)?);

Check warning on line 302 in boards/communication/src/communication.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> boards/communication/src/communication.rs:302:21 | 302 | return Ok(postcard::from_bytes::<Message>(&msg.message)?); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return = note: `#[warn(clippy::needless_return)]` on by default help: remove `return` | 302 - return Ok(postcard::from_bytes::<Message>(&msg.message)?); 302 + Ok(postcard::from_bytes::<Message>(&msg.message)?) |
// weird Ok syntax to coerce to hydra error type.
}
_ => {
herror!(Error,ErrorContext::UnkownPostcardMessage);
herror!(Error, ErrorContext::UnkownPostcardMessage);
return Err(mavlink::error::MessageReadError::Io.into());

Check warning on line 307 in boards/communication/src/communication.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> boards/communication/src/communication.rs:307:21 | 307 | return Err(mavlink::error::MessageReadError::Io.into()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 307 - return Err(mavlink::error::MessageReadError::Io.into()); 307 + Err(mavlink::error::MessageReadError::Io.into()) |
}
}
} else {
return Err(mavlink::error::MessageReadError::Io.into());

Check warning on line 311 in boards/communication/src/communication.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> boards/communication/src/communication.rs:311:13 | 311 | return Err(mavlink::error::MessageReadError::Io.into()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 311 - return Err(mavlink::error::MessageReadError::Io.into()); 311 + Err(mavlink::error::MessageReadError::Io.into()) |
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions boards/communication/src/health.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
//! Would've liked to have this live in common-arm-atsame but the pins and adc are not standardised
//! for all boards which poses the problem of giving an adc to a wrong pin in a generic way.

use atsamd_hal::gpio::{
Alternate, Pin, B, PB00, PB01, PB02, PB03, PB05, PB06, PB07, PB08, PB09,
};
use atsamd_hal::gpio::{Alternate, Pin, B, PB00, PB01, PB02, PB03, PB05, PB06, PB07, PB08, PB09};
use atsamd_hal::{adc::Adc, ehal::adc::OneShot, pac::ADC0, pac::ADC1};
use common_arm::HealthMonitorChannels;

Expand Down Expand Up @@ -57,19 +55,19 @@
}

impl HealthMonitorChannelsCommunication {
pub fn new(
reader: Adc<ADC0>,
reader1: Adc<ADC1>,
pin_3v3: Pin<PB01, Alternate<B>>,
pin_5v: Pin<PB02, Alternate<B>>,
pin_pyro: Pin<PB03, Alternate<B>>,
pin_vcc: Pin<PB00, Alternate<B>>,
pin_ext_3v3: Pin<PB06, Alternate<B>>,
pin_ext_5v: Pin<PB07, Alternate<B>>,
pin_int_5v: Pin<PB08, Alternate<B>>,
pin_int_3v3: Pin<PB09, Alternate<B>>,
pin_failover: Pin<PB05, Alternate<B>>,
) -> Self {

Check warning on line 70 in boards/communication/src/health.rs

View workflow job for this annotation

GitHub Actions / clippy

this function has too many arguments (11/7)

warning: this function has too many arguments (11/7) --> boards/communication/src/health.rs:58:5 | 58 | / pub fn new( 59 | | reader: Adc<ADC0>, 60 | | reader1: Adc<ADC1>, 61 | | pin_3v3: Pin<PB01, Alternate<B>>, ... | 69 | | pin_failover: Pin<PB05, Alternate<B>>, 70 | | ) -> Self { | |_____________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_many_arguments
HealthMonitorChannelsCommunication {
reader,
reader1,
Expand Down
12 changes: 9 additions & 3 deletions boards/communication/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,31 @@
use communication::Capacities;
use communication::{RadioDevice, RadioManager};
use data_manager::DataManager;
use hal::adc::Adc;
use hal::clock::v2::pclk::Pclk;
use hal::clock::v2::Source;
use health::HealthMonitorChannelsCommunication;
use hal::adc::Adc;
use hal::gpio::Pins;
use hal::gpio::{
Alternate, Output, Pin, PushPull, PushPullOutput, C, PA05, PB12, PB13, PB14, PB15,
};
use hal::prelude::*;
use hal::sercom::{spi, spi::Config, spi::Duplex, spi::Pads, spi::Spi, IoSet1, Sercom4};
use health::HealthMonitorChannelsCommunication;
use mcan::messageram::SharedMemory;
use messages::command::RadioRate;
use messages::health::Health;
use messages::state::State;
use messages::*;
use panic_halt as _;
use systick_monotonic::*;
use types::*;

/// Custom panic handler.
/// Reset the system if a panic occurs.
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
atsamd_hal::pac::SCB::sys_reset();
}

#[rtic::app(device = hal::pac, peripherals = true, dispatchers = [EVSYS_0, EVSYS_1, EVSYS_2])]
mod app {

Expand All @@ -51,21 +57,21 @@
#[local]
struct Local {
led: Pin<PA05, PushPullOutput>,
sd_manager: SdManager<
Spi<
Config<
Pads<
hal::pac::SERCOM4,
IoSet1,
Pin<PB15, Alternate<C>>,
Pin<PB12, Alternate<C>>,
Pin<PB13, Alternate<C>>,
>,
>,
Duplex,
>,
Pin<PB14, Output<PushPull>>,
>,

Check warning on line 74 in boards/communication/src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

very complex type used. Consider factoring parts into `type` definitions

warning: very complex type used. Consider factoring parts into `type` definitions --> boards/communication/src/main.rs:60:21 | 60 | sd_manager: SdManager< | _____________________^ 61 | | Spi< 62 | | Config< 63 | | Pads< ... | 73 | | Pin<PB14, Output<PushPull>>, 74 | | >, | |_________^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#type_complexity
}

#[monotonic(binds = SysTick, default = true)]
Expand Down Expand Up @@ -191,7 +197,7 @@
/// Idle task for when no other tasks are running.
#[idle]
fn idle(_: idle::Context) -> ! {
loop {}

Check warning on line 200 in boards/communication/src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

empty `loop {}` wastes CPU cycles

warning: empty `loop {}` wastes CPU cycles --> boards/communication/src/main.rs:200:9 | 200 | loop {} | ^^^^^^^ | = help: you should either use `panic!()` or add a call pausing or sleeping the thread to the loop body = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_loop = note: `#[warn(clippy::empty_loop)]` on by default
}

/// Handles the CAN0 interrupt.
Expand Down Expand Up @@ -241,10 +247,10 @@
let mut buf: [u8; 255] = [0; 255];
let msg_ser = postcard::to_slice_cobs(&m, &mut buf)?;
if let Some(mut file) = manager.file.take() {
manager.write(&mut file, &msg_ser)?;

Check warning on line 250 in boards/communication/src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> boards/communication/src/main.rs:250:42 | 250 | manager.write(&mut file, &msg_ser)?; | ^^^^^^^^ help: change this to: `msg_ser` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default
manager.file = Some(file);
} else if let Ok(mut file) = manager.open_file("log.txt") {
manager.write(&mut file, &msg_ser)?;

Check warning on line 253 in boards/communication/src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> boards/communication/src/main.rs:253:42 | 253 | manager.write(&mut file, &msg_ser)?; | ^^^^^^^^ help: change this to: `msg_ser` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow
manager.file = Some(file);
}
Ok(())
Expand Down
4 changes: 2 additions & 2 deletions boards/communication/src/types.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use atsamd_hal::gpio::*;
use atsamd_hal::sercom::uart::EightBit;
use atsamd_hal::sercom::{uart, IoSet1, Sercom5};
use atsamd_hal::gpio::*;
use messages::sender::Sender;
use messages::sender::Sender::CommunicationBoard;

Expand All @@ -13,4 +13,4 @@ pub static COM_ID: Sender = CommunicationBoard;
// Ground Station
// -------
pub type GroundStationPads = uart::PadsFromIds<Sercom5, IoSet1, PB17, PB16>;
pub type GroundStationUartConfig = uart::Config<GroundStationPads, EightBit>;
pub type GroundStationUartConfig = uart::Config<GroundStationPads, EightBit>;
1 change: 0 additions & 1 deletion boards/power/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ edition = "2021"
cortex-m = { workspace = true }
cortex-m-rt = "^0.7.0"
cortex-m-rtic = "1.1.3"
panic-halt = "0.2.0"
systick-monotonic = "1.0.1"
defmt = "0.3.2"
postcard = "1.0.2"
Expand Down
8 changes: 7 additions & 1 deletion boards/power/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@
use hal::gpio::{Pin, Pins, PushPullOutput, PB16, PB17};
use hal::prelude::*;
use mcan::messageram::SharedMemory;
use panic_halt as _;
use systick_monotonic::*;

/// Custom panic handler.
/// Reset the system if a panic occurs.
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
atsamd_hal::pac::SCB::sys_reset();
}

#[rtic::app(device = hal::pac, peripherals = true, dispatchers = [EVSYS_0, EVSYS_1, EVSYS_2])]
mod app {
use super::*;
Expand All @@ -26,7 +32,7 @@
#[shared]
struct Shared {
em: ErrorManager,
data_manager: DataManager,

Check warning on line 35 in boards/power/src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

fields `data_manager` and `can0` are never read

warning: fields `data_manager` and `can0` are never read --> boards/power/src/main.rs:35:9 | 35 | data_manager: DataManager, | ^^^^^^^^^^^^ 36 | can0: CanDevice0, | ^^^^ ... 52 | fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) { | ------ fields in this struct
can0: CanDevice0,
}

Expand Down Expand Up @@ -104,7 +110,7 @@
/// Idle task for when no other tasks are running.
#[idle]
fn idle(_: idle::Context) -> ! {
loop {}

Check warning on line 113 in boards/power/src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

empty `loop {}` wastes CPU cycles

warning: empty `loop {}` wastes CPU cycles --> boards/power/src/main.rs:113:9 | 113 | loop {} | ^^^^^^^ | = help: you should either use `panic!()` or add a call pausing or sleeping the thread to the loop body = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_loop = note: `#[warn(clippy::empty_loop)]` on by default
}

// #[task(local = [adc_test, adc_pin], shared = [&em])]
Expand Down
1 change: 0 additions & 1 deletion boards/recovery/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ edition = "2021"
cortex-m = { workspace = true }
cortex-m-rt = "^0.7.0"
cortex-m-rtic = "1.1.3"
panic-halt = "0.2.0"
systick-monotonic = "1.0.1"
defmt = "0.3.2"
postcard = "1.0.2"
Expand Down
20 changes: 12 additions & 8 deletions boards/recovery/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,17 @@
use hal::prelude::*;
use mcan::messageram::SharedMemory;
use messages::*;
use panic_halt as _;
use state_machine::{StateMachine, StateMachineContext};
use systick_monotonic::*;
use types::COM_ID;

/// Custom panic handler.
/// Reset the system if a panic occurs.
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
atsamd_hal::pac::SCB::sys_reset();
}

#[rtic::app(device = hal::pac, peripherals = true, dispatchers = [EVSYS_0, EVSYS_1, EVSYS_2])]
mod app {
use super::*;
Expand Down Expand Up @@ -127,7 +133,7 @@
/// Idle task for when no other tasks are running.
#[idle]
fn idle(_: idle::Context) -> ! {
loop {}

Check warning on line 136 in boards/recovery/src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

empty `loop {}` wastes CPU cycles

warning: empty `loop {}` wastes CPU cycles --> boards/recovery/src/main.rs:136:9 | 136 | loop {} | ^^^^^^^ | = help: you should either use `panic!()` or add a call pausing or sleeping the thread to the loop body = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_loop = note: `#[warn(clippy::empty_loop)]` on by default
}

#[task(priority = 3, local = [fired: bool = false], shared=[gpio, &em])]
Expand Down Expand Up @@ -184,14 +190,12 @@
#[task(binds = CAN0, shared = [can0, data_manager, &em])]
fn can0(mut cx: can0::Context) {
cx.shared.can0.lock(|can| {
cx.shared
.data_manager
.lock(|data_manager| {
cx.shared.em.run(|| {
can.process_data(data_manager)?;
Ok(())
});
cx.shared.data_manager.lock(|data_manager| {
cx.shared.em.run(|| {
can.process_data(data_manager)?;
Ok(())
});
});
});
}

Expand Down
1 change: 0 additions & 1 deletion boards/sensor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ edition = "2021"
cortex-m = { workspace = true }
cortex-m-rt = "^0.7.0"
cortex-m-rtic = "1.1.3"
panic-halt = "0.2.0"
systick-monotonic = "1.0.1"
defmt = "0.3.2"
postcard = "1.0.2"
Expand Down
22 changes: 12 additions & 10 deletions boards/sensor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,19 @@
use mcan::messageram::SharedMemory;
use messages::sensor::Sensor;
use messages::*;
use panic_halt as _;
use sbg_manager::{sbg_dma, sbg_handle_data, sbg_sd_task, SBGManager};
//use sbg_manager::{sbg_dma, sbg_handle_data, SBGManager};

use sbg_rs::sbg::{CallbackData, SBG_BUFFER_SIZE};

use systick_monotonic::*;
use types::*;

/// Custom panic handler.
/// Reset the system if a panic occurs.
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
atsamd_hal::pac::SCB::sys_reset();
}

#[rtic::app(device = hal::pac, peripherals = true, dispatchers = [EVSYS_0, EVSYS_1, EVSYS_2])]
mod app {
use super::*;
Expand Down Expand Up @@ -160,7 +164,7 @@
/// Idle task for when no other tasks are running.
#[idle]
fn idle(_: idle::Context) -> ! {
loop {}

Check warning on line 167 in boards/sensor/src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

empty `loop {}` wastes CPU cycles

warning: empty `loop {}` wastes CPU cycles --> boards/sensor/src/main.rs:167:9 | 167 | loop {} | ^^^^^^^ | = help: you should either use `panic!()` or add a call pausing or sleeping the thread to the loop body = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_loop = note: `#[warn(clippy::empty_loop)]` on by default
}

#[task(local = [sbg_power_pin], shared = [sd_manager, &em])]
Expand All @@ -182,14 +186,12 @@
#[task(priority = 3, binds = CAN0, shared = [can, data_manager, &em])]
fn can0(mut cx: can0::Context) {
cx.shared.can.lock(|can| {
cx.shared
.data_manager
.lock(|manager| {
cx.shared.em.run(|| {
can.process_data(manager)?;
Ok(())
});
cx.shared.data_manager.lock(|manager| {
cx.shared.em.run(|| {
can.process_data(manager)?;
Ok(())
});
});
});
}

Expand Down
1 change: 0 additions & 1 deletion boards/sensor_v2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
panic-halt = "0.2.0"
cortex-m = { workspace = true }
cortex-m-rt = "^0.7.0"
cortex-m-rtic = "1.1.3"
Expand Down
7 changes: 6 additions & 1 deletion boards/sensor_v2/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@
use stm32h7xx_hal::gpio::{Output, PushPull};
use stm32h7xx_hal::prelude::*;

use panic_halt as _;
/// Custom panic handler.
/// Reset the system if a panic occurs.
#[panic_handler]
fn panic(info: &core::panic::PanicInfo) -> ! {

Check warning on line 16 in boards/sensor_v2/src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `info`

warning: unused variable: `info` --> boards/sensor_v2/src/main.rs:16:10 | 16 | fn panic(info: &core::panic::PanicInfo) -> ! { | ^^^^ help: if this is intentional, prefix it with an underscore: `_info` | = note: `#[warn(unused_variables)]` on by default
stm32h7xx_hal::pac::SCB::sys_reset();
}

#[rtic::app(device = stm32h7xx_hal::stm32, dispatchers = [EXTI0, EXTI1])]
mod app {
Expand All @@ -18,7 +23,7 @@

#[shared]
struct SharedResources {
data_manager: DataManager,

Check warning on line 26 in boards/sensor_v2/src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

field `data_manager` is never read

warning: field `data_manager` is never read --> boards/sensor_v2/src/main.rs:26:9 | 26 | data_manager: DataManager, | ^^^^^^^^^^^^ ... 35 | fn init(mut ctx: init::Context) -> (SharedResources, LocalResources, init::Monotonics) { | --------------- field in this struct
}
#[local]
struct LocalResources {
Expand All @@ -27,7 +32,7 @@
}

#[init]
fn init(mut ctx: init::Context) -> (SharedResources, LocalResources, init::Monotonics) {

Check warning on line 35 in boards/sensor_v2/src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

variable does not need to be mutable

warning: variable does not need to be mutable --> boards/sensor_v2/src/main.rs:35:13 | 35 | fn init(mut ctx: init::Context) -> (SharedResources, LocalResources, init::Monotonics) { | ----^^^ | | | help: remove this `mut` | = note: `#[warn(unused_mut)]` on by default
let pwr = ctx.device.PWR.constrain();
// We could use smps, but the board is not designed for it
// let pwrcfg = example_power!(pwr).freeze();
Expand All @@ -41,7 +46,7 @@
let gpioc = ctx.device.GPIOC.split(ccdr.peripheral.GPIOC);

// Button
let mut button = gpioc.pc13.into_floating_input();

Check warning on line 49 in boards/sensor_v2/src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

variable does not need to be mutable

warning: variable does not need to be mutable --> boards/sensor_v2/src/main.rs:49:13 | 49 | let mut button = gpioc.pc13.into_floating_input(); | ----^^^^^^ | | | help: remove this `mut`
(
SharedResources {
data_manager: DataManager::new(),
Expand All @@ -55,12 +60,12 @@
}

#[idle]
fn idle(mut ctx: idle::Context) -> ! {

Check warning on line 63 in boards/sensor_v2/src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

variable does not need to be mutable

warning: variable does not need to be mutable --> boards/sensor_v2/src/main.rs:63:13 | 63 | fn idle(mut ctx: idle::Context) -> ! { | ----^^^ | | | help: remove this `mut`

Check warning on line 63 in boards/sensor_v2/src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `ctx`

warning: unused variable: `ctx` --> boards/sensor_v2/src/main.rs:63:17 | 63 | fn idle(mut ctx: idle::Context) -> ! { | ^^^ help: if this is intentional, prefix it with an underscore: `_ctx`
loop {}

Check warning on line 64 in boards/sensor_v2/src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

empty `loop {}` wastes CPU cycles

warning: empty `loop {}` wastes CPU cycles --> boards/sensor_v2/src/main.rs:64:9 | 64 | loop {} | ^^^^^^^ | = help: you should either use `panic!()` or add a call pausing or sleeping the thread to the loop body = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_loop = note: `#[warn(clippy::empty_loop)]` on by default
}

#[task(local = [button, led])]
fn sleep_system(mut cx: sleep_system::Context) {

Check warning on line 68 in boards/sensor_v2/src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

variable does not need to be mutable

warning: variable does not need to be mutable --> boards/sensor_v2/src/main.rs:68:21 | 68 | fn sleep_system(mut cx: sleep_system::Context) { | ----^^ | | | help: remove this `mut`

Check warning on line 68 in boards/sensor_v2/src/main.rs

View workflow job for this annotation

GitHub Actions / clippy

unused variable: `cx`

warning: unused variable: `cx` --> boards/sensor_v2/src/main.rs:68:25 | 68 | fn sleep_system(mut cx: sleep_system::Context) { | ^^ help: if this is intentional, prefix it with an underscore: `_cx`
// Turn off the SBG and CAN
}
}
7 changes: 3 additions & 4 deletions libraries/common-arm/src/health/health_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,15 @@
match data {
Some(x) => {
if nominal.contains(&x) {
return HealthState::Nominal;

Check warning on line 66 in libraries/common-arm/src/health/health_manager.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> libraries/common-arm/src/health/health_manager.rs:66:17 | 66 | return HealthState::Nominal; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return = note: `#[warn(clippy::needless_return)]` on by default help: remove `return` | 66 - return HealthState::Nominal; 66 + HealthState::Nominal |
}
else {
warn!("Unsafe Voltage");
} else {
// warn!("Unsafe Voltage");
HealthState::Error
}
},
}
None => {
warn!("No data");
return HealthState::Warning;

Check warning on line 74 in libraries/common-arm/src/health/health_manager.rs

View workflow job for this annotation

GitHub Actions / clippy

unneeded `return` statement

warning: unneeded `return` statement --> libraries/common-arm/src/health/health_manager.rs:74:13 | 74 | return HealthState::Warning; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return help: remove `return` | 74 - return HealthState::Warning; 74 + HealthState::Warning |
}
}
}
Loading