Interface: tos.interfaces.SpiPacket

interface SpiPacket

SPI Packet/buffer interface for sending data over an SPI bus. This interface provides a split-phase send command which can be used for sending, receiving or both. It is a "send" command because reading from the SPI requires writing bytes. The send call allows NULL parameters for receive or send only operations. This interface is for buffer based transfers where the microcontroller is the master (clocking) device. Often, an SPI bus must first be acquired using a Resource interface before sending commands with SPIPacket. In the case of multiple devices attached to a single SPI bus, chip select pins are often also used.

Author:
Philip Levis
Jonathan Hui
Joe Polastre Revision: $Revision: 1.4 $

Commands
command error_t send(uint8_t *txBuf, uint8_t *rxBuf, uint16_t len) Send a message over the SPI bus.

Events
event void sendDone(uint8_t *txBuf, uint8_t *rxBuf, uint16_t len, error_t error) Notification that the send command has completed.

Commands - Details

send

command error_t send(uint8_t *txBuf, uint8_t *rxBuf, uint16_t len)

Send a message over the SPI bus.

Parameters:
txBuf - A pointer to the buffer to send over the bus. If this parameter is NULL, then the SPI will send zeroes.
rxBuf - A pointer to the buffer where received data should be stored. If this parameter is NULL, then the SPI will discard incoming bytes.
len - Length of the message. Note that non-NULL rxBuf and txBuf parameters must be AT LEAST as large as len, or the SPI will overflow a buffer.
Returns:
SUCCESS if the request was accepted for transfer

Events - Details

sendDone

event void sendDone(uint8_t *txBuf, uint8_t *rxBuf, uint16_t len, error_t error)

Notification that the send command has completed.

Parameters:
txBuf - The buffer used for transmission
rxBuf - The buffer used for reception
len - The request length of the transfer, but not necessarily the number of bytes that were actually transferred
error - SUCCESS if the operation completed successfully, FAIL otherwise