bpi m3 在gpio上終於解掉了。確定可以執行了。
安裝gpio
參考此篇文章:http://forum.banana-pi.org/t/how-to-banana-pi-bpi-m3-install-bpi-wiringpi/1056
使用git下載檔案
git clone https://github.com/BPI-SINOVOIP/BPI-WiringPi.git -b BPI_M3
安裝
cd BPI-WiringPi
chmod +x ./build
sudo ./build
做到這裡,個人遇到出現許多error,看了許多文章,仍未找到答案。
使用gpio -v 看到的都是不認識硬體的錯誤訊息
看到了INSTALL後,應該是少了一個動作。
vim /etc/ld.so.conf
在第一行加入路徑
/usr/local/lib
再重新編譯,這時就成功了。
使用gpio -v 可以得到
gpio version: 2.26
Copyright (c) 2012-2015 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty
Banana Pi Details:
Type: Model BM, Revision: 1.2, Memory: 2048MB, Maker: BPI
執行gpio readall可以看到gpio全部設定
+-----+-----+---------+------+---+---Pi ---+---+------+---------+-----+-----+
| CPU | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | CPU |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| | | 3.3v | | | 1 || 2 | | | 5v | | |
| 229 | 8 | SDA.1 | ALT5 | 0 | 3 || 4 | | | 5V | | |
| 228 | 9 | SCL.1 | ALT5 | 0 | 5 || 6 | | | GND | | |
| 362 | 7 | GCLK | ALT5 | 0 | 7 || 8 | 0 | ALT5 | TxD0 | 15 | 32 |
| | | GND | | | 9 || 10 | 0 | ALT5 | RxD0 | 16 | 33 |
| 68 | 0 | GEN0 | OUT | 0 | 11 || 12 | 0 | ALT5 | GEN1 | 1 | 35 |
| 71 | 2 | GEN2 | OUT | 1 | 13 || 14 | | | GND | | |
| 81 | 3 | GEN3 | OUT | 1 | 15 || 16 | 0 | ALT5 | GEN4 | 4 | 34 |
| | | 3.3v | | | 17 || 18 | 0 | ALT3 | GEN5 | 5 | 360 |
| 64 | 12 | MOSI | ALT4 | 0 | 19 || 20 | | | GND | | |
| 65 | 13 | MISO | ALT4 | 0 | 21 || 22 | 0 | OUT | GEN6 | 6 | 361 |
| 66 | 14 | SCLK | ALT4 | 0 | 23 || 24 | 0 | ALT4 | CE0 | 10 | 67 |
| | | GND | | | 25 || 26 | 0 | ALT3 | CE1 | 11 | 234 |
| 227 | 30 | SDA.0 | ALT5 | 0 | 27 || 28 | 0 | ALT5 | SCL.0 | 31 | 226 |
| 82 | 21 | GPIO.21 | ALT3 | 0 | 29 || 30 | | | GND | | |
| 202 | 22 | GPIO.22 | ALT3 | 0 | 31 || 32 | 0 | ALT3 | GPIO.26 | 26 | 205 |
| 203 | 23 | GPIO.23 | ALT3 | 0 | 33 || 34 | | | GND | | |
| 204 | 24 | GPIO.24 | OUT | 1 | 35 || 36 | 0 | ALT3 | GPIO.27 | 27 | 133 |
| 132 | 25 | GPIO.25 | OUT | 0 | 37 || 38 | 0 | OUT | GPIO.28 | 28 | 146 |
| | | GND | | | 39 || 40 | 0 | OUT | GPIO.29 | 29 | 147 |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| CPU | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | CPU |
+-----+-----+---------+------+---+---Pi ---+---+------+---------+-----+-----+
這個結果和網站
https://bananapi.gitbooks.io/bpi-m3/content/bpi-m3_gpio_pin_define.html
上的圖有所不同。尤其是gpio的腳位。
測試:我用的是第37根針gpio.25,黑色是地線。
編輯一個檔案:blink.c
內容如下:
#include <wiringPi.h>
int main(void)
{
wiringPiSetup() ;
pinMode (25, OUTPUT) ;
for(;;)
{
digitalWrite(25, HIGH) ; delay (500) ;
digitalWrite(25, LOW) ; delay (500) ;
}
}
編譯:
gcc -Wall -o blink blink.c -lwiringPi
測試
sudo ./blink
這樣可以看到LED燈閃爍。
沒有留言:
張貼留言