|
1. 安装必要工具
apt-get install autoconf automake libtool
2. 安装libsoc
2.1 下载代码
git clone https://github.com/jackmitch/libsoc.git
2.2 配置生成configure脚本
cd libsoc
autoreconf -i
2.3 配置libsoc库
./configure --enable-board=hikey
2.4 编译安装
make && make install
3. 编译安装96BoardGPIO
3.1 下载代码
git clone https://github.com/96boards/96BoardsGPIO.git
3.2 配置
cd 96BoardsGPIO
./autogen.sh && ./configure
3.3 编译安装
make && make install
ldconfig
4. 测试
4.1 C程序测试
cd examples
修该代码bink.c把for循环改成无限循环便于测试
make
./blink &
blink程序不断改变gpio488的值
用下面的脚本查看该GPIO的值
while true; do cat /sys/class/gpio/gpio488/value ; done
4.2 python程序测试
同样把python的代码改成无限循环
./blink.py &
用下面的脚本查看该GPIO的值
while true; do cat /sys/class/gpio/gpio488/value ; done
附件:修改后的代码
blink.c:
#include <stdio.h>/* 96BoardsGPIO header file */#include <gpio.h>/* Just make the pin numbers easier to remember */int main(int argc, char * argv[]){ int x; unsigned int gpio_a = gpio_id("GPIO_A"); /* * GPIO_A can also be looked up with: * gpio_a = gpio_by_letter('A'); * gpio_a = gpio_by_pin(23); */ // Open the GPIO for use. Do so by pin number on the // Low Speed Expansion Connector. if (!gpio_open(gpio_a, "out")) { for (;;) { digitalWrite(gpio_a, HIGH); usleep(500000); digitalWrite(gpio_a, LOW); usleep(500000); } } else { fprintf(stderr, "Unable to open GPIO_A\n"); return -1; } return 0;}blink.py
#!/usr/bin/python [5/1864]import timefrom gpio_96boards import GPIOGPIO_A = GPIO.gpio_id('GPIO_A')pins = ( (GPIO_A, 'out'),)def blink(gpio): while True: gpio.digital_write(GPIO_A, GPIO.HIGH) time.sleep(1) gpio.digital_write(GPIO_A, GPIO.LOW) time.sleep(1)if __name__ == '__main__': import argparse parser = argparse.ArgumentParser( description='Blink LED on GPIO A (pin 23)') args = parser.parse_args() with GPIO(pins) as gpio: blink(gpio) |
|