快速瀏覽

WiringPi 和 Python 包裝器


 
  • 舊版master分支已重命名為master-old分支。如果你在新的 master 分支上遇到問題,請用舊的再試一次。

最初的WiringPi是一個基於 PIN 的 GPIO 訪問庫,用 C 語言編寫,用於 Raspberry Pi 中使用的 BCM2835。它是在 GNU LGPLv3 許可下發布的,可用於 C、C++ 和 RTB (BASIC) 以及許多其他帶有合適包裝器的語言(見下文)它的設計目的是讓使用過 Arduino“接線”系統的人熟悉[1] ]。Hardkernel 為從原始WiringPi分叉的 ODROID 板提供WiringPi庫。

您可以使用我們的 Ubuntu PPA安裝我們的WiringPi。您可以使用apt命令將其保持為最新版本。或者,克隆我們的 Github 存儲庫並自己構建它。

運行gpio readall以檢查所有擴展 GPIO 引腳。這是 ODROID-N2 的默認設置。

root@odroid:~# gpio readall
 +-----+-----+---------+------+---+--- N2 ---+---+------+---------+-----+-----+
 | I/O | wPi |   Name  | Mode | V | Physical | V | Mode |  Name   | wPi | I/O |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3V |      |   |  1 || 2  |   |      | 5V      |     |     |
 | 493 |   8 |   SDA.2 | ALT1 | 1 |  3 || 4  |   |      | 5V      |     |     |
 | 494 |   9 |   SCL.2 | ALT1 | 1 |  5 || 6  |   |      | 0V      |     |     |
 | 473 |   7 |  IO.473 | ALT1 | 0 |  7 || 8  | 1 | ALT1 | TxD1    | 15  | 488 |
 |     |     |      0V |      |   |  9 || 10 | 1 | ALT1 | RxD1    | 16  | 489 |
 | 479 |   0 |  IO.479 |   IN | 1 | 11 || 12 | 1 | IN   | IO.492  | 1   | 492 |
 | 480 |   2 |  IO.480 |   IN | 1 | 13 || 14 |   |      | 0V      |     |     |
 | 483 |   3 |  IO.483 | ALT2 | 1 | 15 || 16 | 1 | IN   | IO.476  | 4   | 476 |
 |     |     |    3.3V |      |   | 17 || 18 | 1 | IN   | IO.477  | 5   | 477 |
 | 484 |  12 |    MOSI |   IN | 1 | 19 || 20 |   |      | 0V      |     |     |
 | 485 |  13 |    MISO |   IN | 1 | 21 || 22 | 1 | IN   | IO.478  | 6   | 478 |
 | 487 |  14 |    SCLK |   IN | 1 | 23 || 24 | 1 | IN   | CE0     | 10  | 486 |
 |     |     |      0V |      |   | 25 || 26 | 0 | IN   | IO.464  | 11  | 464 |
 | 474 |  30 |   SDA.3 | ALT2 | 1 | 27 || 28 | 1 | ALT2 | SCL.3   | 31  | 475 |
 | 490 |  21 |  IO.490 | ALT1 | 1 | 29 || 30 |   |      | 0V      |     |     |
 | 491 |  22 |  IO.491 | ALT1 | 1 | 31 || 32 | 0 | IN   | IO.472  | 26  | 472 |
 | 481 |  23 |  IO.481 |   IN | 1 | 33 || 34 |   |      | 0V      |     |     |
 | 482 |  24 |  IO.482 | ALT2 | 1 | 35 || 36 | 0 | IN   | IO.495  | 27  | 495 |
 |     |  25 |   AIN.3 |      |   | 37 || 38 |   |      | 1V8     | 28  |     |
 |     |     |      0V |      |   | 39 || 40 |   |      | AIN.2   | 29  |     |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | I/O | wPi |   Name  | Mode | V | Physical | V | Mode |  Name   | wPi | I/O |
 +-----+-----+---------+------+---+--- N2 ---+---+------+---------+-----+-----+
root@odroid:~# gpio readall -a
 +------+-----+----------+------+---+----+---- Model  ODROID-N2 ----+----+---+------+----------+-----+------+
 | GPIO | wPi |   Name   | Mode | V | DS | PU/PD | Physical | PU/PD | DS | V | Mode |   Name   | wPi | GPIO |
 +------+-----+----------+------+---+----+-------+----++----+-------+----+---+------+----------+-----+------+
 |      |     |     3.3V |      |   |    |       |  1 || 2  |       |    |   |      | 5V       |     |      |
 |  493 |   8 |    SDA.2 | ALT1 | 1 |  2 |   P/U |  3 || 4  |       |    |   |      | 5V       |     |      |
 |  494 |   9 |    SCL.2 | ALT1 | 1 |  2 |   P/U |  5 || 6  |       |    |   |      | GND(0V)  |     |      |
 |  473 |   7 | GPIO.473 | ALT1 | 0 |  1 |   P/D |  7 || 8  | P/U   | 1  | 1 | ALT1 | TxD1     | 15  | 488  |
 |      |     |  GND(0V) |      |   |    |       |  9 || 10 | P/U   | 1  | 1 | ALT1 | RxD1     | 16  | 489  |
 |  479 |   0 | GPIO.479 |   IN | 1 |  2 |   P/U | 11 || 12 | P/U   | 1  | 1 | IN   | GPIO.492 | 1   | 492  |
 |  480 |   2 | GPIO.480 |   IN | 1 |  2 |   P/U | 13 || 14 |       |    |   |      | GND(0V)  |     |      |
 |  483 |   3 | GPIO.483 | ALT2 | 1 |  1 |   P/U | 15 || 16 | P/U   | 2  | 1 | IN   | GPIO.476 | 4   | 476  |
 |      |     |     3.3V |      |   |    |       | 17 || 18 | P/U   | 2  | 1 | IN   | GPIO.477 | 5   | 477  |
 |  484 |  12 |     MOSI |   IN | 1 |  1 |   P/U | 19 || 20 |       |    |   |      | GND(0V)  |     |      |
 |  485 |  13 |     MISO |   IN | 1 |  1 |   P/U | 21 || 22 | P/U   | 2  | 1 | IN   | GPIO.478 | 6   | 478  |
 |  487 |  14 |     SCLK |   IN | 1 |  2 |   P/U | 23 || 24 | P/U   | 1  | 1 | IN   | CE0      | 10  | 486  |
 |      |     |  GND(0V) |      |   |    |       | 25 || 26 | P/D   | 1  | 0 | IN   | GPIO.464 | 11  | 464  |
 |  474 |  30 |    SDA.3 | ALT2 | 1 |  3 |   P/U | 27 || 28 | P/U   | 3  | 1 | ALT2 | SCL.3    | 31  | 475  |
 |  490 |  21 | GPIO.490 | ALT1 | 1 |  1 |   P/U | 29 || 30 |       |    |   |      | GND(0V)  |     |      |
 |  491 |  22 | GPIO.491 | ALT1 | 1 |  1 |   P/U | 31 || 32 | P/D   | 2  | 0 | IN   | GPIO.472 | 26  | 472  |
 |  481 |  23 | GPIO.481 |   IN | 1 |  2 |   P/U | 33 || 34 |       |    |   |      | GND(0V)  |     |      |
 |  482 |  24 | GPIO.482 | ALT2 | 1 |  1 |   P/D | 35 || 36 | DSBLD | 1  | 0 | IN   | GPIO.495 | 27  | 495  |
 |      |  25 |    AIN.3 |      |   |    |       | 37 || 38 |       |    |   |      | 1V8      | 28  |      |
 |      |     |  GND(0V) |      |   |    |       | 39 || 40 |       |    |   |      | AIN.2    | 29  |      |
 +------+-----+----------+------+---+----+-------+----++----+-------+----+---+------+----------+-----+------+
 | GPIO | wPi |   Name   | Mode | V | DS | PU/PD | Physical | PU/PD | DS | V | Mode |   Name   | wPi | GPIO |
 +------+-----+----------+------+---+----+---- Model  ODROID-N2 ----+----+---+------+----------+-----+------+

Hardkernel 還為 Python 程序員提供WiringPi Python binder,稱為WiringPi -Python。WiringPi -python是Hardkernel的Python的包裹版本WiringPi


LED 開/關

您可以使用WiringPi打開/關閉連接的 LED 。
此示例使用物理引腳 #11WiringPi上的 #0 )和接地引腳。

串行環回

一個簡單的串行環回示例。
此示例使用物理引腳 #8、#10WiringPi上的 #15、#16 )。
兩個引腳直接相互連接

    • ODROID-C4 設備文件名/dev/ttyS1

快速瀏覽

ODROID-C4

四核ARM CORTEX-A55 |4GB RAM |4 USB3 PORTS