[][src]Function mynewt::hw::hal::hal_spi_txrx

pub unsafe extern "C" fn hal_spi_txrx(
    spi_num: c_int,
    txbuf: *mut c_void,
    rxbuf: *mut c_void,
    cnt: c_int
) -> c_int

Blocking interface to send a buffer and store the received values from the slave. The transmit and receive buffers are either arrays of 8-bit (uint8_t) values or 16-bit values depending on whether the spi is configured for 8 bit data or more than 8 bits per value. The 'cnt' parameter is the number of 8-bit or 16-bit values. Thus, if 'cnt' is 10, txbuf/rxbuf would point to an array of size 10 (in bytes) if the SPI is using 8-bit data; otherwise txbuf/rxbuf would point to an array of size 20 bytes (ten, uint16_t values).

NOTE: these buffers are in the native endian-ness of the platform.

MASTER: master sends all the values in the buffer and stores the
        stores the values in the receive buffer if rxbuf is not NULL.
        The txbuf parameter cannot be NULL.
SLAVE: cannot be called for a slave; returns -1
  • spi_num: SPI interface to use
  • txbuf: Pointer to buffer where values to transmit are stored.
  • rxbuf: Pointer to buffer to store values received from peer.
  • cnt: Number of 8-bit or 16-bit values to be transferred.

Return: int 0 on success, non-zero error code on failure.