Struct rppal::spi::Segment[][src]

#[repr(C)]
pub struct Segment<'a, 'b> { /* fields omitted */ }
Expand description

Part of a multi-segment transfer.

Segments are transferred using the Spi::transfer_segments method.

Construct a new Segment for a simultaneous (full-duplex) read/write transfer using new. For read operations without any outgoing data, use with_read. For write operations where any incoming data should be discarded, use with_write.

Implementations

Constructs a new Segment with the default settings, and configures it for a simultaneous (full-duplex) read/write transfer.

For Segments that only require either a read or write operation, call with_read or with_write instead of new.

Spi::transfer_segments will only transfer as many bytes as the shortest of the two buffers contains.

By default, all customizable settings are set to 0, which means it uses the same values as set for Spi.

Constructs a new Segment with the default settings, and configures it for a read operation.

Incoming data from the slave device is written to buffer. The total number of bytes read depends on the length of buffer. A zero-value byte is sent for every byte read.

By default, all customizable settings are set to 0, which means it uses the same values as set for Spi.

Constructs a new Segment with the default settings, and configures it for a write operation.

Outgoing data from buffer is sent to the slave device. Any incoming data is discarded.

By default, all customizable settings are set to 0, which means it uses the same values as set for Spi.

Constructs a new Segment with the specified settings.

These settings override the values set for Spi, and are only used for this specific segment.

If read_buffer is set to None, any incoming data is discarded.

If write_buffer is set to None, a zero-value byte is sent for every byte read.

If both read_buffer and write_buffer are specified, Spi::transfer_segments will only transfer as many bytes as the shortest of the two buffers contains.

clock_speed sets a custom clock speed in hertz (Hz).

delay sets a delay in microseconds (µs).

bits_per_word sets the number of bits per word. The Raspberry Pi currently only supports 8 bits per word.

ss_change changes how Slave Select behaves in between two segments (toggle SS), or after the final segment (keep SS active).

Returns the number of bytes that will be transferred.

If both a read buffer and write buffer are supplied, Spi::transfer_segments only transfers as many bytes as the shortest of the two buffers contains.

Returns true if this segment won’t transfer any bytes.

Gets the custom clock speed in hertz (Hz) for this segment.

Sets a custom clock speed in hertz (Hz) for this segment.

The SPI driver will automatically select the closest valid frequency.

By default, clock_speed is set to 0, which means it will use the same value as configured for Spi.

Gets the delay in microseconds (µs) for this segment.

Sets a delay in microseconds (µs) for this segment.

set_delay adds a delay at the end of this segment, before the (optional) Slave Select change.

By default, delay is set to 0.

Gets the number of bits per word for this segment.

Sets the number of bits per word for this segment.

The Raspberry Pi currently only supports 8 bit words.

By default, bits_per_word is set to 0, which means it will use the same value as configured for Spi.

Gets the state of Slave Select change for this segment.

Changes Slave Select’s behavior for this segment.

If ss_change is set to true, and this is not the last segment of the transfer, the Slave Select line will briefly change to inactive between this segment and the next. If this is the last segment, setting ss_change to true will keep Slave Select active after the transfer ends.

By default, ss_change is set to false.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.