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

Add defmt feature and derive error types #684

Merged
merged 3 commits into from
May 26, 2023
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
60 changes: 34 additions & 26 deletions crates.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,15 +171,17 @@
"features": [
"samd11c",
"unproven",
"dma"
"dma",
"defmt"
],
"target": "thumbv6m-none-eabi"
},
"samd11d": {
"features": [
"samd11d",
"unproven",
"dma"
"dma",
"defmt"
],
"target": "thumbv6m-none-eabi"
},
Expand All @@ -188,7 +190,8 @@
"samd21g",
"unproven",
"usb",
"dma"
"dma",
"defmt"
],
"target": "thumbv6m-none-eabi"
},
Expand All @@ -197,7 +200,8 @@
"samd21j",
"unproven",
"usb",
"dma"
"dma",
"defmt"
],
"target": "thumbv6m-none-eabi"
},
Expand All @@ -207,7 +211,8 @@
"unproven",
"usb",
"sdmmc",
"dma"
"dma",
"defmt"
],
"target": "thumbv7em-none-eabihf"
},
Expand All @@ -217,7 +222,8 @@
"unproven",
"usb",
"sdmmc",
"dma"
"dma",
"defmt"
],
"target": "thumbv7em-none-eabihf"
},
Expand All @@ -227,7 +233,8 @@
"unproven",
"usb",
"sdmmc",
"dma"
"dma",
"defmt"
],
"target": "thumbv7em-none-eabihf"
},
Expand All @@ -237,82 +244,83 @@
"unproven",
"usb",
"sdmmc",
"dma"
"dma",
"defmt"
],
"target": "thumbv7em-none-eabihf"
}
},
"hal_build_variants": {
"samd11c": {
"features": [ "samd11c", "unproven", "dma", "rtic" ],
"features": [ "samd11c", "unproven", "dma", "rtic", "defmt" ],
"target": "thumbv6m-none-eabi"
},
"samd11d": {
"features": [ "samd11d", "unproven", "dma", "rtic" ],
"features": [ "samd11d", "unproven", "dma", "rtic", "defmt" ],
"target": "thumbv6m-none-eabi"
},
"samd21e": {
"features": [ "samd21e", "unproven", "usb", "dma", "rtic" ],
"features": [ "samd21e", "unproven", "usb", "dma", "rtic", "defmt" ],
"target": "thumbv6m-none-eabi"
},
"samd21el": {
"features": [ "samd21el", "unproven", "dma", "rtic" ],
"features": [ "samd21el", "unproven", "dma", "rtic", "defmt" ],
"target": "thumbv6m-none-eabi"
},
"samd21g": {
"features": [ "samd21g", "unproven", "usb", "dma", "rtic" ],
"features": [ "samd21g", "unproven", "usb", "dma", "rtic", "defmt" ],
"target": "thumbv6m-none-eabi"
},
"samd21gl": {
"features": [ "samd21gl", "unproven", "dma", "rtic" ],
"features": [ "samd21gl", "unproven", "dma", "rtic", "defmt" ],
"target": "thumbv6m-none-eabi"
},
"samd21j": {
"features": [ "samd21j", "unproven", "usb", "dma", "rtic" ],
"features": [ "samd21j", "unproven", "usb", "dma", "rtic", "defmt" ],
"target": "thumbv6m-none-eabi"
},
"samd51g": {
"features": [ "samd51g", "unproven", "usb", "dma", "sdmmc", "rtic" ],
"features": [ "samd51g", "unproven", "usb", "dma", "sdmmc", "rtic", "defmt" ],
"target": "thumbv7em-none-eabihf"
},
"samd51j": {
"features": [ "samd51j", "unproven", "usb", "dma", "sdmmc", "rtic" ],
"features": [ "samd51j", "unproven", "usb", "dma", "sdmmc", "rtic", "defmt" ],
"target": "thumbv7em-none-eabihf"
},
"samd51n": {
"features": [ "samd51n", "unproven", "usb", "dma", "sdmmc", "rtic" ],
"features": [ "samd51n", "unproven", "usb", "dma", "sdmmc", "rtic", "defmt" ],
"target": "thumbv7em-none-eabihf"
},
"samd51p": {
"features": [ "samd51p", "unproven", "usb", "dma", "sdmmc", "rtic" ],
"features": [ "samd51p", "unproven", "usb", "dma", "sdmmc", "rtic", "defmt" ],
"target": "thumbv7em-none-eabihf"
},
"same51g": {
"features": [ "same51g", "unproven", "usb", "dma", "sdmmc", "rtic", "can" ],
"features": [ "same51g", "unproven", "usb", "dma", "sdmmc", "rtic", "can", "defmt" ],
"target": "thumbv7em-none-eabihf"
},
"same51j": {
"features": [ "same51j", "unproven", "usb", "dma", "sdmmc", "rtic", "can" ],
"features": [ "same51j", "unproven", "usb", "dma", "sdmmc", "rtic", "can", "defmt" ],
"target": "thumbv7em-none-eabihf"
},
"same51n": {
"features": [ "same51n", "unproven", "usb", "dma", "sdmmc", "rtic", "can" ],
"features": [ "same51n", "unproven", "usb", "dma", "sdmmc", "rtic", "can", "defmt" ],
"target": "thumbv7em-none-eabihf"
},
"same53j": {
"features": [ "same53j", "unproven", "usb", "dma", "sdmmc", "rtic" ],
"features": [ "same53j", "unproven", "usb", "dma", "sdmmc", "rtic", "defmt" ],
"target": "thumbv7em-none-eabihf"
},
"same53n": {
"features": [ "same53n", "unproven", "usb", "dma", "sdmmc", "rtic" ],
"features": [ "same53n", "unproven", "usb", "dma", "sdmmc", "rtic", "defmt" ],
"target": "thumbv7em-none-eabihf"
},
"same54n": {
"features": [ "same54n", "unproven", "usb", "dma", "sdmmc", "rtic", "can" ],
"features": [ "same54n", "unproven", "usb", "dma", "sdmmc", "rtic", "can", "defmt" ],
"target": "thumbv7em-none-eabihf"
},
"same54p": {
"features": [ "same54p", "unproven", "usb", "dma", "sdmmc", "rtic", "can" ],
"features": [ "same54p", "unproven", "usb", "dma", "sdmmc", "rtic", "can", "defmt" ],
"target": "thumbv7em-none-eabihf"
}
}
Expand Down
1 change: 1 addition & 0 deletions hal/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Unreleased Changes

- Add `defmt` feature and derive `defmt::Format` for error types (#684, obsoletes #522).
- Add `mcan` integration (#654)
- Fix incorrect PAC provided for `same51g` target
- Fix NVM User Row Mapping for `BOD12` Calibration Parameters
Expand Down
2 changes: 2 additions & 0 deletions hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ jlink_rtt = {version = "0.2", optional = true}
mcan-core = {version = "0.2", optional = true}
rtic-monotonic = {version = "1.0", optional = true}
usb-device = {version = "0.2", optional = true}
defmt = {version = "0.3.4", optional = true}

#===============================================================================
# PACs
Expand Down Expand Up @@ -184,6 +185,7 @@ sdmmc = ["embedded-sdmmc"]
unproven = ["embedded-hal/unproven"]
usb = ["usb-device"]
use_rtt = ["jlink_rtt"]
defmt = ["dep:defmt"]

#===============================================================================
# Implementation-details
Expand Down
1 change: 1 addition & 0 deletions hal/src/dmac/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ pub use dma_controller::*;
pub use transfer::*;

#[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
/// Runtime errors that may occur when dealing with DMA transfers.
pub enum Error {
/// Supplied buffers both have lengths > 1 beat, but not equal to each other
Expand Down
1 change: 1 addition & 0 deletions hal/src/gpio/dynpin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ impl DynRegisters {
///
/// [`DynPin`]s are not tracked and verified at compile-time, so run-time
/// operations are fallible. This `enum` represents the corresponding errors.
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Error {
/// The pin did not have the correct ID or mode for the requested operation
InvalidPinType,
Expand Down
1 change: 1 addition & 0 deletions hal/src/sercom/i2c/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ impl Status {

/// Errors available for I2C transactions
#[derive(Debug, Clone, Copy)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Error {
BusError,
ArbitrationLost,
Expand Down
2 changes: 2 additions & 0 deletions hal/src/sercom/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ pub mod impl_ehal;
/// Define the bit order of transactions
#[repr(u8)]
#[derive(Copy, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum BitOrder {
LsbFirst,
MsbFirst,
Expand Down Expand Up @@ -442,6 +443,7 @@ impl TryFrom<Status> for () {
/// The SPI peripheral only has two error types, buffer overflow and transaction
/// length error.
#[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Error {
Overflow,
LengthError,
Expand Down
1 change: 1 addition & 0 deletions hal/src/sercom/uart/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ bitflags! {

/// Errors available for UART transactions
#[derive(Debug, Clone, Copy)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Error {
/// Detected a parity error
ParityError,
Expand Down
2 changes: 2 additions & 0 deletions hal/src/thumbv7em/dsu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ pub struct Dsu {

/// Errors from hardware
#[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum PeripheralError {
/// Usually misaligned address of length
BusError,
}

/// Error from within the DSU
#[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Error {
/// Address or length was not word aligned
AlignmentError,
Expand Down
2 changes: 2 additions & 0 deletions hal/src/thumbv7em/nvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pub struct Nvm {

/// Errors generated by the NVM peripheral
#[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum PeripheralError {
/// NVM error
NvmError,
Expand All @@ -97,6 +98,7 @@ pub enum PeripheralError {
/// Driver errors
#[non_exhaustive]
#[derive(Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Error {
/// Address range outside of flash
NonFlash,
Expand Down
1 change: 1 addition & 0 deletions hal/src/thumbv7em/qspi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{
use core::marker::PhantomData;

#[derive(Debug, Clone, Copy, Eq, PartialEq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Error {
/// The command you selected cannot be performed by this function
CommandFunctionMismatch,
Expand Down