|Top Previous Next|
Gets or sets configuration parameters for the SPI bus.
A group of bit fields that determine SPI bus parameters.
The config property is a byte value with bit fields that control SPI parameters. You must combine (bit-wise OR) values from each section below to create a complete value.
The parameters set by the config property apply to a single SPI slave device. If you have multiple devices on the SPI bus, you will need to change the config property each time you switch between devices.
There are four combinations of clock phase and polarity with respect to serial data on the bus. Clock polarity refers to the level of the clock when the bus is idle, thus determining the whether the first edge is rising (if the clock was low) or falling (if the clock was high). Clock phase refers to whether data is sampled on the leading edge (whether rising or falling) or on the trailing edge. The table below details how each SPI mode determines clock phase and polarity.
For automatic control of the SS pin, use one of the following numeric values to designate physical pins:
For manual control of SS or a non-SPI protocol that does not use SS, select the constant noSS.
SPI sends data most-significant bit (MSB) first. If you are using a non-SPI protocol and need to send the least-significant bit (LSB) first, use the constant LSBfirst.
// Set up for SPI EEPROM
Cell.SPI.config = Cell.SPI.mode0 | 12; // SS on B4
// Set up for 3-wire interface (DS1620)
Cell.SPI.config = Cell.SPI.mode3 | Cell.SPI.LSBfirst | Cell.SPI.noSS;