Products > Embedded Computing

Using GPIO on a beaglebone in Linux

(1/2) > >>

SimonR:
Is there a ready made Linux driver for controlling Beaglebone PIO lines in user space?

My colleagues has a project prototype that is Beaglebone based and has an engineer doing the software. This engineer has done all of the clever stuff like DMA and LCD but not the keypad. He says the keypad is the most difficult as he has to write the driver from scratch since there are no examples to modify.

All the key pad is are 12 buttons connected to 12 PIO lines, not efficient but really simple.

Surely if there was no driver then none of the hobby/maker community would be using Beaglebone would they, there must be a driver already.

MosherIV:
Hi. As far as I remember, all devices are accessable as file devices.
You just change directory to the devs directory, find the gpio directory, cd to the particular gpio port and then open the gpio port as a file.
You can then just read them or write to them.
(You may have to enable the device for user access or su login to access the port)

I used to use a web site for embedded linux for this kind of info. Try elinux.org
https://elinux.org/Beagleboard:Main_Page#BeagleBone_Black

Never tried bbb, I worked on Nvidia Jetson TK1. The pages I read on gpio was from the bbb pages.

MarkL:
Take a look in the kernel source in ./drivers/input/keyboard.  There's all kinds of interrupt, matrix, and one-to-one GPIO keypad drivers.

What you want is probably gpio_keys_polled.c.

Nominal Animal:

--- Quote from: SimonR on July 19, 2019, 09:18:27 am ---This engineer has done all of the clever stuff like DMA and LCD but not the keypad. He says the keypad is the most difficult as he has to write the driver from scratch since there are no examples to modify.
--- End quote ---
Do you mean using one of the PRUs to inject the 12 buttons as keypresses to the Linux Input subsystem, or what?

If you just want to do it in userspace, you can access the GPIO pins in userspace -- use the new character device interface; see examples in tools/gpio/ in the Linux kernel sources --, and inject any keyboard events back into the Linux input subsystem using the uinput character device.  This approach works for all Linux SBCs, and has nothing BeagleBone specific.

nali:

--- Quote from: MosherIV on July 19, 2019, 11:06:23 pm ---Hi. As far as I remember, all devices are accessable as file devices.
You just change directory to the devs directory, find the gpio directory, cd to the particular gpio port and then open the gpio port as a file.
You can then just read them or write to them.
(You may have to enable the device for user access or su login to access the port)

--- End quote ---

Not used BBB in a while, but from memory I think they are in /sys/class/gpio somewhere. There should be a direction and a value and you can just read or write to them e.g. using cat or echo.

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod