mirror of
https://github.com/yuri91/ili9341-rs.git
synced 2025-02-16 13:05:14 +00:00
cargo fmt
This commit is contained in:
parent
651aba971b
commit
799dc143b8
2 changed files with 112 additions and 110 deletions
22
src/spi.rs
22
src/spi.rs
|
@ -1,7 +1,7 @@
|
||||||
|
use crate::{Error, Interface};
|
||||||
use embedded_hal::blocking::spi;
|
use embedded_hal::blocking::spi;
|
||||||
use embedded_hal::spi::{Mode, Phase, Polarity};
|
|
||||||
use embedded_hal::digital::v2::OutputPin;
|
use embedded_hal::digital::v2::OutputPin;
|
||||||
use crate::{Interface, Error};
|
use embedded_hal::spi::{Mode, Phase, Polarity};
|
||||||
|
|
||||||
/// SPI mode
|
/// SPI mode
|
||||||
pub const MODE: Mode = 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>
|
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>,
|
CS: OutputPin<Error = PinE>,
|
||||||
DC: OutputPin<Error = PinE>,
|
DC: OutputPin<Error = PinE>,
|
||||||
{
|
{
|
||||||
pub fn new(spi: SPI, cs: CS, dc: DC) -> Self {
|
pub fn new(spi: SPI, cs: CS, dc: DC) -> Self {
|
||||||
Self {
|
Self { spi, cs, dc }
|
||||||
spi,
|
|
||||||
cs,
|
|
||||||
dc,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<SPI, CS, DC, SpiE, PinE> Interface for SpiInterface<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>,
|
CS: OutputPin<Error = PinE>,
|
||||||
DC: OutputPin<Error = PinE>,
|
DC: OutputPin<Error = PinE>,
|
||||||
{
|
{
|
||||||
|
@ -50,7 +48,11 @@ impl<SPI, CS, DC, SpiE, PinE> Interface for SpiInterface<SPI, CS, DC>
|
||||||
Ok(())
|
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.cs.set_low().map_err(Error::OutputPin)?;
|
||||||
|
|
||||||
self.dc.set_low().map_err(Error::OutputPin)?;
|
self.dc.set_low().map_err(Error::OutputPin)?;
|
||||||
|
|
Loading…
Reference in a new issue