{"id":1931,"date":"2015-12-15T22:56:19","date_gmt":"2015-12-15T13:56:19","guid":{"rendered":"https:\/\/hack.gpl.jp\/?p=1931"},"modified":"2015-12-15T22:56:19","modified_gmt":"2015-12-15T13:56:19","slug":"post-1931","status":"publish","type":"post","link":"https:\/\/hack.gpl.jp\/2015\/12\/15\/post-1931.html","title":{"rendered":"OPI\u3067L\u30c1\u30ab GPIO\u3092C \u3067"},"content":{"rendered":"

\u524d\u56de\u3001RasPi2 \u3067WiringPi\u3092\u4f7f\u3063\u3066GPIO \u306e\u5236\u5fa1\u3092\u3057\u307e\u3057\u305f\u3002<\/p>\n

\n

RasPi2 \u3067C\u306e\u738b\u9053\uff1f WiringPi<\/a><\/p>\n<\/blockquote>\n

OrangePi \u3067\u3082\u540c\u69d8\u306b\u7121\u3044\u304b\u63a2\u3057\u305f\u3068\u3053\u308d\u3001Fork\u3057\u305f\u3082\u306e\u304c\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n

\n

WiringOP
https:\/\/github.com\/zhaolei\/WiringOP<\/a><\/p>\n<\/blockquote>\n

\u30b5\u30f3\u30d7\u30eb\u30bd\u30fc\u30b9<\/p>\n

#include <wiringPi.h>\n\n#define LED 16\n#define MSEC 50\n\nint main (void)\n{\n  wiringPiSetup () ;\n  pinMode (LED, OUTPUT) ;\n  for (;;)\n  {\n    digitalWrite (LED, HIGH) ; delay (MSEC) ;\n    digitalWrite (LED,  LOW) ; delay (MSEC) ;\n  }\n  return 0 ;\n}<\/pre>\n

\"GPIO\" <\/p>\n

\u30d3\u30eb\u30c9\u65b9\u6cd5\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u307e\u3057\u305f\u3002<\/p>\n

\n

# gcc -o blink blink.c -lwiringPi -lpthread<\/p>\n<\/blockquote>\n

\u30d4\u30f3\u306e\u6307\u5b9a\u304c\u3001\u4ee5\u4e0b\u3067\u51fa\u3066\u304f\u308b wPi \u306e\u756a\u53f7\u306e\u3088\u3046\u3067\u3057\u305f\u3002<\/p>\n

root@opi:~# gpio readall\n +-----+-----+----------+------+---+--OrangePiPC--+---+------+---------+-----+--+\n | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |\n +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+\n |     |     |     3.3v |      |   |  1 || 2  |   |      | 5v       |     |     |\n |   2 |  -1 |    SDA.0 |      |   |  3 || 4  |   |      | 5V       |     |     |\n |   3 |  -1 |    SCL.0 |      |   |  5 || 6  |   |      | 0v       |     |     |\n |   4 |   6 | IO6 PA06 |  OUT | 0 |  7 || 8  |   |      | TxD3     |     |     |\n |     |     |       0v |      |   |  9 || 10 |   |      | RxD3     |     |     |\n |  17 |  -1 |     RxD2 |      |   | 11 || 12 | 0 | OUT  | IO1 PD14 | 1   | 18  |\n |  27 |  -1 |     TxD2 |      |   | 13 || 14 |   |      | 0v       |     |     |\n |  22 |  -1 |     CTS2 |      |   | 15 || 16 | 0 | OUT  | IO4 PC04 | 4   | 23  |\n |     |     |     3.3v |      |   | 17 || 18 | 0 | OUT  | IO5 PC07 | 5   | 24  |\n |  10 |  -1 |     MOSI |      |   | 19 || 20 |   |      | 0v       |     |     |\n |   9 |  -1 |     MISO |      |   | 21 || 22 |   |      | RTS2     |     |     |\n |  11 |  -1 |     SCLK |      |   | 23 || 24 |   |      | SPI-CE0  |     |     |\n |     |     |       0v |      |   | 25 || 26 |   |      | CE1      |     |     |\n |   0 |  -1 |    SDA.1 |      |   | 27 || 28 |   |      | SCL.1    |     |     |\n |   5 |   7 |  IO7 PA7 |  OUT | 0 | 29 || 30 |   |      | 0v       |     |     |\n |   6 |   8 |  IO8 PA8 |  OUT | 0 | 31 || 32 | 0 | OUT  | IO9 PG08 | 9   | 12  |\n |  13 |  10 | IO10 PA9 |  OUT | 0 | 33 || 34 |   |      | 0v       |     |     |\n |  19 |  12 | IO12PA10 |  OUT | 0 | 35 || 36 | 0 | OUT  | IO13PG09 | 13  | 16  |\n |  26 |  14 | IO14PA20 | ALT3 | 0 | 37 || 38 | 0 | OUT  | IO15PG06 | 15  | 20  |\n |     |     |       0v |      |   | 39 || 40 | 1 | OUT  | IO16PG07 | 16  | 21  |\n +-----+-----+----------+------+---+----++----+---+------+----------+-----+-----+\n | BCM | wPi |   Name   | Mode | V | Physical | V | Mode | Name     | wPi | BCM |\n +-----+-----+----------+------+---+--OrangePIPC--+------+----------+-----+-----+<\/pre>\n

\u3068\u308a\u3042\u3048\u305a\u52d5\u304d\u307e\u3057\u305f\u3002\u95a2\u6570\u306e\u6271\u3044\u304c\u3061\u3087\u3063\u3068\uff1f\u306a\u90e8\u5206\u3082\u3042\u308a\u3001\u5b8c\u5168\u306b\u4e92\u63db\u30bd\u30fc\u30b9\u3067\u52d5\u304f\u3068\u3044\u3046\u308f\u3051\u3058\u3083\u306a\u3055\u305d\u3046\u3067\u3059\u3002<\/p>\n

root@opi:~# ls \/sys\/class\/gpio_sw\/\nnormal_led  PA10  PA13  PA14  PA15  PA21  PA3  PA6  PA7  PA8  PA9  PC3  PC4  PC7  PD14  PG6  PG7  PG8  PG9  PL10  standby_led\nroot@opi:~# lsmod\nModule                  Size  Used by\ngpio_sunxi              8233  0 \n8189es                901572  0 \nroot@opi:~# modprobe gpio_sunxi\nroot@opi:~# modprobe gpio-sunxi\nroot@opi:~# modprobe gpio\nmodprobe: FATAL: Module gpio not found.\nroot@opi:~# echo 1 > \/sys\/class\/gpio_sw\/standby_led\/data\nroot@opi:~# echo 0 > \/sys\/class\/gpio_sw\/standby_led\/data\nroot@opi:~# gpio -g write 16 1\npin number error\nroot@opi:~# gpio -g write 21 1\npin number error\nroot@opi:~# gpio -g write IO16PG07 1\npin number error\nroot@opi:~# gpio -g write PG7 1\npin number error\nroot@opi:~# gpio -g write 0 1\npin number error\nroot@opi:~# <\/pre>\n

\u3082\u3046\u5c11\u3057\u3001\u624b\u5165\u308c\u304c\u5fc5\u8981\u3067\u3059\u306d\u3002sysfs \u306b\u76f4\u63a5\u66f8\u304f\u3068\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u5149\u308a\u307e\u3059\u3002gpio \u306e\u30de\u30c3\u30d4\u30f3\u30b0\u304c\u3046\u307e\u304f\u6a5f\u80fd\u3057\u3066\u3044\u306a\u3044\u3088\u3046\u3067\u3059\u306d\u3002<\/p>\n

\"gpio_stanby_led\"<\/p>\n","protected":false},"excerpt":{"rendered":"

\u524d\u56de\u3001RasPi2 \u3067WiringPi\u3092\u4f7f\u3063\u3066GPIO \u306e\u5236\u5fa1\u3092\u3057\u307e\u3057\u305f\u3002 RasPi2 \u3067C\u306e\u738b\u9053\uff1f WiringPi OrangePi \u3067\u3082\u540c\u69d8\u306b\u7121\u3044\u304b\u63a2\u3057\u305f\u3068\u3053\u308d\u3001Fork\u3057\u305f\u3082\u306e\u304c\u3042\u308a\u307e\u3057\u305f\u3002 WiringOP […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_uag_custom_page_level_css":"","footnotes":""},"categories":[6,57,60],"tags":[],"acf":[],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false,"post-thumbnail":false},"uagb_author_info":{"display_name":"JunkHack","author_link":"https:\/\/hack.gpl.jp\/author\/junkhack\/"},"uagb_comment_info":0,"uagb_excerpt":"\u524d\u56de\u3001RasPi2 \u3067WiringPi\u3092\u4f7f\u3063\u3066GPIO \u306e\u5236\u5fa1\u3092\u3057\u307e\u3057\u305f\u3002 RasPi2 \u3067C\u306e\u738b\u9053\uff1f Wir…","_links":{"self":[{"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/posts\/1931"}],"collection":[{"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/comments?post=1931"}],"version-history":[{"count":0,"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/posts\/1931\/revisions"}],"wp:attachment":[{"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/media?parent=1931"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/categories?post=1931"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hack.gpl.jp\/wp-json\/wp\/v2\/tags?post=1931"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}