Linux Quick-Action IO port

Source: Internet
Author: User

The operation of Gpio in an embedded device is the most basic operation. The general practice is to write a separate driver, and most of the examples on the web are like this. In fact, there is a generic Gpio operating interface under Linux, that is, I want to introduce the "/sys/class/gpio" way.

First, see if there is a "/sys/class/gpio" folder in the system. If not, please add Device drivers-> GPIO support->/sys/class/gpio/When compiling the kernel ... (Sysfs interface).

The test is as follows:

1, obtain the GPIO information, and in the terminal, typed the following command:

[[email protected" GPIO]#  CD/ sys/ class /gpio


If you want to operate GPIOD19, first you know that your chip discipline is 0-31 sort. So GPIOD0 is 3*32=96,gpiod19=96+19=115

2, enter the following command

[[email protected] gpio]# echo > Export  


Now we have the IO we want to manipulate


3, test

If we want to use this discipline to control the LEDs, then we need to set it to output


is set to high or low level.


Or



View the pin level


Operation Successful!

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Linux Quick-Action IO port

Related Article

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.