2008-12-19 06:43:21 simple gpio issue
Kiran Kumar B (INDIA)
Message: 66950
Hi,
Distribution : uClinux-dist-2008R1.5-RC3 / Processor : BF527 : / Board EZKIT Tool Chain : blackfin-toolchain-uclibc-full-08r1.5-14.i386 , blackfin-toolchain-08r1.5-14.i386
I am trying to use the driver simple-gpio.c , from the user space. I have refered to test application simple-gpio-test.c and the link: http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:drivers:simple-gpio&s[]=simple&s[]=gpio
Below is the user space test code for reference. You can see that two fwrite is been called with first parameter as "1" and with "0". But I observed that the LED2 doesn not showup any change in the board. For debugging I have added a few prtink in the driver code simple-gpio.c to check the value of variable ' byte ' . I observed that even though I pass "0" or "1" the driver takes it as an alphabet 'O' Is there any problem in the simple-gpio driver or in the test application ? Please let me know.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#include <stdio.h>
#include <unistd.h>
//LED1 PF8 gpio8
//LED2 PG11 gpio27
//LED3 PG12 gpio28
//PG1 gpio17
//PH15 gpio47
//PG13 gpio29
//PF7 gpio7
int main( void])
{
FILE *fp;
int i=0;
fp = fopen( "/dev/gpio27", "r+"); //LED2 , PG11 , gpio27
if(!fp)
printf(" File Error \n");
else
printf(" File created \n");
if (fwrite("O", 1, 1, fp) != 1)
printf(" Error Output\n");
fsync(fileno(fp));
printf(" Output Mode\n");
for (i=0; i<=10;i++)
{
printf(" In Loop \n");
if (fwrite("1", 1, 1, fp) != 1)
printf(" Err set ");
sleep(1);
if (fwrite("0", 1, 1 , fp) != 1)
printf(" Err clear");
sleep(1);
}
fclose(fp);
printf(" File closed \n");
return 0;
}
QuoteReplyEditDelete
2008-12-19 09:23:11 Re: simple gpio issue
abhrajit datta (INDIA)
Message: 66953
you can directly set the gpio direction and value:
$ echo 'O1' > /dev/gpio27 - output mode value =1
In the simple_gpio_game.c the leds are set to output using :
if (write(leds_fd[i], "O0", 2) != 2)
the simple_gpio_game.c is working for LED2 in bf527 EZ kit.
hope this helps.
abhri
QuoteReplyEditDelete
2008-12-22 02:47:33 Re: simple gpio issue
Kiran Kumar B (INDIA)
Message: 67025
Thanks Abhri, I tried using the write( ) , as given in simple_gpio_game.c Its working fine... Thanks again.