User`s manual

EM-1220 LX User’s Manual EM-1220-LX Device API
}
typedef struct gpio_set_struct {
int io_number;
int mode_data;
} gpio_t;
/*
* To get the GPIO mode now.
* Input: unsigned int pio - the GPIO number, from 0 to MAX_GPIO-1
* Output: < 0 - some error
* 1 - input
* 0 - ouput
*/
int get_gpio_mode(unsigned int gpio_no)
{
int fd;
gpio_t pset;
CHECK_GPIO_NO(gpio_no);
fd = open(GPIO_DEVICE_NODE, O_RDWR);
if ( fd < 0 )
return GPIO_NODE_ERROR;
pset.io_number = gpio_no;
if ( ioctl(fd, IOCTL_GPIO_GET_DATA, &pset) != 0 ) {
close(fd);
return GPIO_ERROR;
}
close(fd);
return pset.mode_data;
}
/*
* To set the GPIO now mode.
* Input: unsigned int pio - the GPIO number, from 0 to MAX_GPIO-1
* int mode - want to set mode, 1 for input, 0 for output
* Output: < 0 - some error
* = 0 - OK
*/
int set_gpio_mode(unsigned int gpio_no, int mode)
{
int fd;
gpio_t pset;
CHECK_GPIO_NO(gpio_no);
CHECK_GPIO_MODE(mode);
fd = open(GPIO_DEVICE_NODE, O_RDWR);
if ( fd < 0 )
5-6