sub_spi_transfer_ess

Top  Previous  Next
Got to SUB-20 page

Synopsis

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).

Parameters

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

 

0

Select SS0


1

Select SS1


2

Select SS2


3

Select SS3


4

Select SS4


H

SS High

Byte Transfer

L

SS Low

Byte Transfer

^

SS High

No Byte Transfer

v

SS Low

No Byte Transfer

-

Small delay without SS changes

No Byte Transfer

 

 

Return value

On success function returns 0. Otherwise error code.

Example

/* 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" );

Compatibility

FW version

0.2.9 or grater

Library version

0.1.12.19 or grater