src/gpio.c
/**
 * @breif Read GPIO value
 *
 * Read the given GPIO pin value as either high or low
 *
 * @param gpio GPIO pin number
 *
 * @return Value of GPIO pin as HIGH or LOW, or -1 on failure and errno is set
 */
@breif Read GPIO value
Read the given GPIO pin value as either high or low

@param gpio GPIO pin number

@return Value of GPIO pin as HIGH or LOW, or -1 on failure and errno is set
@breif Read GPIO value Read the given GPIO pin value as either high or low @param gpio GPIO pin number @return Value of GPIO pin as HIGH or LOW or - 1 on failure and errno is set
int gpio_read(unsigned int gpio) {
	char ch;
	int fd = gpio_fd_open(gpio, SYSFS_GPIO_VALUE, O_RDONLY);
	if (fd < 0) {
		return fd;
	}
	read(fd, &ch, 1);
	close(fd);
	if (ch == '0') {
		return 0;
	} else {
		return 1;
	}
}
int gpio_read ( unsigned int gpio ) { char ch ; int fd = gpio_fd_open ( gpio , SYSFS_GPIO_VALUE , O_RDONLY ) ; if ( fd < 0 ) { return fd ; } read ( fd , & ch , 1 ) ; close ( fd ) ; if ( ch == ' ' ) { return 0 ; } else { return 1 ; } }
@breif Read GPIO value
 Read the given GPIO pin value as either high or low
@breif Read GPIO value Read the given GPIO pin value as either high or low