Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
9names committed Aug 6, 2023
1 parent fb546d9 commit 360c060
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/delay.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Delays

use embedded_hal_zero::blocking::delay::{DelayMs as DelayMsZero, DelayUs as DelayUsZero};
use embedded_hal::delay::DelayUs;
use embedded_hal_zero::blocking::delay::{DelayMs as DelayMsZero, DelayUs as DelayUsZero};

/// Use RISCV machine-mode cycle counter (`mcycle`) as a delay provider.
///
Expand Down
24 changes: 11 additions & 13 deletions src/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ impl embedded_hal::i2c::Error for Error {
Self::TxOverflow => embedded_hal::i2c::ErrorKind::Overrun,
Self::RxUnderflow => embedded_hal::i2c::ErrorKind::Overrun,
Self::TxUnderflow => embedded_hal::i2c::ErrorKind::Overrun,
Self::Timeout => embedded_hal::i2c::ErrorKind::NoAcknowledge(embedded_hal::i2c::NoAcknowledgeSource::Address),
Self::Timeout => embedded_hal::i2c::ErrorKind::NoAcknowledge(
embedded_hal::i2c::NoAcknowledgeSource::Address,
),
}
}
}
Expand Down Expand Up @@ -185,7 +187,7 @@ where
}
}

impl<PINS> i2cAlpha::ErrorType for I2c<pac::I2C, PINS> {
impl<PINS> i2cAlpha::ErrorType for I2c<pac::I2C, PINS> {
type Error = Error;
}

Expand Down Expand Up @@ -326,20 +328,16 @@ where

// untested!
fn transaction(
&mut self,
address: i2cAlpha::SevenBitAddress,
operations: &mut [i2cAlpha::Operation<'_>],
) -> Result<(), Self::Error> {
&mut self,
address: i2cAlpha::SevenBitAddress,
operations: &mut [i2cAlpha::Operation<'_>],
) -> Result<(), Self::Error> {
for op in operations {
let result = match op {
i2cAlpha::Operation::Read(buf) => {
i2cAlpha::I2c::read(self, address, buf)
},
i2cAlpha::Operation::Write(buf) => {
i2cAlpha::I2c::write(self, address, buf)
},
i2cAlpha::Operation::Read(buf) => i2cAlpha::I2c::read(self, address, buf),
i2cAlpha::Operation::Write(buf) => i2cAlpha::I2c::write(self, address, buf),
};
if result.is_err(){
if result.is_err() {
return result;
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ where
}
}

impl<UART, PINS> embedded_hal_nb::serial::ErrorType for Serial<UART, PINS>{
impl<UART, PINS> embedded_hal_nb::serial::ErrorType for Serial<UART, PINS> {
type Error = Error;
}

Expand Down Expand Up @@ -303,8 +303,7 @@ where
fn read(&mut self) -> nb::Result<u8, Self::Error> {
if self.uart.uart_fifo_config_1.read().rx_fifo_cnt().bits() == 0 {
Err(nb::Error::WouldBlock)
}
else {
} else {
let ans = self.uart.uart_fifo_rdata.read().bits();
Ok((ans & 0xff) as u8)
}
Expand Down
7 changes: 2 additions & 5 deletions src/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
*/

use bl602_pac::SPI;
use embedded_hal_nb;
pub use embedded_hal::spi::Mode;
use embedded_hal_nb;
use embedded_hal_zero::spi::FullDuplex as FullDuplexZero;
use embedded_time::rate::Hertz;

Expand Down Expand Up @@ -223,12 +223,10 @@ where
}
}


impl<PINS> embedded_hal_nb::spi::ErrorType for Spi<pac::SPI, PINS>{
impl<PINS> embedded_hal_nb::spi::ErrorType for Spi<pac::SPI, PINS> {
type Error = Error;
}


impl<PINS> embedded_hal_nb::spi::FullDuplex<u8> for Spi<pac::SPI, PINS>
where
PINS: Pins<pac::SPI>,
Expand Down Expand Up @@ -293,7 +291,6 @@ impl<PINS> embedded_hal_zero::blocking::spi::write::Default<u8> for Spi<pac::SPI
{
}


impl<PINS> embedded_hal_zero::blocking::spi::write_iter::Default<u8> for Spi<pac::SPI, PINS> where
PINS: Pins<pac::SPI>
{
Expand Down

0 comments on commit 360c060

Please sign in to comment.