NAME
spi – access to the main Raspberry Pi SPI interface

SYNOPSIS
bind –a #π /dev

/dev/spictl
/dev/spi0
/dev/spi1

DESCRIPTION
The Broadcom SoC on the Raspberry Pi has three SPI interfaces: the main SPI interface, designated SPI0, and two auxiliary SPI interfaces, designated SPI1 and SPI2. On the first generation Pis, only SPI0 was brought out to the header on the board. For the B+ and Pi2 models, SPI0 and SPI1 are available. The driver described in this man page only supports SPI0.

Reads and writes to the files spi0 and spi1 transfer data over the SPI bus. Accesses to spi0 cause the transfers to take place with the CE0_0 line asserted low. Similarly, transfers to spi1 are carried out with CE1_0 asserted low.

The spictl file is used to set various control parameters. It accepts the following commands:
clock freq
Set the frequency of the SPI clock. The clock from which the SPI clock is derived runs at 250MHz, and the Broadcom documentation specifies that the divisor must be a power of 2. The driver sets the divisor to the highest power of 2 that results in a clock rate that is less than or equal to the freq parameter in MHz.
mode n
Treats n as a two–bit number specifying the settings for the clock phase and clock polarity. The default value of 0 matches the polarity and phase requirements of most peripheral devices.
lossi
Enable a bidirectional mode where the MOSI line is used for both reads and writes.

SOURCE
/sys/src/9/bcm/devspi.c
/sys/src/9/bcm/spi.c

BUGS
The various SPI modes are untested and the LoSSI support is unimplemented.
Copyright © 2024 Plan 9 Foundation. All rights reserved.