Linux Gpio Learning __linux

Source: Internet
Author: User
previously

Based on Linux Gpio will be in the/sys/class/gpio directory will generate export, Unexport file, of course, there are gpiochipx files, GPIOCHIPX is the management of the pin, such as a certain chip may control a number of pins, in the corresponding The Ngpio in the directory is the number of controls.
When the Echo 4 >/sys/class/gpio/export is executed, the Gpio4 directory will be generated in the/sys/class/gpio directory, which will be like value, edge, direction and other related files.valueis the current value,Edgeis the PIN trigger,directionis the pin input, output mode. But how does echo produce this?Process Scanningfunction Gpiolib_dev_init is exported as Core_initcall (GPIO/GPIOLIB.C) in the initial initialization process This function calls Bus_register registration GPIO, corresponding to the build/sys/bus/gpio directory to call Alloc_chrdev_region gpiochip Settings Gpiochip_setup_devs This will process the total number of gpiochip, for each call Gpiochip_sysfs_register, file to the GPIOLIB-SYSFS.C call Device_create_wtih_groups to create gpiochip%d the corresponding parameter for this function is gpio_class that is, a class class the name of this class definition is Gpio, and defines theattr attrincluding Export-export _store, Unexport-unexport_store the former is the property name, the latter is the function is the echo action to trigger the Export_store function call Gpio_request prepare PIN Then call Gpiod_export to call device_create_with_groups in this function to create gpio%d, and other thingsNotesOf course, there are a lot of details are not clear, but an overview, later to supplement

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.