PreviousNext
Help > Software > The <platform.h> Library for C.impl > Communications
Communications

int spiOpen(int channel, int mode, int baudrate)

Open a SPI channel for communication. Will return 0 is successful, or a negative value result otherwise.

ELLO 1A has only one SPI channel, which is shared among all SPI devices (including the SD card), so the only acceptable parameter for channel number, is 1.

The ‘mode’ parameter specifies the SPI mode between 0 and 3. The port is always initialised for exchange of data words with length of 8 bits.

The ‘baudrate‘ parameter defines the speed of the transfer.

 

int spiClose(int channel)

Close a SPI channel. Will return 0 is successful, or a negative value result otherwise.

The only acceptable parameter for ‘channel’ in ELLO 1A, is 1.

 

unsigned char spiByte(int channel, unsigned char data)

Perform data exchange of a single byte through an open SPI channel. A SPI transfer involves simultaneous transmit and receive operation on every transfer.

It is important to mention, that the chip select signal for the SPI device participating on the other end of the communication, must be set low prior to the actual transfer taking place, and set back high when the transfer is complete.

The only acceptable parameter for ‘channel’ in ELLO 1A, is 1.

 

void spiBlock(int channel, unsigned char *buffer, size_t len)

Perform data exchange of data block of ‘len’ bytes through an open SPI channel. The data to be transmitted should be preloaded in the buffer, and the received data is returned on its place.

It is important to mention, that the chip select signal for the SPI device participating on the other end of the communication, must be set low prior to the actual transfer taking place, and set back high when the transfer is complete.

The only acceptable parameter for ‘channel’ in ELLO 1A, is 1.