SIM_INTERFACE(serial_peripheral_interface_slave) { void (*spi_request)(conf_object_t *obj, int first, int last, int bits, dbuffer_t *payload); void (*connect_master)(conf_object_t *obj, conf_object_t *master, const char *port, serial_peripheral_interface_flags_t flags); void (*disconnect_master)(conf_object_t *obj, conf_object_t *master); }; #define SERIAL_PERIPHERAL_INTERFACE_SLAVE_INTERFACE \ "serial_peripheral_interface_slave"
The serial_peripheral_interface_slave
interface is
implemented by all SPI slave devices.
The connect_master and disconnect_master
functions are used to select which master device is connected. At
most one master device can be connected to a slave device at once.
The flags parameter to connect_master
should be set according to the documentation of the
serial_peripheral_interface_flags_t
type.
An SPI transfer consists of a number of consecutive calls to the
spi_request function. The parameters
first and last represent the rise and
fall of the Slave Select (SS) pin: first is
true
on the first spi_request call of a
transfer, while last is true
on the
last call of a transfer.
The bits and payload parameters
describe the data sent by the master device. bits
defines the number of bits to send, while payload
defines the data to transfer. The size of the
payload buffer should be ceil(bits / 8)
bytes. The first byte corresponds to the first 8 sent bits, and the
least significant bit in each byte corresponds to the first sent
bit. For example, the 11-bit sequence (first) 11011111101
(last) will be represented as two bytes, 0xfb
followed by
0x5
.
serial_peripheral_interface_master_interface_t
,
serial_peripheral_interface_flags_t