Tool/software: Linux
Hello,
I want to write gpio driver with interrupt for AM335x. Please guide me step by step.
Then how to build it.
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Tool/software: Linux
Hello,
I want to write gpio driver with interrupt for AM335x. Please guide me step by step.
Then how to build it.
Thanks,
To guide me,
I write simple code for input and output gpio.
The file will show in given attachment.
Generated executable file put in SD-card directory(/home/root/).
I want to make sure that, this is a right way or not to programming?
#include <stdio.h>
#include <string.h>
#include <stdlib.h> // system()
#include <unistd.h> // sleep()
int main()
{
printf("LED Blink Project!\n");
/* Set GPIO as output */
system("echo 39 > /sys/class/gpio/export");
system("echo \"out\" > /sys/class/gpio/gpio39/direction");
system("echo 1 > /sys/class/gpio/gpio39/value");
/* Set Button as input */
system("echo 69 > /sys/class/gpio/export");
system("echo \"in\" > /sys/class/gpio/gpio69/direction");
system("echo \"falling\" > /sys/class/gpio/gpio69/edge");
while(1)
{
if(1 == system("cat /sys/class/gpio/gpio69/value"))
{
system("echo 1 > /sys/class/gpio/gpio39/value");
printf("LED : on!\n");
}
else
{
system("echo 0 > /sys/class/gpio/gpio39/value");
printf("LED : off!\n");
}
}
return 0;
}