Commit a66936fa authored by Jakob Moser's avatar Jakob Moser
Browse files

Merge branch 'nfc-production-ready' into 'master'

Make NFC production-ready

See merge request moser/poolpay!25
parents 8465762f e28e1d80
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -54,12 +54,9 @@ Then, connect the cables to the Pi as described in this chart:
2. Go to “Interface Options”
3. Go to “SPI”
4. Enable it (no reboot necessary)

<details>
<summary>Further information on enabling SPI</summary>

Enabling SPI will place the line `dtparam=spi=on` in the file `/boot/firmware/config.txt` 
</details>
   * This will enable the first SPI bus (SPI0)
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>Links</summary>
@@ -69,6 +66,8 @@ Enabling SPI will place the line `dtparam=spi=on` in the file `/boot/firmware/co
- [Datasheet (de)](https://cdn-reichelt.de/documents/datenblatt/A300/SBC-RFID-RC522_DB.pdf)
- [Instructions (de)](https://cdn-reichelt.de/documents/datenblatt/C300/SBC-RFID-RC522-ANLEITUNG-08-07-2019.pdf)
- [Instructions (en)](https://cdn-reichelt.de/documents/datenblatt/C300/SBC-RFID-RC522-MANUAL-08-07-2019.pdf)
- [How to enable SPI0 and SPI1 at the same time](https://raspberrypi.stackexchange.com/questions/73346/how-to-enable-spi1-and-spi0-at-the-same-time)
- [SPI pinout map](https://pinout.xyz/pinout/spi)
</details>

### WiFi hotspot

docs/musings/gpio.md

0 → 100644
+5 −0
Original line number Diff line number Diff line
# GPIO

We need to use `rpi-lgpio` instead of `rpi-gpio` so that edge detection works.

See Raspberry Pi book, page 632 and 624.

docs/musings/spi.md

0 → 100644
+17 −0
Original line number Diff line number Diff line
## What does enabling SPI do?

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.**
 No newline at end of file
+1.08 KiB (86.2 KiB)
Loading image diff...
+14 −18
Original line number Diff line number Diff line
@@ -11,40 +11,36 @@
			background: black !important;
		}

		.pin1 .pin {
		.pin31 .pin {
			background: gray !important;
		}

		.pin6 .pin {
		.pin34 .pin {
			background: blue !important;
		}

		.pin6 .pin {
			background: blue !important;
		}

		.pin18 .pin {
		.pin37 .pin {
			background: rgb(165, 118, 42) !important;
			/* brown */
		}

		.pin22 .pin {
		.pin33 .pin {
			background: purple !important;
		}

		.pin24 .pin {
		.pin36 .pin {
			background: red !important;
		}

		.pin19 .pin {
		.pin38 .pin {
			background: yellow !important;
		}

		.pin21 .pin {
		.pin35 .pin {
			background: green !important;
		}

		.pin23 .pin {
		.pin40 .pin {
			background: orange !important;
		}
	</style>
@@ -76,7 +72,7 @@
									class="phys">9</span> Ground</span><span class="pin"></span></a></li>
					<li class="pin11 gpio"><a href="https://pinout.xyz/pinout/pin11_gpio17"
							title="Wiring Pi pin 0"><span class="default"><span class="phys">11</span> <span
									class="name">GPIO 17</span></span><span class="pin"></span></a></li>
									class="name">GPIO 17</span> <small>(SPI1 CE1)</small></small></span><span class="pin"></span></a></li>
					<li class="pin13 gpio"><a href="https://pinout.xyz/pinout/pin13_gpio27"
							title="Wiring Pi pin 2"><span class="default"><span class="phys">13</span> <span
									class="name">GPIO 27</span></span><span class="pin"></span></a></li>
@@ -118,7 +114,7 @@
								class="pin"></span></a></li>
					<li class="pin35 gpio pcm"><a href="https://pinout.xyz/pinout/pin35_gpio19"
							title="Wiring Pi pin 24"><span class="default"><span class="phys">35</span> <span
									class="name">GPIO 19</span> <small>(PCM FS)</small></span><span
									class="name">GPIO 19</span> <small>(SPI1 MISO)</small></span><span
								class="pin"></span></a></li>
					<li class="pin37 gpio"><a href="https://pinout.xyz/pinout/pin37_gpio26"
							title="Wiring Pi pin 25"><span class="default"><span class="phys">37</span> <span
@@ -149,7 +145,7 @@
								class="pin"></span></a></li>
					<li class="pin12 gpio pcm"><a href="https://pinout.xyz/pinout/pin12_gpio18"
							title="Wiring Pi pin 1"><span class="default"><span class="phys">12</span> <span
									class="name">GPIO 18</span> <small>(PCM CLK)</small></span><span
									class="name">GPIO 18</span> <small>(SPI1 CE0)</small></span><span
								class="pin"></span></a></li>
					<li class="pin14 gnd"><a href="https://pinout.xyz/pinout/ground" title="">
							<span class="default"><span class="phys">14</span> Ground</span><span
@@ -194,14 +190,14 @@
					</li>
					<li class="pin36 gpio"><a href="https://pinout.xyz/pinout/pin36_gpio16"
							title="Wiring Pi pin 27"><span class="default"><span class="phys">36</span> <span
									class="name">GPIO 16</span></span><span class="pin"></span></a></li>
									class="name">GPIO 16</span> <small>(SPI1 <s>CE2</s> CE0, for us)</small></span><span class="pin"></span></a></li>
					<li class="pin38 gpio pcm"><a href="https://pinout.xyz/pinout/pin38_gpio20"
							title="Wiring Pi pin 28"><span class="default"><span class="phys">38</span> <span
									class="name">GPIO 20</span> <small>(PCM DIN)</small></span><span
									class="name">GPIO 20</span> <small>(SPI1 MOSI)</small></span><span
								class="pin"></span></a></li>
					<li class="pin40 gpio pcm"><a href="https://pinout.xyz/pinout/pin40_gpio21"
							title="Wiring Pi pin 29"><span class="default"><span class="phys">40</span> <span
									class="name">GPIO 21</span> <small>(PCM DOUT)</small></span><span
									class="name">GPIO 21</span> <small>(SPI1 SCLK)</small></span><span
								class="pin"></span></a></li>
				</ul>
			</nav>
Loading