• 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;
         }

         

      }

    }

  • 相关阅读:
    schema约束和引入
    第一天
    github pages搭建网站(三)
    git安装和使用(二)
    使用github(一)
    命名实体识别总结
    约瑟夫环
    标准化和归一化
    cumsum累计函数系列:pd.cumsum()、pd.cumprod()、pd.cummax()、pd.cummin()
    pandas处理时间序列(4): 移动窗口函数
  • 原文地址:https://www.cnblogs.com/zym0805/p/5006546.html
Copyright © 2020-2023  润新知