Skip to content

Commit

Permalink
Impl more standard traits for error types (#691)
Browse files Browse the repository at this point in the history
* Debug, Clone, Copy, Eq, PartialEq for all errors types
  • Loading branch information
jbeaurivage authored Jun 10, 2023
1 parent a971cbf commit 063fd8f
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 8 deletions.
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

- Implement `Debug, Clone, Copy, Eq, PartialEq` for all HAL error types (#691).
- Replace homebrew time library with `fugit` (#672)
- Add `defmt` feature and derive `defmt::Format` for error types (#684, obsoletes #522).
- Add `mcan` integration (#654)
Expand Down
2 changes: 1 addition & 1 deletion hal/src/dmac/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ pub use channel::*;
pub use dma_controller::*;
pub use transfer::*;

#[derive(Debug)]
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
/// Runtime errors that may occur when dealing with DMA transfers.
pub enum Error {
Expand Down
2 changes: 1 addition & 1 deletion hal/src/sercom/i2c/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl Status {
}

/// Errors available for I2C transactions
#[derive(Debug, Clone, Copy)]
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Error {
BusError,
Expand Down
2 changes: 1 addition & 1 deletion hal/src/sercom/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ impl TryFrom<Status> for () {
///
/// The SPI peripheral only has two error types, buffer overflow and transaction
/// length error.
#[derive(Debug)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Error {
Overflow,
Expand Down
2 changes: 1 addition & 1 deletion hal/src/sercom/uart/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ bitflags! {
//=============================================================================

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

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

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

/// Errors generated by the NVM peripheral
#[derive(Debug)]
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum PeripheralError {
/// NVM error
Expand All @@ -97,7 +97,7 @@ pub enum PeripheralError {

/// Driver errors
#[non_exhaustive]
#[derive(Debug)]
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum Error {
/// Address range outside of flash
Expand Down

0 comments on commit 063fd8f

Please sign in to comment.