Skip to content

Commit b3a3906

Browse files
authored
Merge pull request #2799 from smoe/docs_translations_rpi_02
Documentation on RPi - smallish corrections and (hopefully) clarification (smoe:docs_translations_rpi_02)
2 parents 8bcef84 + 8857bf7 commit b3a3906

2 files changed

Lines changed: 43 additions & 42 deletions

File tree

docs/src/drivers/hal_gpio.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
= Generic driver for any GPIO supported by gpiod.
77

8-
This driver has been tested on the Pi, and should also work on Bananapi, Beaglebone, Pine64 (et al) and other SBCs and potentially on other platforms.
8+
This driver has been tested on the Raspberry Pi, and should also work on Bananapi, Beaglebone, Pine64 (et al) and other single board computers, and potentially on other platforms.
99

1010
== Purpose
1111

@@ -20,7 +20,7 @@ loadrt hal_gpio inputs=GPIO5,GPIO6,GPIO12,GPIO13,GPIO16,GPIO17,GPIO18,GPIO19 \
2020
reset=GPIO21,GPIO22
2121
----
2222

23-
This driver relies on the libgpiod-dev library and the gpiod package, which contains a number of utilities for configuring and querying GPIO.
23+
This driver relies on the libgpiod-dev library and the https://tracker.debian.org/pkg/libgpiod[gpiod] package, which contains a number of utilities for configuring and querying GPIO.
2424
The GPIO pin names in the "loadrt" line of the HAL given above should be the names given by the "gpioinfo" command.
2525

2626
Sample output (truncated):
@@ -57,7 +57,7 @@ A list of input and/or output pins should be specified as shown in the sample ab
5757
Additional modifiers are:
5858
*invert* (valid for outputs only). Inverts the sense of the physical pin relative to the value in HAL.
5959

60-
*reset* (valid for outputs only). If any pins are allocated to the "reset" list than a HAL parameter *hal_gpio.reset_ns* will be created. This will have no effect unless the *hal_gpio.reset* function is added to a realtime thread. This should be placed after the *hal_gpio.write* function and must be in the same thread. The behaviour of this function is equivalent to the same function in the *hal_parport* driver, and it allows a step pulse every thread cycle. If the *hal_gpio.reset_ns* time is set longer than 1/4 of the period of the thread that it is added to, then the value will be reduced to 1/4 the thread period. There is a lower limit to how long the pulse can be. With 8 pins in the output list the pulse width can not reduce lower than 5000ns on a Pi4, for example.
60+
*reset* (valid for outputs only). If any pins are allocated to the "reset" list then a HAL parameter *hal_gpio.reset_ns* will be created. This will have no effect unless the *hal_gpio.reset* function is added to a realtime thread. This should be placed after the *hal_gpio.write* function and must be in the same thread. The behaviour of this function is equivalent to the same function in the *hal_parport* driver, and it allows a step pulse every thread cycle. If the *hal_gpio.reset_ns* time is set longer than 1/4 of the period of the thread that it is added to, then the value will be reduced to 1/4 the thread period. There is a lower limit to how long the pulse can be. With 8 pins in the output list the pulse width can not reduce lower than 5000 ns on an RPi4, for example.
6161

6262
The following functions are accepted in all versions, but are only effective if a version of libgpiod_dev >= 1.6 is installed.
6363
They should be used in the same way as the parameters described above, and will alter the electrical parameters of the GPIO pins *if* this is supported by the hardware.

docs/src/drivers/hal_pi_gpio.adoc

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -7,61 +7,63 @@ It is only really intended to work on the Raspberry Pi. It may, or may not, work
77

88
== Purpose
99

10-
This driver allows the use of the Rapberry Pi GPIO pins in a way analagous to the parallel port driver on x86 PCs. It can use the same step generators, encoder counters and similar components.
10+
This driver allows the use of the Rapberry Pi GPIO pins in a way analagous to the parallel port driver on x86 PCs.
11+
It can use the same step generators, encoder counters and similar components.
1112

1213
== Usage
1314

1415
----
1516
loadrt hal_pi_gpio dir=0x13407 exclude=0x1F64BF8
1617
----
1718

18-
The "dir" mask determines whether the pins are inputs and outputs, the exclude mask prevents the driver from using the pins (and so allows them to be used for their normal RPi purpses such as SPI or UART)
19+
The "dir" mask determines whether the pins are inputs and outputs, the exclude mask prevents the driver from using the pins (and so allows them to be used for their normal RPi purposes such as SPI or UART).
1920

20-
The mask can be in decimal or hexadecimal (hex may be easier as there will be no carries)
21+
The mask can be in decimal or hexadecimal (hex may be easier as there will be no carries).
2122

22-
Add up the values for all pins that should be configured as output, and for all pins that should be excluded according to the following table.
23+
To determine the value of the masks, add up the hex/decimal values for all pins that should be configured as output, and analogously for all pins that should be excluded according to the following table.
2324

24-
[cols="1,1,1,1"]
25+
.GPIO masks - mapping of GPIO numbers (leftmost column) to physical pin numbers as printed on the Raspberry Pi board (rightmost column) and the decimal/hexadecimal values that contribute to the value of the mask.
26+
[cols="1,1,1,1",options="header"]
2527
|===
26-
| GPIO Num | Decimal | Hex | Pin Num
27-
28-
| 2 | 1 | 0x00000001 | 3
29-
| 3 | 2 | 0x00000002 | 5
30-
| 4 | 4 | 0x00000004 | 7
31-
| 5 | 8 | 0x00000008 | 29
32-
| 6 | 16 | 0x00000010 | 31
33-
| 7 | 32 | 0x00000020 | 26
34-
| 8 | 64 | 0x00000040 | 24
35-
| 9 | 128 | 0x00000080 | 21
36-
| 10 | 256 | 0x00000100 | 19
37-
| 11 | 512 | 0x00000200 | 23
38-
| 12 | 1024 | 0x00000400 | 32
39-
| 13 | 2048 | 0x00000800 | 33
40-
| 14 | 4096 | 0x00001000 | 8
41-
| 15 | 8192 | 0x00002000 | 10
42-
| 16 | 16384 | 0x00004000 | 36
43-
| 17 | 32768 | 0x00008000 | 11
44-
| 18 | 65536 | 0x00010000 | 12
45-
| 19 | 131072 | 0x00020000 | 35
46-
| 20 | 262144 | 0x00040000 | 38
47-
| 21 | 524288 | 0x00080000 | 40
48-
| 22 | 1048576 | 0x00100000 | 15
49-
| 23 | 2097152 | 0x00200000 | 16
50-
| 24 | 4194304 | 0x00400000 | 18
51-
| 25 | 8388608 | 0x00800000 | 22
52-
| 26 | 16777216 | 0x01000000 | 37
53-
| 27 | 33554432 | 0x02000000 | 13
28+
^| GPIO Num ^| Decimal ^| Hex ^| Pin Num
29+
30+
| 2 >| 1 | 0x00000001 ^| 3
31+
| 3 >| 2 | 0x00000002 ^| 5
32+
| 4 >| 4 | 0x00000004 ^| 7
33+
| 5 >| 8 | 0x00000008 ^| 29
34+
| 6 >| 16 | 0x00000010 ^| 31
35+
| 7 >| 32 | 0x00000020 ^| 26
36+
| 8 >| 64 | 0x00000040 ^| 24
37+
| 9 >| 128 | 0x00000080 ^| 21
38+
| 10 >| 256 | 0x00000100 ^| 19
39+
| 11 >| 512 | 0x00000200 ^| 23
40+
| 12 >| 1024 | 0x00000400 ^| 32
41+
| 13 >| 2048 | 0x00000800 ^| 33
42+
| 14 >| 4096 | 0x00001000 ^| 8
43+
| 15 >| 8192 | 0x00002000 ^| 10
44+
| 16 >| 16384 | 0x00004000 ^| 36
45+
| 17 >| 32768 | 0x00008000 ^| 11
46+
| 18 >| 65536 | 0x00010000 ^| 12
47+
| 19 >| 131072 | 0x00020000 ^| 35
48+
| 20 >| 262144 | 0x00040000 ^| 38
49+
| 21 >| 524288 | 0x00080000 ^| 40
50+
| 22 >| 1048576 | 0x00100000 ^| 15
51+
| 23 >| 2097152 | 0x00200000 ^| 16
52+
| 24 >| 4194304 | 0x00400000 ^| 18
53+
| 25 >| 8388608 | 0x00800000 ^| 22
54+
| 26 >| 16777216 | 0x01000000 ^| 37
55+
| 27 >| 33554432 | 0x02000000 ^| 13
5456
|===
5557

56-
Note that in the calculation of the masks the GPIO numbers are used. Whereas in the naming of the HAL pins it is the Raspberry Pi header pin numbers.
57-
58-
So, for example, if you enable GPIO 17 as an output (dir=0x200) then that output will be controlled by the hal pin *hal_pi_gpio.pin-11-out*.
58+
Note: In the calculation of the individual pin's mask value its GPIO numbers are used, the value being derived as 2^(_GPIO number_ - 2),
59+
whereas in the naming of the HAL pins it is the Raspberry Pi header pin numbers.
5960

61+
So, for example, if you enable GPIO 17 as an output (dir=0x8000) then that output will be controlled by the hal pin *hal_pi_gpio.pin-11-out*.
6062

6163
== Pins
6264

63-
* hal_pi_gpio.pin-NN-out
64-
* hal_pi_gpio.pin-NN-in
65+
* hal_pi_gpio.pin-__NN__-out
66+
* hal_pi_gpio.pin-__NN__-in
6567

6668
Depending on the dir and exclude masks.
6769

@@ -83,7 +85,6 @@ For unknown reasons the driver also creates HAL _pins_ to indicate timing
8385
== Functions
8486

8587
* 'hal_pi_gpio.read' - Add this to the base thread to update the HAL pin values to match the physical input values.
86-
8788
* 'hal_pi_gpio.write' - Add this to the base thread to update the physical pins to match the HAL values.
8889

8990
Typically the 'read' function will be early in the call list, before any encoder counters and the 'write' function will be later in the call list, after stepgen.make-pulses.

0 commit comments

Comments
 (0)