2 * This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307USA
16 * Feedback, Bugs... blogic@openwrt.org
22 #include <sys/types.h>
25 #include <linux/gpio_dev.h>
26 #include <linux/ioctl.h>
31 printf("gpioctl dirin|dirout|get|set|clear gpio\n");
36 main(int argc
, char **argv
)
47 if ((fd
= open("/dev/gpio", O_RDWR
)) < 0)
49 printf("Error whilst opening /dev/gpio\n");
53 gpio_pin
= atoi(argv
[2]);
55 printf("using gpio pin %d\n", gpio_pin
);
57 if (!strcmp(argv
[1], "dirin"))
59 ioctl(fd
, GPIO_DIR_IN
, gpio_pin
);
60 } else if (!strcmp(argv
[1], "dirout"))
62 ioctl(fd
, GPIO_DIR_OUT
, gpio_pin
);
63 } else if (!strcmp(argv
[1], "get"))
65 result
= ioctl(fd
, GPIO_GET
, gpio_pin
);
66 printf("Pin %d is %s\n", gpio_pin
, (result
? "HIGH" : "LOW"));
67 } else if (!strcmp(argv
[1], "set"))
69 ioctl(fd
, GPIO_SET
, gpio_pin
);
70 } else if (!strcmp(argv
[1], "clear"))
72 ioctl(fd
, GPIO_CLEAR
, gpio_pin
);
This page took 0.060315 seconds and 5 git commands to generate.