Skip to main content

MSS_SPI_transfer_block

Function MSS_SPI_transfer_block 

Source
pub unsafe extern "C" fn MSS_SPI_transfer_block(
    this_spi: *mut mss_spi_instance_t,
    cmd_buffer: *const u8,
    cmd_byte_size: u32,
    rd_buffer: *mut u8,
    rd_byte_size: u32,
)
Expand description

MSS_SPI_transfer_block() is used by an MSS SPI masters to transmit and receive blocks of data organized as a specified number of bytes. It can be used for the following events:

  • Writing a data block to a slave
  • Reading a data block from a slave
  • Sending a command to a slave followed by reading the response to the command in a single SPI transaction

@param this_spi this_spi is a pointer to an mss_spi_instance_t structure that identifies the MSS SPI hardware block to be operated.

@param cmd_buffer cmd_buffer is a pointer to the buffer that contains the data sent by the master from the beginning of the transfer.

@param cmd_byte_size cmd_byte_size specifies the number of bytes in cmd_buffer that is sent. A value of 0 indicates that no data needs to be sent to the slave.

@param rd_buffer rd_buffer is a pointer to the buffer that stores the data received from the slave after sending the command.

@param rd_byte_size rd_byte_size specifies the number of bytes received from the slave and stores in the rd_buffer. A value of 0 indicates that no data is to be read from the slave.

@return This function does not return any value.

@example Polled write transfer example: @code uint8_t master_tx_buffer[MASTER_TX_BUFFER] = {0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A}; MSS_SPI_init(&g_mss_spi0_lo); MSS_SPI_configure_master_mode(&g_mss_spi0_lo, MSS_SPI_SLAVE_0, MSS_SPI_MODE1, 256u, MSS_SPI_BLOCK_TRANSFER_FRAME_SIZE, mss_spi_overflow_handler);

MSS_SPI_set_slave_select(&g_mss_spi0_lo, MSS_SPI_SLAVE_0); MSS_SPI_transfer_block(&g_mss_spi0_lo,master_tx_buffer, sizeof(master_tx_buffer),0,0); MSS_SPI_clear_slave_select(&g_mss_spi0_lo, MSS_SPI_SLAVE_0); @endcode