src/gpio.c
/**
 * @brief Open GPIO file descriptor
 *
 * Open the given GPIO pin's file descriptor
 *
 * @param gpio GPIO pin number
 * @param sysfs_file File to open file descriptor from
 * @param flags File descriptor open() flags
 *
 * @return File descriptor on success, or -1 on failure and errno is set
 */
@brief Open GPIO file descriptor
Open the given GPIO pin's file descriptor

@param gpio GPIO pin number
@param sysfs_file File to open file descriptor from
@param flags File descriptor open() flags

@return File descriptor on success, or -1 on failure and errno is set
@brief Open GPIO file descriptor Open the given GPIO pin ' s file descriptor @param gpio GPIO pin number @param sysfs_file File to open file descriptor from @param flags File descriptor open () flags @return File descriptor on success or - 1 on failure and errno is set
int gpio_fd_open(unsigned int gpio, char* sysfs_file, int flags) {
	char buf[MAX_BUF];
	if (sysfs_file == SYSFS_GPIO_EXPORT || sysfs_file == SYSFS_GPIO_UNEXPORT) {
		snprintf(buf, sizeof(buf), "%s/%s", SYSFS_GPIO_DIR, sysfs_file);
	} else {
		snprintf(buf, sizeof(buf), "%s/gpio%d/%s", SYSFS_GPIO_DIR, gpio, sysfs_file);
	}
	return open(buf, flags);
}
int gpio_fd_open ( unsigned int gpio , char * sysfs_file , int flags ) { char buf [ MAX_BUF ] ; if ( sysfs_file == SYSFS_GPIO_EXPORT || sysfs_file == SYSFS_GPIO_UNEXPORT ) { snprintf ( buf , sizeof ( buf ) , " " , SYSFS_GPIO_DIR , sysfs_file ) ; } else { snprintf ( buf , sizeof ( buf ) , " " , SYSFS_GPIO_DIR , gpio , sysfs_file ) ; } return open ( buf , flags ) ; }
@brief Open GPIO file descriptor
 Open the given GPIO pin's file descriptor
@brief Open GPIO file descriptor Open the given GPIO pin ' s file descriptor