Krolyxon
Commit 1d55752

Branches

Tags

Refs →

orion-rf.piolibdepsesp32-s3-n16r8RF24docsrpi_general.md

120 lines · 3.7 KB · Markdown

1# Linux General/Raspberry Pi
2
3@tableofcontents
4
5<!-- markdownlint-disable MD031 -->
6RF24 supports a variety of Linux based devices via various drivers. Some boards like RPi can utilize multiple methods
7to drive the GPIO and SPI functionality.
8
9## Potential PreConfiguration
10
11If SPI is not already enabled, load it on boot:
12
13```shell
14sudo raspi-config
15```
16
171. Update the tool via the menu as required
182. Select **Advanced** and **enable the SPI kernel module**
193. Update other software and libraries
20 ```shell
21 sudo apt-get update
22 sudo apt-get upgrade
23 ```
24
25## Build Options
26
27The default build on Raspberry Pi utilizes the included **BCM2835** driver from [the BCM2835 Library](http://www.airspayce.com/mikem/bcm2835)
28
291. See [the Linux section for automated installation](linux_install.md).
302. Manual install:
31 ```shell
32 make
33 sudo make install
34 ```
35
36## Connections and Pin Configuration
37
38Using pin 15(GPIO22) for CE, pin 24(GPIO8 commonly labeled as CE0) for CSN
39
40Can use any available SPI BUS for CSN.
41
42In general, use
43
44```cpp
45RF24 radio(<ce_pin>, <a>*10+<b>);
46```
47
48for proper constructor to address the correct spi device at /dev/spidev\<a\>.\<b\>
49
50Choose any GPIO output pin for radio CE pin.
51
52> [!WARNING]
53> The pin numbers may be different for certain systems.
54> In this library's examples, we use the BCM pin numbers for BroadCom chips such as
55> those used on all Raspberry Pi models.
56>
57> For Raspberry Pi clones, such as Orange Pi or Banana Pi, defer to the pin numbers described
58> in their corresponding documentation/manual.
59>
60> Hint: If libgpiod is installed (not required for this library),
61> then you can use the included
62> [CLI tools shipped with libgpiod](https://libgpiod.readthedocs.io/en/latest/gpio_tools.html)
63> to gleam system-specific details.
64
65### Linux kernel (SPIDEV driver) and the GPIO chip number
66
67This RF24 library, as of v1.4.9, uses the Linux kernel's Character Device API to interface
68with GPIO pins (AKA "lines" in kernel docs). Previous versions used the deprecated "sys fs" interface.
69
70By default, this library attempts to use pins exposed via `/dev/gpiochip0`.
71Some systems have multiple public-facing GPIO chips integrated (ie nVidia Jetson series).
72If your system exposes the desired GPIO pins via a different chip (ie `/dev/gpiochip4`), then the
73`RF24_LINUX_GPIO_CHIP` can be set to the correct value when compiling the library.
74
75```shell
76cmake .. -DRF24_LINUX_GPIO_CHIP="/dev/gpiochip4"
77```
78
79### General
80
81```cpp
82RF24 radio(22, 0);
83```
84
85### MRAA Constructor
86
87```cpp
88RF24 radio(15, 0);
89```
90
91See [the MRAA documentation for Raspberry Pi support](http://iotdk.intel.com/docs/master/mraa/rasppi.html)
92
93### SPI_DEV Constructor
94
95```cpp
96RF24 radio(22, 0);
97```
98
99See [the Raspberry Pi documentation about the GPIO pins](https://www.raspberrypi.com/documentation/computers/os.html#gpio-and-the-40-pin-header)
100
101### Pins
102
103| PIN | NRF24L01 | RPI | RPi -P1 Connector |
104| --- | -------- | ---------- | ----------------- |
105| 1 | GND | rpi-gnd | (25) |
106| 2 | VCC | rpi-3v3 | (17) |
107| 3 | CE | rpi-gpio22 | (15) |
108| 4 | CSN | rpi-gpio8 | (24) |
109| 5 | SCK | rpi-sclk | (23) |
110| 6 | MOSI | rpi-mosi | (19) |
111| 7 | MISO | rpi-miso | (21) |
112| 8 | IRQ | - | - |
113
114## brief history of RF24 library lineage
115
116Based on the arduino lib from [J. Coliz](maniacbug@ymail.com),
117the library was berryfied by [Purinda Gunasekara](purinda@gmail.com)
118then forked from github [stanleyseow/RF24](https://github.com/stanleyseow/RF24) to [jscrane/RF24-rpi](https://github.com/jscrane/RF24-rpi)
119
120Network lib also based on [farconada/RF24Network](https://github.com/farconada/RF24Network)