Struct capsules::spi::SpiSlave
[−]
[src]
pub struct SpiSlave<'a, S: SpiSlaveDevice + 'a> { spi_slave: &'a S, busy: Cell<bool>, app: MapCell<SlaveApp>, kernel_read: TakeCell<'static, [u8]>, kernel_write: TakeCell<'static, [u8]>, kernel_len: Cell<usize>, }
Fields
spi_slave: &'a S
busy: Cell<bool>
app: MapCell<SlaveApp>
kernel_read: TakeCell<'static, [u8]>
kernel_write: TakeCell<'static, [u8]>
kernel_len: Cell<usize>
Methods
impl<'a, S: SpiSlaveDevice> SpiSlave<'a, S>
[src]
pub fn new(spi_slave: &'a S) -> SpiSlave<'a, S>
[src]
pub fn config_buffers(
&mut self,
read: &'static mut [u8],
write: &'static mut [u8]
)
[src]
&mut self,
read: &'static mut [u8],
write: &'static mut [u8]
)
fn do_next_read_write(&self, app: &mut SlaveApp)
[src]
Trait Implementations
impl<'a, S: SpiSlaveDevice> Driver for SpiSlave<'a, S>
[src]
fn allow(
&self,
_appid: AppId,
allow_num: usize,
slice: AppSlice<Shared, u8>
) -> ReturnCode
[src]
&self,
_appid: AppId,
allow_num: usize,
slice: AppSlice<Shared, u8>
) -> ReturnCode
Provide read/write buffers to SpiSlave
allow_num 0: Provides an app_read buffer to receive transfers into.
allow_num 1: Provides an app_write buffer to send transfers from.
fn subscribe(&self, subscribe_num: usize, callback: Callback) -> ReturnCode
[src]
Setup callbacks for SpiSlave
subscribe_num 0: Sets up a callback for when read_write completes. This is called after completing a transfer/reception with the Spi master. Note that this occurs after the pending DMA transfer initiated by read_write_bytes completes.
subscribe_num 1: Sets up a callback for when the chip select line is driven low, meaning that the slave was selected by the Spi master. This occurs immediately before a data transfer.
fn command(&self, cmd_num: usize, arg1: usize, _: usize, _: AppId) -> ReturnCode
[src]
- 0: check if present
- 1: read/write buffers
- read and write buffers optional
- fails if arg1 (bytes to write) > write_buffer.len()
- 2: get chip select
- returns current selected peripheral
- in slave mode, always returns 0
- 3: set clock phase on current peripheral
- 0 is sample leading
- non-zero is sample trailing
- 4: get clock phase on current peripheral
- 0 is sample leading
- non-zero is sample trailing
- 5: set clock polarity on current peripheral
- 0 is idle low
- non-zero is idle high
- 6: get clock polarity on current peripheral
- 0 is idle low
- non-zero is idle high
- x: lock spi
- if you perform an operation without the lock, it implicitly acquires the lock before the operation and releases it after
- while an app holds the lock no other app can issue operations on SPI (they are buffered)
- not implemented or currently supported
- x+1: unlock spi
- does nothing if lock not held
- not implemented or currently supported
impl<'a, S: SpiSlaveDevice> SpiSlaveClient for SpiSlave<'a, S>
[src]
fn read_write_done(
&self,
writebuf: Option<&'static mut [u8]>,
readbuf: Option<&'static mut [u8]>,
length: usize
)
[src]
&self,
writebuf: Option<&'static mut [u8]>,
readbuf: Option<&'static mut [u8]>,
length: usize
)
This is called as a DMA interrupt when a transfer has completed
fn chip_selected(&self)
[src]
This is called whenever the slave is selected by the master