|Top Previous Next|
|Got to SUB-20 page|
int sub_spi_transfer_ess( sub_handle hndl, char* out_buf, char* in_buf,
int sz, char* ess_str )
Perform SPI master transaction with Extended Slave Select control (ESS). Depending on out_buf and in_buf parameters transaction can be either read (out_buf==0), write (in_buf==0) or read-write ( both in_buf and out_buf are non zero).
•out_buf - Output data buffer or NULL. If NULL there will be no write transaction and MOSI pin will stay unchanged.
•in_buf - Input buffer to store read data or NULL. If NULL there will be no read transaction and data on MISO pin will be ignored.
•sz - Transaction size
•ess_str - string defining SS selection and activity during SPI transfer. Characters of the ess_str have following meaning
On success function returns 0. Otherwise error code.
/* Write 5 bytes with SS0 Low. Make SS0 High to Low pulse after each byte */
rc = sub_spi_transfer( hndl, out, 0, 5, "0L^-vL^-vL^-vL^-vL^-v" );
/* Transfer 10 bytes with SS High. Use SS1 for first 5 bytes and SS2 for last */
rc = sub_spi_transfer( hndl, out, in, 10, "1HHHHHv-2HHHHHv" );
/* Read 10 bytes. SS0 High for first 2 bytes and low after that */
rc = sub_spi_transfer( hndl, 0, in, 10, "0HHv" );