查看: 929|回复: 0

【HiKey】HiKey Debain 系统下 96BoardGPIO项目测试

[复制链接]

该用户从未签到

发表于 2016-11-14 09:19:03 | 显示全部楼层 |阅读模式
分享到:
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)
回复

使用道具 举报

您需要登录后才可以回帖 注册/登录

本版积分规则

关闭

站长推荐上一条 /2 下一条

手机版|小黑屋|与非网

GMT+8, 2024-4-25 18:31 , Processed in 0.132112 second(s), 18 queries , MemCache On.

ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

苏公网安备 32059002001037号

Powered by Discuz! X3.4

Copyright © 2001-2024, Tencent Cloud.