zoukankan      html  css  js  c++  java
  • sama5 kio接口控制

    //example 
    #include <stdio.h>
    #include <stdlib.h>
    #include <unistd.h>
    #include <string.h>

    #define TX1_LED     160 //

    #define RX1_LED     161//

    int main(int argc, char * argv)
    {
            int i, n, fd;
            char num,val;
            int ret;
            fd = open("/dev/kio", O_RDWR);                //打开设备
            if (fd < 0)
            {
                printf("can't open /dev/kio! ");
                exit(1);
            }
            sleep(1);
            ioctl(fd, 1, TX1_LED);                //设置GPIO160输出 TX1_LED

        ioctl(fd, 1, RX1_LED);                //设置GPIO161输出 RX1_LED
           
            while (1) 
            {
                    num = 1;
                    ret = write(fd,"1",TX1_LED); //置高
                    if(ret < 0)
                    {
                            perror("write");
                            return -1;
                    }
                    sleep(1);
                    ret = write(fd,"0",TX1_LED);//置低
                    if(ret < 0)
                    {
                        perror("write");
                        return -1;
         }

         ret = write(fd,"1",RX1_LED); //置高
                    if(ret < 0)
                    {
                            perror("write");
                            return -1;
                    }
                    sleep(1);
                    ret = write(fd,"0",RX1_LED);//置低
                    if(ret < 0)
                    {
                        perror("write");
                        return -1;
         }

         

      }

    }

  • 相关阅读:
    [转载]c++转python
    [转载]One-hot编码
    [转载]各种机器学习算法的应用场景
    SVC和SVR
    机器学习-正则化+回归与分类辨析
    C#编译时,提示缺少NuGet包
    C++中 左值和右值的区别
    C++11并发编程实战 免费书籍
    静态库和动态库
    C++中string类
  • 原文地址:https://www.cnblogs.com/zym0805/p/5006546.html
Copyright © 2011-2022 走看看