Trait opentitanlib::io::spi::Target
source · pub trait Target {
Show 17 methods
// Required methods
fn get_transfer_mode(&self) -> Result<TransferMode>;
fn set_transfer_mode(&self, mode: TransferMode) -> Result<()>;
fn get_bits_per_word(&self) -> Result<u32>;
fn set_bits_per_word(&self, bits_per_word: u32) -> Result<()>;
fn get_max_speed(&self) -> Result<u32>;
fn set_max_speed(&self, max_speed: u32) -> Result<()>;
fn supports_bidirectional_transfer(&self) -> Result<bool>;
fn supports_tpm_poll(&self) -> Result<bool>;
fn get_max_transfer_count(&self) -> Result<usize>;
fn get_max_transfer_sizes(&self) -> Result<MaxSizes>;
fn run_transaction(
&self,
transaction: &mut [Transfer<'_, '_>]
) -> Result<()>;
fn assert_cs(self: Rc<Self>) -> Result<AssertChipSelect>;
// Provided methods
fn set_pins(
&self,
_serial_clock: Option<&Rc<dyn GpioPin>>,
_host_out_device_in: Option<&Rc<dyn GpioPin>>,
_host_in_device_out: Option<&Rc<dyn GpioPin>>,
_chip_select: Option<&Rc<dyn GpioPin>>,
_gsc_ready: Option<&Rc<dyn GpioPin>>
) -> Result<()> { ... }
fn set_voltage(&self, _voltage: Voltage) -> Result<()> { ... }
fn get_flashrom_programmer(&self) -> Result<String> { ... }
fn get_eeprom_max_transfer_sizes(&self) -> Result<MaxSizes> { ... }
fn run_eeprom_transactions(
&self,
transactions: &mut [Transaction<'_, '_>]
) -> Result<()> { ... }
}
Expand description
A trait which represents a SPI Target.
Required Methods§
sourcefn get_transfer_mode(&self) -> Result<TransferMode>
fn get_transfer_mode(&self) -> Result<TransferMode>
Gets the current SPI transfer mode.
sourcefn set_transfer_mode(&self, mode: TransferMode) -> Result<()>
fn set_transfer_mode(&self, mode: TransferMode) -> Result<()>
Sets the current SPI transfer mode.
sourcefn get_bits_per_word(&self) -> Result<u32>
fn get_bits_per_word(&self) -> Result<u32>
Gets the current number of bits per word.
sourcefn set_bits_per_word(&self, bits_per_word: u32) -> Result<()>
fn set_bits_per_word(&self, bits_per_word: u32) -> Result<()>
Sets the current number of bits per word.
sourcefn get_max_speed(&self) -> Result<u32>
fn get_max_speed(&self) -> Result<u32>
Gets the maximum allowed speed of the SPI bus.
sourcefn set_max_speed(&self, max_speed: u32) -> Result<()>
fn set_max_speed(&self, max_speed: u32) -> Result<()>
Sets the maximum allowed speed of the SPI bus.
sourcefn supports_bidirectional_transfer(&self) -> Result<bool>
fn supports_bidirectional_transfer(&self) -> Result<bool>
Indicates whether Transfer::Both()
is supported.
sourcefn supports_tpm_poll(&self) -> Result<bool>
fn supports_tpm_poll(&self) -> Result<bool>
Indicates whether Transfer::TpmPoll
is supported.
sourcefn get_max_transfer_count(&self) -> Result<usize>
fn get_max_transfer_count(&self) -> Result<usize>
Returns the maximum number of transfers allowed in a single transaction.
sourcefn get_max_transfer_sizes(&self) -> Result<MaxSizes>
fn get_max_transfer_sizes(&self) -> Result<MaxSizes>
Maximum Read
and Write
data size for run_transaction()
.
sourcefn run_transaction(&self, transaction: &mut [Transfer<'_, '_>]) -> Result<()>
fn run_transaction(&self, transaction: &mut [Transfer<'_, '_>]) -> Result<()>
Runs a SPI transaction composed from the slice of Transfer
objects. Will assert the
CS for the duration of the entire transactions.
sourcefn assert_cs(self: Rc<Self>) -> Result<AssertChipSelect>
fn assert_cs(self: Rc<Self>) -> Result<AssertChipSelect>
Assert the CS signal. Uses reference counting, will be deasserted when each and every
returned AssertChipSelect
object have gone out of scope.
Provided Methods§
sourcefn set_pins(
&self,
_serial_clock: Option<&Rc<dyn GpioPin>>,
_host_out_device_in: Option<&Rc<dyn GpioPin>>,
_host_in_device_out: Option<&Rc<dyn GpioPin>>,
_chip_select: Option<&Rc<dyn GpioPin>>,
_gsc_ready: Option<&Rc<dyn GpioPin>>
) -> Result<()>
fn set_pins( &self, _serial_clock: Option<&Rc<dyn GpioPin>>, _host_out_device_in: Option<&Rc<dyn GpioPin>>, _host_in_device_out: Option<&Rc<dyn GpioPin>>, _chip_select: Option<&Rc<dyn GpioPin>>, _gsc_ready: Option<&Rc<dyn GpioPin>> ) -> Result<()>
Sets which pins should be used for SPI communication. None
value means use the same pin
as previously, or the implementation default if never before specified. This call is not
supported by most backend transports, and ones that do support it may still have
restrictions on which set of pins can be used in which roles.
fn set_voltage(&self, _voltage: Voltage) -> Result<()>
sourcefn get_flashrom_programmer(&self) -> Result<String>
fn get_flashrom_programmer(&self) -> Result<String>
Returns "raiden_debug_spi:serial=XXX"
or similar string usable for passing via -p
argument to flashrom
, in order for it to connect to this SPI port instance.
sourcefn get_eeprom_max_transfer_sizes(&self) -> Result<MaxSizes>
fn get_eeprom_max_transfer_sizes(&self) -> Result<MaxSizes>
Maximum payload size of Read
and Write
elements for run_eeprom_transactions()
.
sourcefn run_eeprom_transactions(
&self,
transactions: &mut [Transaction<'_, '_>]
) -> Result<()>
fn run_eeprom_transactions( &self, transactions: &mut [Transaction<'_, '_>] ) -> Result<()>
Runs a number of EEPROM/FLASH protocol SPI transactions. Will assert and deassert CS for each transaction.