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

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

Non-blocking interface to send a buffer and store received values. Can be used for both master and slave SPI types. The user must configure the callback (using hal_spi_set_txrx_cb); the txrx callback is executed at interrupt context when the buffer is sent.

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: Slave "preloads" the data to be sent to the master (values
       stored in txbuf) and places received data from master in rxbuf
       (if not NULL). The txrx callback occurs when len values are
       transferred or master de-asserts chip select. If txbuf is NULL,
       the slave transfers its default byte. Both rxbuf and txbuf cannot
       be NULL.
  • 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.