Skip to content

Commit

Permalink
Only allow HAL to create I2C/SPI config errors
Browse files Browse the repository at this point in the history
  • Loading branch information
AlyoshaVasilieva authored and mciantyre committed Nov 17, 2020
1 parent 0878f7a commit 429b9fa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions imxrt-hal/src/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,15 @@ pub struct I2C<M> {
/// Indicates an error when computing the parameters that control
/// the clock speed.
#[derive(Debug)]
pub struct ClockSpeedError;
pub struct ClockSpeedError(());
/// Indicates an error when computing the parameters that control
/// the pin low timeout
#[derive(Debug)]
pub struct PinLowTimeoutError;
pub struct PinLowTimeoutError(());
/// Indicates an error when computing the parameters that control
/// the bus idle timeout
#[derive(Debug)]
pub struct BusIdleTimeoutError;
pub struct BusIdleTimeoutError(());

const RETRIES: usize = 100_000;

Expand Down Expand Up @@ -314,7 +314,7 @@ where
.into_iter()
.next()
.filter(|ticks| *ticks <= 0x0FFFu16)
.ok_or(PinLowTimeoutError)?;
.ok_or(PinLowTimeoutError(()))?;
log::debug!("PINLOW = 0x{:X}", pin_low_ticks);
self.with_master_disabled(|| {
ral::modify_reg!(
Expand Down Expand Up @@ -344,7 +344,7 @@ where
.into_iter()
.next()
.filter(|ticks| *ticks <= 0xFFFu16)
.ok_or(BusIdleTimeoutError)?;
.ok_or(BusIdleTimeoutError(()))?;
log::debug!("BUSIDLE = 0x{:X}", bus_idle_ticks);
self.with_master_disabled(|| {
ral::modify_reg!(
Expand Down
8 changes: 4 additions & 4 deletions imxrt-hal/src/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,22 +212,22 @@ pub struct SPI<M> {
/// Indicates an error when computing the parameters that control
/// the clock speed.
#[derive(Debug)]
pub struct ClockSpeedError;
pub struct ClockSpeedError(());

/// Indicates an error when computing the parameters that control
/// the mode.
#[derive(Debug)]
pub struct ModeError;
pub struct ModeError(());

/// Indicates an error when computing the parameters that control
/// the pin low timeout
#[derive(Debug)]
pub struct PinLowTimeoutError;
pub struct PinLowTimeoutError(());

/// Indicates an error when computing the parameters that control
/// the bus idle timeout
#[derive(Debug)]
pub struct BusIdleTimeoutError;
pub struct BusIdleTimeoutError(());

const RETRIES: usize = 100_000;

Expand Down

0 comments on commit 429b9fa

Please sign in to comment.