How to read out User Push Button not GPIO

Moderator: nferre

micro1
Posts: 42
Joined: Sun Jun 08, 2014 11:55 am

How to read out User Push Button not GPIO

Fri Feb 06, 2015 9:34 pm

Hello,

does anybody know how can i read out push Buttons in the sama5d4 xplained User Push Button! Via GPIO Export does not work Due to when i Export the GPIO how is connected to the Button error Message occur that the Ressource is Busy.

Manne the there is an extra driver for push Buttons?
blue_z
Location: USA
Posts: 1690
Joined: Thu Apr 19, 2007 10:15 pm

Re: How to read out User Push Button not GPIO

Wed Feb 11, 2015 2:57 am

micro1 wrote:does anybody know how can i read out push Buttons in the sama5d4 xplained User Push Button!
Assuming that you are using Linux and that the push button is connected to a PIO configured as such (in the Device Tree), then look at this web page.

Regards
micro1
Posts: 42
Joined: Sun Jun 08, 2014 11:55 am

Re: How to read out User Push Button not GPIO

Wed Feb 11, 2015 8:09 pm

OK thank you. Now i am able to get an Response of the button when i

Code: Select all

 cat dev/input/event0 
But where is all the stuff written down?
micro1
Posts: 42
Joined: Sun Jun 08, 2014 11:55 am

Re: How to read out User Push Button not GPIO

Wed Feb 11, 2015 9:30 pm

So i have check the source code device tree

Code: Select all

gpio_keys {
		compatible = "gpio-keys";
		#address-cells = <1>;
		#size-cells = <0>;

		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_key_gpio>;

		pb_user1 {
			label = "pb_user1";
			gpios = <&pioE 8 GPIO_ACTIVE_HIGH>;
			linux,code = <0x100>;
			gpio-key,wakeup;
		};
	};
But where can i now find out where pb_user1 is located on the filesystem?
blue_z
Location: USA
Posts: 1690
Joined: Thu Apr 19, 2007 10:15 pm

Re: How to read out User Push Button not GPIO

Thu Feb 12, 2015 3:02 am

micro1 wrote:But where is all the stuff written down?
Start with Documentation/input/input.txt, especially sections 3.2.4 and 5.
micro1 wrote:But where can i now find out where pb_user1 is located on the filesystem?
For what purpose?
/dev/input/event0 is the device node to read to obtain events in the form of struct input_event.

Regards
micro1
Posts: 42
Joined: Sun Jun 08, 2014 11:55 am

Re: How to read out User Push Button not GPIO

Sat Feb 14, 2015 5:48 pm

Thanks for help here is the solution

Code: Select all

    struct input_event ev[64];

    do
    {

        // Read out user push button

        int b_Handle0 = open("/dev/input/by-path/platform-gpio_keys.3-event",
        O_RDONLY);

        read(b_Handle0, ev, sizeof(ev));

        close(b_Handle0);

        printf("%ld.%06ld\n", ev[0].time.tv_sec, ev[0].time.tv_usec);
        printf("Time %d \r\n", ev[0].code);
        printf("Time %d \r\n", ev[0].type);
        printf("Time %d \r\n", ev[0].value);

        exit(0);

    } while (1);

Return to “SAMA5-based”

Who is online

Users browsing this forum: Google [Bot] and 1 guest