opio.1 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. .\" Automatically generated by Pandoc 2.9.2.1
  2. .\"
  3. .TH "OPIO" "1" "Aug 2021" "opio v1.0" ""
  4. .hy
  5. .SH NAME
  6. .PP
  7. opio - Control GPIO pins on OrangePi.
  8. A replacement for WiringPi
  9. .SH SYNOPSIS
  10. .PP
  11. \f[B]opio\f[R] [-2] readall
  12. .PP
  13. \f[B]opio\f[R] [-2] readallx
  14. .PP
  15. \f[B]opio\f[R] [-2] exports
  16. .PP
  17. \f[B]opio\f[R] leds
  18. .PP
  19. \f[B]opio\f[R] mode \f[I]pin\f[R] [ in | out | alt ]
  20. .PP
  21. \f[B]opio\f[R] [ -d ] read \f[I]pin\f[R]
  22. .PP
  23. \f[B]opio\f[R] [ -d ] write \f[I]pin\f[R] [ 1 | 0 | on | off ]
  24. .SH DESCRIPTION
  25. .PP
  26. \f[B]opio\f[R] allows access to the GPIO pins of OrangePi single-board
  27. computers.
  28. This version is designed speciifically for the
  29. .IP \[bu] 2
  30. OrangePi i96
  31. .IP \[bu] 2
  32. OrangePi 2G-iot
  33. .PP
  34. Running \f[B]opio\f[R] without any parameters will show its usage.
  35. \f[B]opio\f[R] requires `su' permissions, so must be run as `root' or
  36. via `sudo'.
  37. .SH COMMANDS
  38. .TP
  39. \f[B]readall\f[R]
  40. Displays the state of the gpio pins in a grid format.
  41. The list includes all the pins used in the on-board 40 pin connector.
  42. For each pin, the listing shows the gpio pin number, its alternate
  43. function, its i96 pin name, its current \f[I]mode\f[R] and
  44. \f[I]value\f[R], and the corresponding pin number on the 40 pin
  45. connector.
  46. .TP
  47. \f[B]readallx\f[R]
  48. Creates a similar chart, but includes the RDA pin names.
  49. .TP
  50. \f[B]leds\f[R]
  51. Creates a smaller chart, for the interesting I/O pins which are
  52. \f[I]not\f[R] part of the 40 pin connector.
  53. On the i96 board, there are 3 LEDs which can be controlled via
  54. \f[B]opio\f[R]
  55. .TP
  56. \f[B]exports\f[R]
  57. Print a list of entries in /sys/class/gpio, indicating which pins have
  58. been exported (prepared for read/write).
  59. If a gpio pin exists on the 40 pin connector, the pin number is listed.
  60. .TP
  61. \f[B]mode\f[R]
  62. Sets the \f[I]mode\f[R] for a pin as either `in', `out' or
  63. `alternate-function'.
  64. Normally \f[B]opio\f[R] will create an export for this gpio pin, and
  65. then set the direction.
  66. If you set the `alt' function, the export will be removed.
  67. With the \f[B]-d\f[R] option, the export is not created, but the
  68. `in'/`out'/`alt' \f[I]mode\f[R] setting will still be done.
  69. \f[B]mode\f[R] with a pin number and no set-mode request, will simply
  70. return the current \f[I]mode\f[R] (in, out, alt, in*, alt*).
  71. .TP
  72. \f[B]read\f[R]
  73. Returns the current \f[I]value\f[R] (1/0) of the gpio pin, if possible.
  74. If the pin is in `alt' \f[I]mode\f[R], it is changed to `in' before the
  75. \f[I]value\f[R] is read.
  76. .TP
  77. \f[B]write\f[R]
  78. Attempts to write the given \f[I]value\f[R] into the given pin.
  79. If the pin is in `alt' \f[I]mode\f[R], it is changed to `out' before the
  80. \f[I]value\f[R] is asserted.
  81. .SH OPTIONS
  82. .TP
  83. \f[B]-d\f[R]
  84. Use low-level access to control the pins.
  85. Without the \f[B]-d\f[R] option, \f[B]opio\f[R] tries to use the
  86. `export' gpio mechanism (at /sys/class/gpio).
  87. The \f[B]-d\f[R] option only applies to \f[B]mode, read\f[R] and
  88. \f[B]write\f[R]
  89. .TP
  90. \f[B]-2\f[R]
  91. Use the pin assignments for the OrangePi-2G-iot.
  92. The default is to use the pins for the OrangePi-i96.
  93. If you wish to make this option persistent, create a file named
  94. /etc/OrangePi_2G_IOT.
  95. .SS Mode
  96. .PP
  97. The microcontroller used on these boards presents i/o pins which can be
  98. set to `general usage' GPIO as `input' or `output, or alternatively, set
  99. to operate in a specific way (uart, i2c, i2s, pcm, etc). \f[B]opio\f[R]
  100. refers the the current \f[I]mode\f[R] of each pin one of these: either
  101. GPIO \[cq]in', GPIO `out', or \[cq]alt\[cq]ernate function.
  102. .PP
  103. The `in*' or `out*' are marked with an asterisk to indicate that the pin
  104. is in GPIO \f[I]mode\f[R], but \f[I]not\f[R] listed in the current
  105. `export' list.
  106. .PP
  107. As a convenience, the \f[B]read\f[R] and \f[B]write\f[R] commands will
  108. automatically set the \f[I]mode\f[R] on the GPIO pin and create an
  109. export.
  110. So, generally, the \f[B]mode\f[R] command is only \f[I]required\f[R] if
  111. you wish to change a pin back to its `alt' function.
  112. .SH HERITAGE
  113. .PP
  114. This program is styled after the \f[B]gpio\f[R] program written by
  115. Gordon Henderson for the Raspberry Pi.
  116. Unlike the original \f[B]gpio\f[R] program, this one does not implement:
  117. .IP \[bu] 2
  118. export\&...\&...\&.....exports are created automatically by \f[B]mode,
  119. read\f[R] and \f[B]write\f[R]
  120. .IP \[bu] 2
  121. pwm, clk\&...\&...\&...this microcontroller does not have PWM or CLK
  122. type pins
  123. .IP \[bu] 2
  124. aread, awrite\&....these boards have not connected and ADC/DAC pins
  125. .SH NUMBERING
  126. .PP
  127. There are 4 naming schemes used to identify pins in these boards.
  128. \f[B]opio\f[R] uses exclusively the Linux gpio device driver numbers,
  129. the first on this list:
  130. .IP \[bu] 2
  131. Linux gpio numbers (from /sys/class/gpio)
  132. .IP \[bu] 2
  133. I/O connector pin numbers (1-40)
  134. .IP \[bu] 2
  135. RDA microcontroller pin names (like GPIOA_C23)
  136. .IP \[bu] 2
  137. i96 pin names (like GPIOB)
  138. .PP
  139. You can explore the correspondence between these naming schemes with
  140. \f[B]opio readall\f[R] and \f[B]opio readallx\f[R]
  141. .SH HIGH LEVEL/LOW LEVEL ACCESS
  142. .PP
  143. Normally, \f[B]opio\f[R] will access the GPIO pins through the Linux
  144. gpio device driver, and the corresponding files at
  145. \f[C]/sys/class/gpio\f[R].
  146. This is \f[I]high level\f[R] access.
  147. .PP
  148. If you wish to bypass the Linux gpio driver, add the \f[C]-d\f[R] option
  149. to the \f[B]opio\f[R] command line and the reads/writes will be done at
  150. a \f[I]low level\f[R], directly on the machine\[cq]s registers.
  151. .PP
  152. The commands \f[B]readall, readallx\f[R] and \f[B]leds\f[R] are always
  153. done using \f[I]low level\f[R] access.
  154. The \f[B]exports\f[R] command is always done with \f[I]high level\f[R]
  155. commands.
  156. .PP
  157. Be careful about making changed with the \f[B]-d\f[R] option.
  158. Some linux gpio drivers will direction and value, so changes you make
  159. with the \f[B]-d\f[R] option may not be reflected in the export folder.
  160. .SH EXAMPLES
  161. .PP
  162. display a chart of the pin assignments of the 40 pin connector:
  163. .IP
  164. .nf
  165. \f[C]
  166. opio readall
  167. \f[R]
  168. .fi
  169. .PP
  170. list the currently `exported' pins:
  171. .IP
  172. .nf
  173. \f[C]
  174. opio exports
  175. \f[R]
  176. .fi
  177. .PP
  178. set gpio 15 to an output; also create an export for gpio15 \&...then
  179. flash the pin (gpio15 Linux number):
  180. .IP
  181. .nf
  182. \f[C]
  183. opio mode 15 out
  184. opio write 15 on
  185. sleep 2
  186. opio write 15 off
  187. \f[R]
  188. .fi
  189. .PP
  190. set gpio 15 to an output; do \f[I]not\f[R] create an export
  191. .IP
  192. .nf
  193. \f[C]
  194. opio -d mode 15 out
  195. \f[R]
  196. .fi
  197. .PP
  198. write to gpio15 pin, bypassing the export mechanism
  199. .IP
  200. .nf
  201. \f[C]
  202. opio -d write 15 on
  203. \f[R]
  204. .fi
  205. .PP
  206. \f[B]NOTE\f[R] The more recent /dev/gpio driver is not yet available on
  207. these boards, since they\[cq]re running the 3.xx kernels.
  208. .PP
  209. \f[B]NOTE\f[R] The 2G-IOT board uses the I2C1 bus to communicate with
  210. the modem chip.
  211. This is i2c-0 in the kernel, and is pins 3 & 5 on the 40 pin connector.
  212. Do not use these pins to connect to peripherals.
  213. And do not use \f[B]opio\f[R] to modify the \f[I]mode\f[R] of these
  214. pins.
  215. .PP
  216. \f[B]NOTE\f[R] The 2G-IOT board uses the I2C3 bus to communicate with
  217. the LCD.
  218. If you are using an LCD in the socket, do \f[I]not\f[R] change the mode
  219. on pins 38 & 40.
  220. .SH AUTHORS
  221. Pat Beirne <patb@pbeirne.com>.