You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/drivers/hal_gpio.adoc
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@
5
5
6
6
= Generic driver for any GPIO supported by gpiod.
7
7
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.
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.
24
24
The GPIO pin names in the "loadrt" line of the HAL given above should be the names given by the "gpioinfo" command.
25
25
26
26
Sample output (truncated):
@@ -57,7 +57,7 @@ A list of input and/or output pins should be specified as shown in the sample ab
57
57
Additional modifiers are:
58
58
*invert* (valid for outputs only). Inverts the sense of the physical pin relative to the value in HAL.
59
59
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.
61
61
62
62
The following functions are accepted in all versions, but are only effective if a version of libgpiod_dev >= 1.6 is installed.
63
63
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.
Copy file name to clipboardExpand all lines: docs/src/drivers/hal_pi_gpio.adoc
+40-39Lines changed: 40 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,61 +7,63 @@ It is only really intended to work on the Raspberry Pi. It may, or may not, work
7
7
8
8
== Purpose
9
9
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.
11
12
12
13
== Usage
13
14
14
15
----
15
16
loadrt hal_pi_gpio dir=0x13407 exclude=0x1F64BF8
16
17
----
17
18
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).
19
20
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).
21
22
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.
23
24
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"]
25
27
|===
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
54
56
|===
55
57
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.
59
60
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*.
60
62
61
63
== Pins
62
64
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
65
67
66
68
Depending on the dir and exclude masks.
67
69
@@ -83,7 +85,6 @@ For unknown reasons the driver also creates HAL _pins_ to indicate timing
83
85
== Functions
84
86
85
87
* 'hal_pi_gpio.read' - Add this to the base thread to update the HAL pin values to match the physical input values.
86
-
87
88
* 'hal_pi_gpio.write' - Add this to the base thread to update the physical pins to match the HAL values.
88
89
89
90
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