Hi,

MC Potgieter wrote:
> In the FriendlyARM linux examples they show that the LEDs (IO) can be
> accessed in the following manner:
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <unistd.h>
> #include <sys/ioctl.h>
>
> int main(int argc, char **argv)
> {
>     int led_state = 1;
>     int led_no = 0;
>     int fd;
>
>     fd = open("/dev/leds0", 0);
>     if (fd < 0) {
>         fd = open("/dev/leds", 0);
>     }
>     if (fd < 0) {
>         perror("open device leds");
>         exit(1);
>     }
>     ioctl(fd, led_state, led_no);
>     close(fd);
>     return 0;
> }
>
> In the oselas documentation they show one can access the leds through
> /sys/class/leds. How would one access the peripherals or IOs in PTXdist
> using C?
> Is there any example programs?

Do it in your C-Code like the "cat" and the "echo" commands do it.

h = fopen("/sys/class/leds/led1/brightness", "w");
fprintf(h, "1\n");
close(h);

h = fopen("/sys/class/leds/led1/brightness", "w");
fprintf(h, "0\n");
close(h);

(note: The above is an untested example)

Juergen

-- 
Pengutronix e.K.                              | Juergen Beisert             |
Linux Solutions for Science and Industry      | http://www.pengutronix.de/  |

-- 
ptxdist mailing list
[email protected]

Reply via email to