I know that a lot of this has been asked before and/or has been answered and I have somehow missed the answer.
First off, I would like to thank those who helped solve the issue of making uarts work.
I have a BBB that is running I believe 3.8.11 and I would like the ability to hook up some simple IO to the board. Things like buttons/switches, likewise maybe hook up some external leds so it would be nice to be able to use some of the pins on the external connectors. So the question is what is the best way to do this. Are there some simple functions that are equivalent to the Arduino functions (pinMode, digitalRead, digitalWrite)?
I have been playing around with this for a little while and have not had that much luck yet. My first attempt was to use the library Beagle_GPIO-master by Francois Sugny, which I did not work for me as I believe it again relies on the old debug memory map stuff.
Yesterday, I tried out the library bonelib, which I have had some limited success with. In particular, I was able to the get the led example to work, after I modified the src/leds.cpp file to change the hardware path to where the leds are. to:
sprintf(p, “/sys/class/leds/beaglebone:green:usr%d/”, n);
However I was not able to get the IO pin stuff working as I tried building a simple test case, from a suggestion in a different posting, which looked like:
`
#include <stdio.h>
#include <unistd.h>
#include “bonelib/gpio.hpp”
int
main(int argc, const char argv[])
{
BeagleBone::gpio IOP = BeagleBone::gpio::P8(3);
printf(“Start Test IO Pin\n\r”);
IOP->configure(BeagleBone::pin::OUT);
printf(“After Configure\n\r”);
IOP->set(1);
printf(“After first set\n\r”);
for (int i = 0; i < 8; i++) {
IOP->set(0);
printf(“Off\n\r”);
usleep(5001000);
IOP->set(1);
printf(“On\n\r”);
usleep(5001000);
}
return 1;
}
`
But this failed as well, again I believe using the old omap mapping.
Start Test IO Pin
ERROR: Cannot open /sys/kernel/debug/omap_mux/gpmc_ad6 for writing: No such file or directory
After Configure
…
My guess is that I need to somehow use the GPIO interface, like the one mentioned in:
https://git.kernel.org/cgit/linux/kernel/git/stable/linux-stable.git/tree/Documentation/gpio.txt?id=refs/tags/v3.8.11
But this for example relies on I believe pin numbers. If so is there already a mapping somewhere that takes for example the logical pin P8(3) and maps to the correct pin number?
Note as part of the UART stuff, I know we used the define: /sys/kernel/debug/pinctrl/44e10800.pinmux/pins
(Defined on my machine as $PINS)
When I do: cat $PINS
I get an output of I believe 142 pins.
I know from trying to map uart2_rxd/txd that the address for uart2_rxd was something like: 44e10950, which looking through the list of 142 pins shows up like:
pin 84 (44e10950) 00000021 pinctrl-single
pin 85 (44e10954) 00000001 pinctrl-single
(Also showing the TXD). So in this case would I use 84 as the pin number to GPIO?
Thanks
Kurt
P.S - sorry if I rambled on a little too much.