SPI

Description

This command can be used to change the SPI slave settings of the module.

Parameters

Two arguments are required. The first one is the clock polarity and the second one is the clock phase. Both arguments can be either 1 or 0. The clock polarity determines if the clock signal is active high or active low. A 0 as clock polarity means, that the high clock pulses (the default SPI mode) are used while a 1 means low clock pulses are used.

The clock phase determines the relationship between the data lines and the clock line in SPI transfers. If 0, data is sampled on the first clock edge and a transfer must begin and end with with activation and deactivation of the chip select input. If 1, data is sampled on the second clock edge. A transfer starts with the first clock edge and ends with the last sampling edge while the chip select input is active. In this mode it is possible too keep the chip select input constantly active while using the SPI.

Here is a list of all possible SPI modes on the Avisaro Module:

Mode 0
- Clock Polarity = 0, Clock Phase = 0, Chip Select must be activated and deactivated between transfers

Mode 1
- Clock Polarity = 0, Clock Phase = 1, Chip Select must be activated and deactivated between transfers

Mode 2
- Clock Polarity = 1, Clock Phase = 0, Chip Select can remain active while transferring multiple bytes

Mode 3
- Clock Polarity = 1, Clock phase = 1, Chip Select can remain active while transferring multiple bytes

Return Value

ERR_ARGUMENT (4) if one or all of the arguments are neither 0 nor 1
ERR_OK (0) if the command was accepted

Example 

SPI 0 0 

Sets the SPI to Mode 0

Remarks

To activate the SPI as I/O protocol use the PROT command.

 


SPI?

Description 

Reads back SPI settings made by the SPI command. SPI? always prints out two binary numbers. For details see the description above.