@@ -58,24 +58,6 @@ Then, connect the cables to the Pi as described in this chart:
5. Add the line `dtoverlay=spi1-1cs,cs0_pin=16` somewhere in `/boot/firmware/config.txt` (reboot might be necessary here)
* This will enable the second SPI bus (SPI1). Furthermore, it will set the Chip Select pin for device 0 (`cs0`) to GPIO 16.
<details>
<summary>Further information on SPI</summary>
Enabling SPI will place the line `dtparam=spi=on` in the file `/boot/firmware/config.txt`.
Multiple devices can be connected to a single SPI bus (e.g. SPI0). They share the SCLK (clock), MISO and MOSI pins, however, each device has to be wired to a dedicated Chip Select (CS, = CE) pin. This is why an SPI devices is listed as `/dev/spi0.0`: The first `0` is the bus, the second `0` the device.
So, do we use this to connect both the LCD and the NFC reader? **Actually, no.**
The Raspberry Pi also has two SPI buses (SPI0 and SPI1). They have different SCLK, MISO and MOSI pins; and as stated above, each SPI bus has its own set of CS pins. In the pinout.xyz diagram, you can see that there is e.g. a `SPI0 CE0` and a `SPI1 CE0` pin.
Okay, so we wire up the LCD on SPI0 as device 0 and connect it to the respective pins; and then the NFC reader on SPI1 as device 0 and connect it to the respective pins, right? **Almost.**
The problem is that `SPI1 CE0` is pin 18, which is occupied by the GPIO header for the display. I don't know if it is needed, but I didn't want to take the risk. This is why I am remapping pin 18 (which would normally be `SPI1 CE2`) to the Chip Select pin for device 0 on SPI1. This is done with the `cs0_pin=16` instruction.
**This means that the NFC reader will be `/dev/spi1.0` (device 0 on SPI1), but wired physically as if it were device 2.**
Enabling SPI will place the line `dtparam=spi=on` in the file `/boot/firmware/config.txt`.
## There are two SPI buses (SPI0 and SPI1), both of which support multiple devices
Multiple devices can be connected to a single SPI bus (e.g. SPI0). They share the SCLK (clock), MISO and MOSI pins, however, each device has to be wired to a dedicated Chip Select (CS, = CE) pin. This is why an SPI devices is listed as `/dev/spi0.0`: The first `0` is the bus, the second `0` the device.
So, do we use this to connect both the LCD and the NFC reader? **Actually, no.**
The Raspberry Pi also has two SPI buses (SPI0 and SPI1). They have different SCLK, MISO and MOSI pins; and as stated above, each SPI bus has its own set of CS pins. In the pinout.xyz diagram, you can see that there is e.g. a `SPI0 CE0` and a `SPI1 CE0` pin.
Okay, so we wire up the LCD on SPI0 as device 0 and connect it to the respective pins; and then the NFC reader on SPI1 as device 0 and connect it to the respective pins, right? **Almost.**
The problem is that `SPI1 CE0` is pin 18, which is occupied by the GPIO header for the display. I don't know if it is needed, but I didn't want to take the risk. This is why I am remapping pin 18 (which would normally be `SPI1 CE2`) to the Chip Select pin for device 0 on SPI1. This is done with the `cs0_pin=16` instruction.
**This means that the NFC reader will be `/dev/spi1.0` (device 0 on SPI1), but wired physically as if it were device 2.**