Struct sam4l::spi::Spi
[−]
[src]
pub struct Spi { registers: *mut Registers, client: Cell<Option<&'static SpiMasterClient>>, dma_read: Cell<Option<&'static DMAChannel>>, dma_write: Cell<Option<&'static DMAChannel>>, transfers_in_progress: Cell<u8>, dma_length: Cell<usize>, slave_client: Cell<Option<&'static SpiSlaveClient>>, role: Cell<SpiRole>, }
The SAM4L supports four peripherals.
Fields
registers: *mut Registers
client: Cell<Option<&'static SpiMasterClient>>
dma_read: Cell<Option<&'static DMAChannel>>
dma_write: Cell<Option<&'static DMAChannel>>
transfers_in_progress: Cell<u8>
dma_length: Cell<usize>
slave_client: Cell<Option<&'static SpiSlaveClient>>
role: Cell<SpiRole>
Methods
impl Spi
[src]
pub const fn new() -> Spi
[src]
Creates a new SPI object, with peripheral 0 selected
fn init_as_role(&self, role: SpiRole)
[src]
pub fn enable(&self)
[src]
pub fn disable(&self)
[src]
pub fn set_baud_rate(&self, rate: u32) -> u32
[src]
Sets the approximate baud rate for the active peripheral, and return the actual baud rate set.
Since the only supported baud rates are (system clock / n) where n is an integer from 1 to 255, the exact baud rate may not be available. In that case, the next lower baud rate will be selected.
The lowest available baud rate is 188235 baud. If the requested rate is lower, 188235 baud will be selected.
pub fn get_baud_rate(&self) -> u32
[src]
fn set_clock(&self, polarity: ClockPolarity)
[src]
fn get_clock(&self) -> ClockPolarity
[src]
fn set_phase(&self, phase: ClockPhase)
[src]
fn get_phase(&self) -> ClockPhase
[src]
pub fn set_active_peripheral(&self, peripheral: Peripheral)
[src]
pub fn get_active_peripheral(&self) -> Peripheral
[src]
Returns the currently active peripheral
fn get_active_csr(&self) -> &ReadWrite<u32, Register>
[src]
Returns the value of CSR0, CSR1, CSR2, or CSR3, whichever corresponds to the active peripheral
pub fn set_dma(&mut self, read: &'static DMAChannel, write: &'static DMAChannel)
[src]
Set the DMA channels used for reading and writing.
fn enable_clock(&self)
[src]
pub fn handle_interrupt(&self)
[src]
fn read_write_bytes(
&self,
write_buffer: Option<&'static mut [u8]>,
read_buffer: Option<&'static mut [u8]>,
len: usize
) -> ReturnCode
[src]
&self,
write_buffer: Option<&'static mut [u8]>,
read_buffer: Option<&'static mut [u8]>,
len: usize
) -> ReturnCode
Asynchronous buffer read/write of SPI.
returns SUCCESS
if operation starts (will receive callback through SpiMasterClient),
returns EBUSY
if the operation does not start.
Trait Implementations
impl SpiMaster for Spi
[src]
type ChipSelect = u8
fn set_client(&self, client: &'static SpiMasterClient)
[src]
fn init(&self)
[src]
By default, initialize SPI to operate at 40KHz, clock is idle on low, and sample on the leading edge.
fn is_busy(&self) -> bool
[src]
fn write_byte(&self, out_byte: u8)
[src]
Write a byte to the SPI and discard the read; if an asynchronous operation is outstanding, do nothing.
fn read_byte(&self) -> u8
[src]
Write 0 to the SPI and return the read; if an asynchronous operation is outstanding, do nothing.
fn read_write_byte(&self, val: u8) -> u8
[src]
Write a byte to the SPI and return the read; if an asynchronous operation is outstanding, do nothing.
fn read_write_bytes(
&self,
write_buffer: &'static mut [u8],
read_buffer: Option<&'static mut [u8]>,
len: usize
) -> ReturnCode
[src]
&self,
write_buffer: &'static mut [u8],
read_buffer: Option<&'static mut [u8]>,
len: usize
) -> ReturnCode
Asynchronous buffer read/write of SPI.
write_buffer must be Some; read_buffer may be None;
if read_buffer is Some, then length of read/write is the
minimum of two buffer lengths; returns SUCCESS
if operation
starts (will receive callback through SpiMasterClient), returns
EBUSY
if the operation does not start.
fn set_rate(&self, rate: u32) -> u32
[src]
Returns the actual rate set
fn get_rate(&self) -> u32
[src]
fn set_clock(&self, polarity: ClockPolarity)
[src]
fn get_clock(&self) -> ClockPolarity
[src]
fn set_phase(&self, phase: ClockPhase)
[src]
fn get_phase(&self) -> ClockPhase
[src]
fn hold_low(&self)
[src]
fn release_low(&self)
[src]
fn specify_chip_select(&self, cs: Self::ChipSelect)
[src]
Tell the SPI peripheral what to use as a chip select pin. The type of the argument is based on what makes sense for the peripheral when this trait is implemented. Read more
impl SpiSlave for Spi
[src]
fn set_client(&self, client: Option<&'static SpiSlaveClient>)
[src]
fn has_client(&self) -> bool
[src]
Returns true if there is a client.
fn init(&self)
[src]
fn set_write_byte(&self, write_byte: u8)
[src]
This sets the value in the TDR register, to be sent as soon as the chip select pin is low.
fn read_write_bytes(
&self,
write_buffer: Option<&'static mut [u8]>,
read_buffer: Option<&'static mut [u8]>,
len: usize
) -> ReturnCode
[src]
&self,
write_buffer: Option<&'static mut [u8]>,
read_buffer: Option<&'static mut [u8]>,
len: usize
) -> ReturnCode