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.

Linux/PROCESSOR-SDK-AM335X: GPIO Driver

Part Number: PROCESSOR-SDK-AM335X


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.

  • Hi,

    Driver development is not supported on this forum. The AM335x Linux Processor SDK already has a GPIO driver.
  • Thanks,
    Please guide me to develop a simple code, when a button pressed it will change status of LED, with the help of interrupt routing.
  • 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;	
    }
    

  • Harshad,

    You should use GPIO sysfs for user space access. You can use shell script or C application to access sys/class/gpio from user space. Please have a look in the below links for more info:

    falsinsoft.blogspot.com/.../access-gpio-from-linux-user-space.html

    developer.ridgerun.com/.../How_to_use_GPIO_signals - see gpio.sh for example shell script, gpio-int-test.c for exmaple C application

    e2e.ti.com/.../2246361
    e2e.ti.com/.../1930093

    Regards,
    Pavel