Skip to content
epsilonrt edited this page Oct 2, 2018 · 1 revision

The pidocommand allows you to modify the mode, the pull resistance, to read or write logical or analogical states (PWM) ...

On a raspberry pi model B, this allows to do for example:

$ pido readall
                                    P1 (#1)
+-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
| sOc | iNo |   Name   | Mode | V | Ph || Ph | V | Mode |   Name   | iNo | sOc |
+-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
|     |     |     3.3V |      |   |  1 || 2  |   |      | 5V       |     |     |
|   2 |   8 |    GPIO2 |   IN | 1 |  3 || 4  |   |      | 5V       |     |     |
|   3 |   9 |    GPIO3 |   IN | 1 |  5 || 6  |   |      | GND      |     |     |
|   4 |   7 |    GPIO4 |   IN | 1 |  7 || 8  | 1 | ALT0 | TXD0     | 15  | 14  |
|     |     |      GND |      |   |  9 || 10 | 1 | ALT0 | RXD0     | 16  | 15  |
|  17 |   0 |   GPIO17 |   IN | 0 | 11 || 12 | 0 | IN   | GPIO18   | 1   | 18  |
|  27 |   2 |   GPIO27 |   IN | 0 | 13 || 14 |   |      | GND      |     |     |
|  22 |   3 |   GPIO22 |   IN | 0 | 15 || 16 | 0 | IN   | GPIO23   | 4   | 23  |
|     |     |     3.3V |      |   | 17 || 18 | 0 | IN   | GPIO24   | 5   | 24  |
|  10 |  12 |   GPIO10 |   IN | 0 | 19 || 20 |   |      | GND      |     |     |
|   9 |  13 |    GPIO9 |   IN | 0 | 21 || 22 | 0 | IN   | GPIO25   | 6   | 25  |
|  11 |  14 |   GPIO11 |   IN | 0 | 23 || 24 | 1 | IN   | GPIO8    | 10  | 8   |
|     |     |      GND |      |   | 25 || 26 | 1 | IN   | GPIO7    | 11  | 7   |
+-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
| sOc | iNo |   Name   | Mode | V | Ph || Ph | V | Mode |   Name   | iNo | sOc |
+-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+

                                    P5 (#2)
+-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
| sOc | iNo |   Name   | Mode | V | Ph || Ph | V | Mode |   Name   | iNo | sOc |
+-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+
|     |     |       5V |      |   |  1 || 2  |   |      | 3.3V     |     |     |
|  28 |  17 |   GPIO28 |   IN | 0 |  3 || 4  | 0 | IN   | GPIO29   | 18  | 29  |
|  30 |  19 |   GPIO30 |   IN | 0 |  5 || 6  | 0 | IN   | GPIO31   | 20  | 31  |
|     |     |      GND |      |   |  7 || 8  |   |      | GND      |     |     |
+-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+

On a NanoPi Neo Plus 2, this allows to display for example:

$ pido readall
                                          CON1 (#1)
+-----+-----+----------+------+------+---+----++----+---+------+------+----------+-----+-----+
| sOc | iNo |   Name   | Mode | Pull | V | Ph || Ph | V | Pull | Mode |   Name   | iNo | sOc |
+-----+-----+----------+------+------+---+----++----+---+------+------+----------+-----+-----+
|     |     |     3.3V |      |      |   |  1 || 2  |   |      |      | 5V       |     |     |
|  12 |   8 |  I2C0SDA | ALT2 |  OFF |   |  3 || 4  |   |      |      | 5V       |     |     |
|  11 |   9 |  I2C0SCK | ALT2 |  OFF |   |  5 || 6  |   |      |      | GND      |     |     |
|  91 |   7 |  GPIOG11 |  OFF |  OFF |   |  7 || 8  |   | OFF  | ALT2 | UART1TX  | 15  | 86  |
|     |     |      GND |      |      |   |  9 || 10 |   | OFF  | ALT2 | UART1RX  | 16  | 87  |
|   0 |   0 |   GPIOA0 |  OFF |  OFF |   | 11 || 12 |   | OFF  | OFF  | GPIOA6   | 1   | 6   |
|   2 |   2 |   GPIOA2 |  OFF |  OFF |   | 13 || 14 |   |      |      | GND      |     |     |
|   3 |   3 |   GPIOA3 |  OFF |  OFF |   | 15 || 16 |   | OFF  | OFF  | GPIOG8   | 4   | 88  |
|     |     |     3.3V |      |      |   | 17 || 18 |   | OFF  | OFF  | GPIOG9   | 5   | 89  |
|  22 |  12 |   GPIOC0 |  OFF |  OFF |   | 19 || 20 |   |      |      | GND      |     |     |
|  23 |  13 |   GPIOC1 |  OFF |  OFF |   | 21 || 22 |   | OFF  | OFF  | GPIOA1   | 6   | 1   |
|  24 |  14 |   GPIOC2 |  OFF |  OFF |   | 23 || 24 |   | UP   | OFF  | GPIOC3   | 10  | 25  |
+-----+-----+----------+------+------+---+----++----+---+------+------+----------+-----+-----+
| sOc | iNo |   Name   | Mode | Pull | V | Ph || Ph | V | Pull | Mode |   Name   | iNo | sOc |
+-----+-----+----------+------+------+---+----++----+---+------+------+----------+-----+-----+

                 DBG_UART (#2)
+-----+-----+----------+------+------+---+----+
| sOc | iNo |   Name   | Mode | Pull | V | Ph |
+-----+-----+----------+------+------+---+----+
|     |     |      GND |      |      |   |  1 |
|     |     |       5V |      |      |   |  2 |
|   4 |  17 |  UART0TX | ALT2 |  OFF |   |  3 |
|   5 |  18 |  UART0RX | ALT2 |   UP |   |  4 |
+-----+-----+----------+------+------+---+----+

                   INNER (#3)
+-----+-----+----------+------+------+---+----+
| sOc | iNo |   Name   | Mode | Pull | V | Ph |
+-----+-----+----------+------+------+---+----+
|  10 |  19 |  GPIOA10 |  OFF |  OFF |   |  1 |
| 104 |  32 |  PWR_LED |  OUT |  OFF | 1 |  2 |
+-----+-----+----------+------+------+---+----+

                   CON2 (#4)
+-----+-----+----------+------+------+---+----+
| sOc | iNo |   Name   | Mode | Pull | V | Ph |
+-----+-----+----------+------+------+---+----+
|     |     |       5V |      |      |   |  1 |
|     |     |  USB-DP1 |      |      |   |  2 |
|     |     |  USB-DM1 |      |      |   |  3 |
|     |     |  USB-DP2 |      |      |   |  4 |
|     |     |  USB-DM2 |      |      |   |  5 |
| 105 |  20 |  GPIOL11 |  OFF |  OFF |   |  6 |
|  17 |  11 |  GPIOA17 |  OFF |  OFF |   |  7 |
|  18 |  31 |  GPIOA18 |  OFF |  OFF |   |  8 |
|  19 |  30 |  GPIOA19 |  OFF |  OFF |   |  9 |
|  20 |  21 |  GPIOA20 |  OUT |  OFF | 0 | 10 |
|  21 |  22 |  GPIOA21 |  OFF |  OFF |   | 11 |
|     |     |      GND |      |      |   | 12 |
+-----+-----+----------+------+------+---+----+
| sOc | iNo |   Name   | Mode | Pull | V | Ph |
+-----+-----+----------+------+------+---+----+

As can be seen above, on a NanoPi Neo Plus 2, there are 4 "connectors", the connector INNER corresponds to internal signals to the card which can be useful to handle (here one has the signal of the Led ON and the Led STATUS (GPIOA10)).

Note also that in the case of the NanoPi, the readall command displays a column Pull which allows to display the state of the pull resistor (this feature is not available on a raspberry pi because the BCM2835 does not can not do that).

We can specify the readall command, the number of the connector to display (the number of the connector is displayed above its table after the #), for example:

$ pido readall 1
                                          CON1 (#1)
+-----+-----+----------+------+------+---+----++----+---+------+------+----------+-----+-----+
| sOc | iNo |   Name   | Mode | Pull | V | Ph || Ph | V | Pull | Mode |   Name   | iNo | sOc |
+-----+-----+----------+------+------+---+----++----+---+------+------+----------+-----+-----+
|     |     |     3.3V |      |      |   |  1 || 2  |   |      |      | 5V       |     |     |
|  12 |   8 |  I2C0SDA | ALT2 |  OFF |   |  3 || 4  |   |      |      | 5V       |     |     |
|  11 |   9 |  I2C0SCK | ALT2 |  OFF |   |  5 || 6  |   |      |      | GND      |     |     |
|  91 |   7 |  GPIOG11 |  OFF |  OFF |   |  7 || 8  |   | OFF  | ALT2 | UART1TX  | 15  | 86  |
|     |     |      GND |      |      |   |  9 || 10 |   | OFF  | ALT2 | UART1RX  | 16  | 87  |
|   0 |   0 |   GPIOA0 |  OFF |  OFF |   | 11 || 12 |   | OFF  | OFF  | GPIOA6   | 1   | 6   |
|   2 |   2 |   GPIOA2 |  OFF |  OFF |   | 13 || 14 |   |      |      | GND      |     |     |
|   3 |   3 |   GPIOA3 |  OFF |  OFF |   | 15 || 16 |   | OFF  | OFF  | GPIOG8   | 4   | 88  |
|     |     |     3.3V |      |      |   | 17 || 18 |   | OFF  | OFF  | GPIOG9   | 5   | 89  |
|  22 |  12 |   GPIOC0 |  OFF |  OFF |   | 19 || 20 |   |      |      | GND      |     |     |
|  23 |  13 |   GPIOC1 |  OFF |  OFF |   | 21 || 22 |   | OFF  | OFF  | GPIOA1   | 6   | 1   |
|  24 |  14 |   GPIOC2 |  OFF |  OFF |   | 23 || 24 |   | UP   | OFF  | GPIOC3   | 10  | 25  |
+-----+-----+----------+------+------+---+----++----+---+------+------+----------+-----+-----+
| sOc | iNo |   Name   | Mode | Pull | V | Ph || Ph | V | Pull | Mode |   Name   | iNo | sOc |
+-----+-----+----------+------+------+---+----++----+---+------+------+----------+-----+-----+

To put pin number 0 in output:

$ pido mode 0 out

By default, it is the numbering of the iNo column that is used, but we could also designate the signal 0 by 1.11:

$ pido mode 1.11 out

This notation C.N, makes it possible to quickly designate the pin N (here 11) of the C connector (here 1).

To put this output in high state:

$ pido write 0 1

To put it in the low state:

$ pido write 0 0

You can also toggle the state:

$ pido toggle 0

Or generate a square signal on the pin :

$ pido blink 0 100

To put it in input with pull-up resistor:

$ pido mode 0 in
$ pido pull 0 up

And to read it:

$ pido read 0

Or we can wait for a falling front on this entry:

$ pido wfi 0 falling

See also pido(1) manpage.

Clone this wiki locally