Package comm
Class SPI

Public Method open

static void open(int freq, byte dss, byte cpol, byte cpha, byte msm)

Throws:

_INSERT_METHOD_SIGNATURE_HERE_

Description:

Parameter Range Description
freq 500 ... 7000 clock frequency in kHz
dss 8 ... 16 data size selection ranging from 8 to 16-bit per frame
cpol 0 ... 1 clock polarity
(cpol = 0) produces a steady state low value on the SCK pin when data is not being transferred
(cpol = 1) produces a steady state high value on the SCK pin when data is not being transferred
cpha 0 ... 1 clock phase
(cpha = 0) data is captured on the first clock edge transition
(cpha = 1) data is captured on the second clock edge transition
msm SPI.MASTER or
SPI.SLAVE
master slave mode
(msm = SPI.MASTER) master mode
(msm = SPI.SLAVE) slave mode

The SPI communication parameter can be adjusted with the open(int, byte, byte, byte, byte) method. All parameters for the SPI communication are listed in the table above. Bit order is always MSB first.

Example

The following code example shows how to open the SPI for the serial communication.

   import comm.SPI;

   ...

   int freq = 1000;

   byte dss = 16;

   byte cpol = 0;

   byte cpha = 0;

   SPI.open(freq, dss, cpol, cpha, SPI.MASTER);

The comm package is imported in the first line to make use of the SPI. Afterwards, the SPI is initialised with the open method.

Notes