|
void | format (int bits, int mode=0) |
| Configure the data transmission format. More...
|
|
void | frequency (int hz=1000000) |
| Set the SPI bus clock frequency. More...
|
|
virtual int | write (int value) |
| Write to the SPI Slave and return the response. More...
|
|
template<typename WordT > |
std::enable_if< std::is_integral< WordT >::value, int >::type | write (const WordT *tx_buffer, int tx_length, WordT *rx_buffer, int rx_length) |
| Write to the SPI Slave and obtain the response. More...
|
|
virtual void | lock (void) |
| Acquire exclusive access to this SPI bus. More...
|
|
virtual void | unlock (void) |
| Release exclusive access to this SPI bus. More...
|
|
void | select (void) |
| Assert the Slave Select line and acquire exclusive access to this SPI bus. More...
|
|
void | deselect (void) |
| Deassert the Slave Select line, releasing exclusive access to this SPI bus. More...
|
|
void | set_default_write_value (char data) |
| Set default write data. More...
|
|
template<typename WordT > |
std::enable_if< std::is_integral< WordT >::value, int >::type | transfer (const WordT *tx_buffer, int tx_length, CacheAlignedBuffer< WordT > &rx_buffer, int rx_length, const event_callback_t &callback, int event=SPI_EVENT_COMPLETE) |
| Start non-blocking SPI transfer. More...
|
|
template<typename WordT > |
std::enable_if< std::is_integral< WordT >::value, int >::type | transfer_and_wait (const WordT *tx_buffer, int tx_length, CacheAlignedBuffer< WordT > &rx_buffer, int rx_length, rtos::Kernel::Clock::duration_u32 timeout=rtos::Kernel::wait_for_u32_forever) |
| Start SPI transfer and wait until it is complete. More...
|
|
void | abort_transfer () |
| Abort the on-going SPI transfer, if any, and continue with transfers in the queue, if any. More...
|
|
void | clear_transfer_buffer () |
| Clear the queue of transfers. More...
|
|
void | abort_all_transfers () |
| Clear the queue of transfers and abort any on-going transfer. More...
|
|
int | set_dma_usage (DMAUsage usage) |
| Configure DMA usage suggestion for non-blocking transfers. More...
|
|
Definition at line 31 of file EMW3080B_SPI.h.
std::enable_if< std::is_integral< WordT >::value, int >::type write |
( |
const WordT * |
tx_buffer, |
|
|
int |
tx_length, |
|
|
WordT * |
rx_buffer, |
|
|
int |
rx_length |
|
) |
| |
|
inherited |
Write to the SPI Slave and obtain the response.
The total number of bytes sent and received will be the maximum of tx_length and rx_length. The bytes written will be padded with the value 0xff.
Note: Even if the word size / bits per frame is not 8, rx_length
and tx_length
still count bytes of input data, not numbers of words.
- Parameters
-
tx_buffer | Pointer to the byte-array of data to write to the device. |
tx_length | Number of bytes to write, may be zero. |
rx_buffer | Pointer to the byte-array of data to read from the device. |
rx_length | Number of bytes to read, may be zero. |
- Returns
- The number of bytes written and read from the device (as an int). This is maximum of tx_length and rx_length.
Definition at line 385 of file SPI.h.
Assert the Slave Select line and acquire exclusive access to this SPI bus.
The slave select line will remain selected (low) for all following operations until you call deselect() on this instance. This allows you to string together multiple SPI transactions as if they were a single operation (from the perspective of peripheral chips).
If use_gpio_ssel was not passed to the constructor, manual control of the SSEL line is not possible, and this function behaves identically to lock().
Like lock(), this function will block until exclusive access can be acquired.
- Warning
- Do not call this function while an asynchronous transfer is in progress, as undefined behavior can occur.
Start SPI transfer and wait until it is complete.
Like the transactional API this blocks the current thread, however all work is done in the background and other threads may execute.
As long as there is space, this function will enqueue the transfer request onto the peripheral, and block until it is done.
Internally, the chip vendor may implement this function using either DMA or interrupts.
- Parameters
-
tx_buffer | The TX buffer with data to be transferred. May be nullptr if tx_length is 0. |
tx_length | The length of TX buffer in bytes. If 0, the default SPI data value is sent when receiving data. |
rx_buffer | The RX buffer which is used for received data. Rather than a C array, a CacheAlignedBuffer structure must be passed so that cache alignment can be handled for data received from DMA. May be nullptr if rx_length is 0. |
rx_length | The length of RX buffer in bytes If 0, no reception is done. |
timeout | timeout value. Use rtos::Kernel::wait_for_u32_forever to wait forever (the default). |
- Returns
- Operation result (integer)
- Return values
-
-1 | if the transfer could not be enqueued (increase drivers.spi_transaction_queue_len option) |
1 | on timeout |
2 | on other error |
0 | on success |
Definition at line 529 of file SPI.h.