cargo fmt

This commit is contained in:
Yuri Iozzelli 2020-03-01 16:45:00 +01:00
parent 651aba971b
commit 799dc143b8
2 changed files with 112 additions and 110 deletions

View file

@ -1,7 +1,7 @@
use crate::{Error, Interface};
use embedded_hal::blocking::spi;
use embedded_hal::spi::{Mode, Phase, Polarity};
use embedded_hal::digital::v2::OutputPin;
use crate::{Interface, Error};
use embedded_hal::spi::{Mode, Phase, Polarity};
/// SPI mode
pub const MODE: Mode = Mode {
@ -17,21 +17,19 @@ pub struct SpiInterface<SPI, CS, DC> {
}
impl<SPI, CS, DC, SpiE, PinE> SpiInterface<SPI, CS, DC>
where SPI: spi::Transfer<u8, Error = SpiE> + spi::Write<u8, Error = SpiE>,
where
SPI: spi::Transfer<u8, Error = SpiE> + spi::Write<u8, Error = SpiE>,
CS: OutputPin<Error = PinE>,
DC: OutputPin<Error = PinE>,
{
pub fn new(spi: SPI, cs: CS, dc: DC) -> Self {
Self {
spi,
cs,
dc,
}
Self { spi, cs, dc }
}
}
impl<SPI, CS, DC, SpiE, PinE> Interface for SpiInterface<SPI, CS, DC>
where SPI: spi::Transfer<u8, Error = SpiE> + spi::Write<u8, Error = SpiE>,
where
SPI: spi::Transfer<u8, Error = SpiE> + spi::Write<u8, Error = SpiE>,
CS: OutputPin<Error = PinE>,
DC: OutputPin<Error = PinE>,
{
@ -50,7 +48,11 @@ impl<SPI, CS, DC, SpiE, PinE> Interface for SpiInterface<SPI, CS, DC>
Ok(())
}
fn write_iter(&mut self, command: u8, data: impl IntoIterator<Item=u16>) -> Result<(), Self::Error> {
fn write_iter(
&mut self,
command: u8,
data: impl IntoIterator<Item = u16>,
) -> Result<(), Self::Error> {
self.cs.set_low().map_err(Error::OutputPin)?;
self.dc.set_low().map_err(Error::OutputPin)?;