Moxa EM-1220-LX Инструкция по эксплуатации онлайн [50/57] 170895

Moxa EM-1240-T-LX Инструкция по эксплуатации онлайн [50/57] 170900
EM-1240-LX User’s Manual EM-1240-LX Device API
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 )
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;
5-7

Содержание

Похожие устройства

Скачать