Configuring SPI, I2C and other GPIOs

Here's how to free up all the SPI buses on the pi-top [4]

Sometimes, you may wish to work with peripherals (such as HATs) or content that is specifically designed to work with particular GPIO pins. The pi-top [4] uses I2C for communication with the hub, with a fixed I2C address of 0x11. Anything that requires this address is unfortunately incompatible.

I2C uses GPIO pins 2 and 3. GPIO 2 is the Data pin and GPIO 3 is the Clock pin

However, pi-top [4] also uses SPI1 by default for its onboard Mini OLED Screen. The good news is that the pi-top [4] is also capable of using SPI0 to do this instead. This is useful for when the GPIO pins that are used by SPI1 are desired for something else - for example, a HAT that uses SPI1 or any of its pins (regardless of its intended use).

SP1 uses GPIO pins 16, 17, 18, 19, 20, and 21

SPI0 uses GPIO pins 7, 8 9, 10, and 11

To set the SPI bus of the OLED, run the appropriate command:

pi-top oled spi 0          #Forces the OS to switch the SPI bus to Port 0
pi-top oled spi 1 #Forces the OS to switch the SPI bus to Port 1

Alternatively, you can also use the following to turn off the OLED for the current session, but bear in mind it will resume function when the pi-top is rebooted.

sudo systemctl stop pt-sys-oled    #stop for the current session
sudo systemctl start pt-sys-oled #start for the current session

And lastly, you can also run the following to disable the OLED from bootup.

sudo systemctl disable pt-sys-oled      #disable on boot
sudo systemctl disable pt-sys-oled      #enable on boot

Remember that the OLED will only work on pi-top OS or on Raspberry Pi OS with the pi-top packages installed. If you have neither of these then the OLED won't function is a great place to learn the additional functions of the GPIO pins on the Raspberry Pi. Have a look at their site for more information

The Mini OLED Screen is fed by a multiplexer controlled by the Hub. The multiplexer is connected to SPI1, SPI0 and to the hub. The hub then selects which bus is connected to the Mini OLED Screen at any time.