乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      GPIO User Space App

       WUCANADA 2015-08-28
      The following user space application was used to test the GPIO using the sysfs interface.

      #include <stdio.h>
      #include <stdlib.h>
      #include <fcntl.h>
       
       
      // The specific GPIO being used must be setup and replaced thru
      // this code.  The GPIO of 240 is in the path of most the sys dirs
      // and in the export write.
      //
      // Figuring out the exact GPIO was not totally obvious when there
      // were multiple GPIOs in the system. One way to do is to go into
      // the gpiochips in /sys/class/gpio and view the label as it should
      // reflect the address of the GPIO in the system. The name of the
      // the chip appears to be the 1st GPIO of the controller.
      //
      // The export causes the gpio240 dir to appear in /sys/class/gpio.
      // Then the direction and value can be changed by writing to them.
       
      // The performance of this is pretty good, using a nfs mount,
      // running on open source linux, on the ML507 reference system,
      // the GPIO can be toggled about every 4 usec.
       
      // The following commands from the console setup the GPIO to be
      // exported, set the direction of it to an output and write a 1
      // to the GPIO.
      //
      // bash> echo 240 > /sys/class/gpio/export
      // bash> echo out > /sys/class/gpio/gpio240/direction
      // bash> echo 1 > /sys/class/gpio/gpio240/value
       
      // if sysfs is not mounted on your system, the you need to mount it
      // bash> mount -t sysfs sysfs /sys
       
      // the following bash script to toggle the gpio is also handy for
      // testing
      //
      // while [ 1 ]; do
      //  echo 1 > /sys/class/gpio/gpio240/value
      //  echo 0 > /sys/class/gpio/gpio240/value
      // done
       
      // to compile this, use the following command
      // gcc gpio.c -o gpio
       
      // The kernel needs the following configuration to make this work.
      //
      // CONFIG_GPIO_SYSFS=y
      // CONFIG_SYSFS=y
      // CONFIG_EXPERIMENTAL=y
      // CONFIG_GPIO_XILINX=y
       
      int main()
      {
          int valuefd, exportfd, directionfd;
       
          printf("GPIO test running...\n");
       
          // The GPIO has to be exported to be able to see it
          // in sysfs
       
          exportfd = open("/sys/class/gpio/export", O_WRONLY);
          if (exportfd < 0)
          {
              printf("Cannot open GPIO to export it\n");
              exit(1);
          }
       
          write(exportfd, "240", 4);
          close(exportfd);
       
          printf("GPIO exported successfully\n");
       
          // Update the direction of the GPIO to be an output
       
          directionfd = open("/sys/class/gpio/gpio240/direction", O_RDWR);
          if (directionfd < 0)
          {
              printf("Cannot open GPIO direction it\n");
              exit(1);
          }
       
          write(directionfd, "out", 4);
          close(directionfd);
       
          printf("GPIO direction set as output successfully\n");
       
          // Get the GPIO value ready to be toggled
       
          valuefd = open("/sys/class/gpio/gpio240/value", O_RDWR);
          if (valuefd < 0)
          {
              printf("Cannot open GPIO value\n");
              exit(1);
          }
       
          printf("GPIO value opened, now toggling...\n");
       
          // toggle the GPIO as fast a possible forever, a control c is needed
          // to stop it
       
          while (1)
          {
              write(valuefd,"1", 2);
              write(valuefd,"0", 2);
          }
      }


        本站是提供個(gè)人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多