In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
What this article shares to you is about how to use the GPIO driver. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
GPIO Control Operation of CB
The operating system used on the board is the official standard system version 1.1 of Linaro's official img, which already comes with the gpio driver file.
1. The official driver is gpio-sunxi.ko, located at / lib/modules/3.0.62/kernel/drivers/gpio/gpio-sunxi.ko.
two。 Because the driver module is not loaded after the system is started, users need to insert it by themselves and use the insmod command. After that, lsmod can see gpio-sunxi.
Of course, you can also edit / etc/modules and add gpio-sunxi.ko to it. Lsmod checks to see if it has been loaded after restart.
3. After the driver is loaded, you can operate the GPIO port.
For the operation of GPIO port, you need to have the following three steps:
1)。 You need to indicate the port number on which you need to operate.
Echo 4 > / sys/class/gpio/export
Ls / sys/class/gpio
The port folder gpio4-pe4 we need will appear.
If echo 1 > / sys/class/gpio/export seems to appear gpio1-pe1.
2) Open gpio4-pe4, or ls gpio4-pe4, and you can see the files in gpio4-pe4. There are two files related to our operations:
Direction and value, respectively, can be seen to represent the direction of the port and the value of the port.
For direction, you can write echo out > / sys/class/gpio/gpio4-pe4/direction to set the port as the output. If it is not set, there is no response to write data.
3) Port setting or zeroing.
Complete the port setting or zeroing by writing 1 or 0 to the value file.
Echo 1 > / sys/class/gpio/gpio4-pe4/value; set 1.
The selection, setting, and use of GPIO ports can be completed through the above three steps.
However, problems and solutions are found in use:
1 gpio-sunxi.ko driver will not be automatically loaded by the system, after each boot need to load their own, more troublesome.
Solution: edit / etc/modules to add gpio driver module. After each restart, the system automatically loads the GPIO module.
two。 It is necessary to reset the GPIO port and configure the port direction after each system restart.
Solution: edit / etc/rc.local, add before exit
Echo 1 > / sys/class/gpio/export
Echo out > / sys/class/gpio/gpio4-pe4/direction
Complete the selection and port setting of the GPIP port.
3. Chmod permission is required for the operation of / sys. Chmod-R 777 / sys.
This also requires editing / etc/rc.local.
In addition, this time I use CB to achieve the function is similar to the ttl smart door lock, I use my phone to control the lights.
The basic architecture is also accomplished by using LNMP as a server and using PHP language to read and write / sys/class/gpio/gpio4-pe4/value.
What should be noted here is the website directory setting of the nginx server. The previous setting of / etc/nginx/www/ cannot complete the alignment of / sys/.. The operation of.
Later, I modified the site directory and set it directly to /, and the operation of the / sys file can be completed.
The above is how to use the GPIO driver, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.