Trait pn532::Interface

source ·
pub trait Interface {
    type Error: Debug;

    // Required methods
    fn write(&mut self, frame: &[u8]) -> Result<(), Self::Error>;
    fn wait_ready(&mut self) -> Poll<Result<(), Self::Error>>;
    fn read(&mut self, buf: &mut [u8]) -> Result<(), Self::Error>;
}
Expand description

Abstraction over the different serial links. Either SPI, I2C or HSU (High Speed UART).

Required Associated Types§

source

type Error: Debug

Error specific to the serial link.

Required Methods§

source

fn write(&mut self, frame: &[u8]) -> Result<(), Self::Error>

Writes a frame to the Pn532

source

fn wait_ready(&mut self) -> Poll<Result<(), Self::Error>>

Checks if the Pn532 has data to be read. Uses either the serial link or the IRQ pin.

source

fn read(&mut self, buf: &mut [u8]) -> Result<(), Self::Error>

Reads data from the Pn532 into buf. This method will only be called if wait_ready returned Poll::Ready(Ok(())) before.

Implementations on Foreign Types§

source§

impl<I: Interface> Interface for &mut I

§

type Error = <I as Interface>::Error

source§

fn write(&mut self, frame: &[u8]) -> Result<(), Self::Error>

source§

fn wait_ready(&mut self) -> Poll<Result<(), Self::Error>>

source§

fn read(&mut self, buf: &mut [u8]) -> Result<(), Self::Error>

Implementors§

source§

impl Interface for SerialPortInterface

Available on crate feature std only.
§

type Error = Error

source§

impl<I2C> Interface for I2CInterface<I2C>
where I2C: Transactional + Write<Error = <I2C as Transactional>::Error> + Read<Error = <I2C as Transactional>::Error>, <I2C as Transactional>::Error: Debug,

§

type Error = <I2C as Transactional>::Error

source§

impl<I2C, IRQ> Interface for I2CInterfaceWithIrq<I2C, IRQ>
where I2C: Transactional + Write<Error = <I2C as Transactional>::Error> + Read<Error = <I2C as Transactional>::Error>, <I2C as Transactional>::Error: Debug, IRQ: InputPin<Error = Infallible>,

§

type Error = <I2C as Transactional>::Error

source§

impl<SPI, CS> Interface for SPIInterface<SPI, CS>
where SPI: Transfer<u8> + Write<u8, Error = <SPI as Transfer<u8>>::Error>, <SPI as Transfer<u8>>::Error: Debug, CS: OutputPin<Error = Infallible>,

§

type Error = <SPI as Transfer<u8>>::Error

source§

impl<SPI, CS, IRQ> Interface for SPIInterfaceWithIrq<SPI, CS, IRQ>
where SPI: Transfer<u8> + Write<u8, Error = <SPI as Transfer<u8>>::Error>, <SPI as Transfer<u8>>::Error: Debug, CS: OutputPin<Error = Infallible>, IRQ: InputPin<Error = Infallible>,

§

type Error = <SPI as Transfer<u8>>::Error