- Look up GPIO number of the pin in the Beaglebone reference manual. For example, pin 3 on P8 is connected GPIO1_6. To obtain the GPIO number we must multiply the port number by 32 and add the pin number. So GPIO1_6 would be 1x32 + 6 = 38
- Next we must export this pin, so that it is accessible from user space.
echo 38 > /sys/class/gpio/export
- Set the direction of the pin as output
echo out > /sys/class/gpio/gpio38/direction
- Write values to the 'value' file
echo 1 > /sys/class/gpio/gpio38/value
The above steps were followed to blink an led from the terminal. The same was then converted into a C program using C file operations (fopen, fprintf)
No comments:
Post a Comment