I would like to continuously read the status of an IO line on my Beaglebone 
black.  The code I pasted below is a section of my software looking for 
rising and falling edges.  Is there a way in Linux to read the status of 
that line without having to open and close the same file that is faster? 
 The method I have below works, but only at really low frequencies. 

I am trying to read the IO approx. 15kHz.

Thanks


      while( buf[0]=='0' ) {
memset(adc_drdy, 0, sizeof(adc_drdy) );
if((j =  fopen ( "/sys/class/gpio/gpio65/value", "r"   )) ==  NULL)  {
//printSerial("Unable to read input file");
}
else {
fgets(adc_drdy, sizeof(adc_drdy), j);
strcpy(buf, adc_drdy);
//fprintf(j, "%s", adc_drdy);
fclose(j);
}
system("echo 0 > /sys/class/gpio/gpio61/value");
printf("%c\n", buf[0]);
//if(ADC_DRDY=='1') break;
}
 while( buf[0]=='1' ) {

memset(adc_drdy, 0, sizeof(adc_drdy) );
if((j =  fopen ( "/sys/class/gpio/gpio65/value", "r"   )) ==  NULL)  {
//printSerial("Unable to read input file");
}
else {
fgets(adc_drdy, sizeof(adc_drdy), j);
strcpy(buf, adc_drdy);
//fprintf(j, "%s", adc_drdy);
fclose(j);
}
system("echo 1 > /sys/class/gpio/gpio61/value");
printf("%c\n", buf[0]);
//if(ADC_DRDY=='0') break;
}

-- 
For more options, visit http://beagleboard.org/discuss
--- 
You received this message because you are subscribed to the Google Groups 
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to