User`s manual

EM-1220 LX User’s Manual EM-1220-LX Device API
5-7
return GPIO_NODE_ERROR;
pset.io_number = gpio_no;
pset.mode_data = mode;
if ( ioctl(fd, IOCTL_GPIO_SET_MODE, &pset) != 0 ) {
close(fd);
return GPIO_ERROR;
}
close(fd);
return GPIO_OK;
}
/*
* To set the GPIO now data.
* Input: unsigned int pio - the GPIO number, from 0 to MAX_GPIO-1
* int data - 1 for high, 0 for low
* Output: < 0 - some error
* = 0 - OK
*/
int set_gpio_data(unsigned int gpio_no, int data)
{
int fd;
gpio_t pset;
CHECK_GPIO_NO(gpio_no);
CHECK_GPIO_DATA(data);
fd = open(GPIO_DEVICE_NODE, O_RDWR);
if ( fd < 0 )
return GPIO_NODE_ERROR;
pset.io_number = gpio_no;
pset.mode_data = data;
if ( ioctl(fd, IOCTL_GPIO_SET_DATA, &pset) != 0 ) {
close(fd);
return GPIO_ERROR;
}
close(fd);
return GPIO_OK;
}