Moxa Technologies EM-1240-LX Manuale Utente Pagina 50

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 58
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 49
EM-1240-LX User’s Manual EM-1240-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_MODE, &pset) != 0 ) {
close(fd);
return GPIO_ERROR;
}
close(fd);
return pset.mode_data;
}
/*
* To get the GPIO data now.
* Input: unsigned int pio - the GPIO number, from 0 to MAX_GPIO-1
* Output: < 0 - some error
* 1 - high
* 0 - low
*/
int get_gpio_data(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 ) {
5-6
Vedere la pagina 49
1 2 ... 45 46 47 48 49 50 51 52 53 54 55 56 57 58

Commenti su questo manuale

Nessun commento