Bit by bit analysis Linkit™smart 7688 button operation

Source: Internet
Author: User
using the ProCD and Gpio-button-hotplug sampling buttons

There are many ways to do a button operation in OpenWrt. I think one method is easier. Reference 1.3. The method is controlled by the Gpio-button-hotplug (openwrt/package/kernel/gpio-button-hotplug) module.

Specific steps: Modify the Target/linux/ramips/dts/linkit7688.dts. Configure the relevant buttons as gpio-button-hotplug approved buttons. Compile the system reference Https://wiki.openwrt.org/doc/howto/hardware.button?s[]=button&s[]=hotplug document for operation.
So easy. If you use the ProCD method

You need to create a script to the/etc/rc.button/directory. Each script corresponds to the specified button. If you use Gpio-button-hotplug, you need to create a script to/etc/hotplug.d/button/00-button that handles the button information. Refer to OpenWrt website information.

root@mylinkit:/# Cat/sys/kernel/debug/gpio
GPIOs 0-31, Platform/10000600.gpio, 10000600.gpio:
gpio-11  (Bootstrap           ) Out Lo
gpio-14  (btn_0               ) in  hi
gpio-15  (btn_1               ) in  hi
gpio-16  (btn_2               ) in  hi
gpio-17  (bnt_3               ) in  hi
gpio-18  (btn_4               ) in  hi
Gpio-19  (btn_5               ) in  hi

GPIOs 32-63, Platform/10000600.gpio, 10000600.gpio:
gpio-38  ( Reset               ) in  hi

GPIOs 64-95, Platform/10000600.gpio, 10000600.gpio:

GPIOs 127-127, platform/ Gpio-wifi, Gpio-wifi:
gpio-127 (Mediatek:orange:wifi) out?
Script GPIO Control//gpio Application Layer Control

Https://wiki.openwrt.org/doc/howto/hardware.button
Https://wiki.openwrt.org/doc/hardware/port.gpio?s[]=kmod&s[]=leds&s[]=gpio
Https://wiki.openwrt.org/doc/howto/hardware.button#preliminary.steps

http://wiki.wrtnode.cc/index.php?title= User-space Gpio calls

1 GPIO39 pin control led

Export GPIO39 Pin

  root@mylinkit:/sys/class/gpio# echo ">export"
  root@mylinkit:/sys/class/gpio# ls
  export       gpio39       gpiochip0    gpiochip127  gpiochip32   gpiochip64   unexport

Defining the GPIO39 Output

  root@mylinkit:/sys/class/gpio# CD gpio39
  root@mylinkit:/sys/devices/10000000.palmbus/10000600.gpio/gpio/ gpio39# ls
  active_low  device      direction   Edge        subsystem   uevent      value
  root@mylinkit:/sys/devices/10000000.palmbus/10000600.gpio/gpio/gpio39# Cat Direction
  in
  Root@mylinkit :/sys/devices/10000000.palmbus/10000600.gpio/gpio/gpio39# echo "Out" >direction
  root@mylinkit:/sys/ devices/10000000.palmbus/10000600.gpio/gpio/gpio39# Cat Direction out
  

Modifying the GPIO39 output level

  root@mylinkit:/sys/devices/10000000.palmbus/10000600.gpio/gpio/gpio39# Cat value
  0
  root@mylinkit:/sys/ devices/10000000.palmbus/10000600.gpio/gpio/gpio39# echo "1" > Value
  root@mylinkit:/sys/devices/10000000. palmbus/10000600.gpio/gpio/gpio39# Cat Value
  1

1 Detecting a button input

Export Gpio

  root@mylinkit:/sys/class/gpio# echo ">export"
  root@mylinkit:/sys/class/gpio# ls
  export       gpio16       gpiochip0    gpiochip127  gpiochip32   gpiochip64   unexport
  root@mylinkit:/sys/class/ gpio# cd gpio16
  root@mylinkit:/sys/devices/10000000.palmbus/10000600.gpio/gpio/gpio16# ls
  active_low  device      Direction   Edge        subsystem   uevent      value
  root@mylinkit:/sys/devices/ 10000000.palmbus/10000600.gpio/gpio/gpio16#

Define GPIO39 Input

  root@mylinkit:/sys/devices/10000000.palmbus/10000600.gpio/gpio/gpio16# Cat Direction
  in
  root@mylinkit:/ sys/devices/10000000.palmbus/10000600.gpio/gpio/gpio16# echo "in" >direction
  root@mylinkit:/sys/devices/ 10000000.palmbus/10000600.gpio/gpio/gpio16# Cat Direction in
  

Detect button status High/low level

  root@mylinkit:/sys/devices/10000000.palmbus/10000600.gpio/gpio/gpio16# Cat value
  1
  root@mylinkit:/sys/ devices/10000000.palmbus/10000600.gpio/gpio/gpio16# Cat Value
  0

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.