kernel::hil::spi

Trait SpiMasterDevice

Source
pub trait SpiMasterDevice<'a> {
    // Required methods
    fn set_client(&self, client: &'a dyn SpiMasterClient);
    fn configure(
        &self,
        cpol: ClockPolarity,
        cpal: ClockPhase,
        rate: u32,
    ) -> Result<(), ErrorCode>;
    fn read_write_bytes(
        &self,
        write_buffer: SubSliceMut<'static, u8>,
        read_buffer: Option<SubSliceMut<'static, u8>>,
    ) -> Result<(), (ErrorCode, SubSliceMut<'static, u8>, Option<SubSliceMut<'static, u8>>)>;
    fn set_rate(&self, rate: u32) -> Result<(), ErrorCode>;
    fn get_rate(&self) -> u32;
    fn set_polarity(&self, polarity: ClockPolarity) -> Result<(), ErrorCode>;
    fn get_polarity(&self) -> ClockPolarity;
    fn set_phase(&self, phase: ClockPhase) -> Result<(), ErrorCode>;
    fn get_phase(&self) -> ClockPhase;
}
Expand description

A chip-select-specific interface to the SPI Controller hardware, such that a client cannot change the chip select line.

This restricts the SPI peripherals the client can access to a specific peripheral.

Required Methods§

Source

fn set_client(&self, client: &'a dyn SpiMasterClient)

Set the callback for read_write operations.

Source

fn configure( &self, cpol: ClockPolarity, cpal: ClockPhase, rate: u32, ) -> Result<(), ErrorCode>

Configure the bus for this chip select.

Source

fn read_write_bytes( &self, write_buffer: SubSliceMut<'static, u8>, read_buffer: Option<SubSliceMut<'static, u8>>, ) -> Result<(), (ErrorCode, SubSliceMut<'static, u8>, Option<SubSliceMut<'static, u8>>)>

Source

fn set_rate(&self, rate: u32) -> Result<(), ErrorCode>

Source

fn get_rate(&self) -> u32

Return the current chip select’s clock rate.

Source

fn set_polarity(&self, polarity: ClockPolarity) -> Result<(), ErrorCode>

Source

fn get_polarity(&self) -> ClockPolarity

Return the current bus polarity.

Source

fn set_phase(&self, phase: ClockPhase) -> Result<(), ErrorCode>

Source

fn get_phase(&self) -> ClockPhase

Get the current bus phase for the current chip select.

Implementors§