diff --git a/Cargo.lock b/Cargo.lock index fd6b2dc4..e1c52042 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -146,7 +146,6 @@ dependencies = [ "enum_dispatch", "heapless", "messages", - "panic-halt", "postcard", "systick-monotonic", "typenum", @@ -259,7 +258,6 @@ dependencies = [ "embedded-sdmmc", "heapless", "messages", - "panic-halt", "postcard", "systick-monotonic", "typenum", @@ -851,7 +849,6 @@ dependencies = [ "enum_dispatch", "heapless", "messages", - "panic-halt", "postcard", "systick-monotonic", "typenum", @@ -1022,7 +1019,6 @@ dependencies = [ "enum_dispatch", "heapless", "messages", - "panic-halt", "postcard", "systick-monotonic", "typenum", @@ -1188,7 +1184,6 @@ dependencies = [ "embedded-sdmmc", "heapless", "messages", - "panic-halt", "postcard", "sbg-rs", "systick-monotonic", @@ -1205,7 +1200,6 @@ dependencies = [ "cortex-m-rt", "cortex-m-rtic", "messages", - "panic-halt", "postcard", "stm32h7xx-hal", ] diff --git a/Cargo.toml b/Cargo.toml index e64c9d8e..fa2ef33e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 diff --git a/boards/camera/Cargo.toml b/boards/camera/Cargo.toml index b5fb984f..567f8a36 100644 --- a/boards/camera/Cargo.toml +++ b/boards/camera/Cargo.toml @@ -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" diff --git a/boards/camera/src/main.rs b/boards/camera/src/main.rs index 2ab8fada..a99c7e69 100644 --- a/boards/camera/src/main.rs +++ b/boards/camera/src/main.rs @@ -21,9 +21,15 @@ use hal::gpio::Pins; 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 { diff --git a/boards/communication/Cargo.toml b/boards/communication/Cargo.toml index 9dbf4a8f..fd97f157 100644 --- a/boards/communication/Cargo.toml +++ b/boards/communication/Cargo.toml @@ -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" diff --git a/boards/communication/src/communication.rs b/boards/communication/src/communication.rs index fe2ea22a..1ea183af 100644 --- a/boards/communication/src/communication.rs +++ b/boards/communication/src/communication.rs @@ -13,16 +13,16 @@ use atsamd_hal::pac::MCLK; 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; @@ -296,14 +296,14 @@ impl RadioManager { 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::(&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()); } } diff --git a/boards/communication/src/health.rs b/boards/communication/src/health.rs index af8a56bb..1f5cbd97 100644 --- a/boards/communication/src/health.rs +++ b/boards/communication/src/health.rs @@ -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; diff --git a/boards/communication/src/main.rs b/boards/communication/src/main.rs index 808a1a39..dcd1ea95 100644 --- a/boards/communication/src/main.rs +++ b/boards/communication/src/main.rs @@ -15,25 +15,31 @@ use common_arm::*; 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 { diff --git a/boards/communication/src/types.rs b/boards/communication/src/types.rs index 8492d402..236121d8 100644 --- a/boards/communication/src/types.rs +++ b/boards/communication/src/types.rs @@ -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; @@ -13,4 +13,4 @@ pub static COM_ID: Sender = CommunicationBoard; // Ground Station // ------- pub type GroundStationPads = uart::PadsFromIds; -pub type GroundStationUartConfig = uart::Config; \ No newline at end of file +pub type GroundStationUartConfig = uart::Config; diff --git a/boards/power/Cargo.toml b/boards/power/Cargo.toml index a577cf29..56ae7a12 100644 --- a/boards/power/Cargo.toml +++ b/boards/power/Cargo.toml @@ -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" diff --git a/boards/power/src/main.rs b/boards/power/src/main.rs index 263933e3..405b1df4 100644 --- a/boards/power/src/main.rs +++ b/boards/power/src/main.rs @@ -16,9 +16,15 @@ use hal::clock::v2::Source; 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::*; diff --git a/boards/recovery/Cargo.toml b/boards/recovery/Cargo.toml index 8ed11ea2..e5460103 100644 --- a/boards/recovery/Cargo.toml +++ b/boards/recovery/Cargo.toml @@ -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" diff --git a/boards/recovery/src/main.rs b/boards/recovery/src/main.rs index 6613ba6c..bd08c8f8 100644 --- a/boards/recovery/src/main.rs +++ b/boards/recovery/src/main.rs @@ -21,11 +21,17 @@ use hal::gpio::{Pin, Pins, PushPullOutput, PB16, PB17}; 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::*; @@ -184,14 +190,12 @@ mod app { #[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(()) }); + }); }); } diff --git a/boards/sensor/Cargo.toml b/boards/sensor/Cargo.toml index 81539546..13142f56 100644 --- a/boards/sensor/Cargo.toml +++ b/boards/sensor/Cargo.toml @@ -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" diff --git a/boards/sensor/src/main.rs b/boards/sensor/src/main.rs index cba45357..96d1eea2 100644 --- a/boards/sensor/src/main.rs +++ b/boards/sensor/src/main.rs @@ -26,15 +26,19 @@ use hal::sercom::{spi, IoSet2, Sercom4}; 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::*; @@ -182,14 +186,12 @@ mod app { #[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(()) }); + }); }); } diff --git a/boards/sensor_v2/Cargo.toml b/boards/sensor_v2/Cargo.toml index 3f6d1bb1..53704102 100644 --- a/boards/sensor_v2/Cargo.toml +++ b/boards/sensor_v2/Cargo.toml @@ -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" diff --git a/boards/sensor_v2/src/main.rs b/boards/sensor_v2/src/main.rs index 2e3048e1..c1e00f58 100644 --- a/boards/sensor_v2/src/main.rs +++ b/boards/sensor_v2/src/main.rs @@ -10,7 +10,12 @@ use stm32h7xx_hal::gpio::Input; 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) -> ! { + stm32h7xx_hal::pac::SCB::sys_reset(); +} #[rtic::app(device = stm32h7xx_hal::stm32, dispatchers = [EXTI0, EXTI1])] mod app { diff --git a/libraries/common-arm/src/health/health_manager.rs b/libraries/common-arm/src/health/health_manager.rs index e2a86677..7b059ae4 100644 --- a/libraries/common-arm/src/health/health_manager.rs +++ b/libraries/common-arm/src/health/health_manager.rs @@ -64,12 +64,11 @@ fn get_status(data: Option, nominal: &RangeInclusive) -> HealthState { Some(x) => { if nominal.contains(&x) { return HealthState::Nominal; - } - else { - warn!("Unsafe Voltage"); + } else { + // warn!("Unsafe Voltage"); HealthState::Error } - }, + } None => { warn!("No data"); return HealthState::Warning;