#![cfg_attr(not(feature = "utils"), no_std)]
#[macro_use]
extern crate log;
extern crate embedded_hal;
pub mod wrapper;
#[cfg(feature = "mock")]
extern crate std;
#[cfg(feature = "mock")]
pub mod mock;
#[cfg(feature = "ffi")]
extern crate libc;
#[cfg(feature = "ffi")]
pub mod ffi;
#[cfg(feature = "utils")]
extern crate serde;
#[cfg(feature = "utils")]
extern crate toml;
#[cfg(feature = "utils")]
extern crate simplelog;
#[cfg(feature = "utils")]
extern crate linux_embedded_hal;
#[cfg(feature = "utils")]
pub mod utils;
pub trait Transactional {
type Error;
fn spi_read(&mut self, prefix: &[u8], data: &mut [u8]) -> Result<(), Self::Error>;
fn spi_write(&mut self, prefix: &[u8], data: &[u8]) -> Result<(), Self::Error>;
fn spi_exec(&mut self, transactions: &mut [Transaction]) -> Result<(), Self::Error>;
}
#[derive(Debug, PartialEq)]
pub enum Transaction<'a> {
Write(&'a [u8]),
Read(&'a mut [u8]),
}
pub trait Busy {
type Error;
fn get_busy(&mut self) -> Result<PinState, Self::Error>;
}
pub trait Reset {
type Error;
fn set_reset(&mut self, state: PinState) -> Result<(), Self::Error>;
}
pub trait Ready {
type Error;
fn get_ready(&mut self) -> Result<PinState, Self::Error>;
}
#[derive(Debug, Clone, PartialEq)]
pub enum Error<SpiError, PinError> {
Spi(SpiError),
Pin(PinError),
Aborted,
}
#[derive(Debug, Clone, PartialEq)]
pub enum PinState {
Low,
High,
}