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

Impl more standard traits for error types #691

Merged
merged 2 commits into from
Jun 10, 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
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