Moxa EM-1220-LX [47/57] How to use the gpio

Moxa EM-1220-T-LX [47/57] How to use the gpio
EM-1240-LX User’s Manual EM-1240-LX Device API
int set_gpio_mode(unsigned int pio, int mode)
--to configure GPIO ports to be DI ports or DO ports.
Input:
unsigned int pio - GPIO port number
Each GPIO point will be regarded as a port. We support from Port 0 to Port 9 for the EM-1240,
and from Port 0 to Port 7 for the EM-1220.
int mode
1 represents DI.
0 represents DO.
Output:
1 represents high.
0 represents low.
Return:
< 0 is wrong.
= 0 is correct.
int set_gpio_data(unsigned int pio, int data)
--to check the current status of the GPIO, either high or low voltage, used when the GPIO points
are configured as DO.
Input:
unsigned int pio - GPIO port number
Each GPIO point will be regarded as a port. We support from Port 0 to Port 9 for the EM-1240,
and from Port 0 to Port 7 for the EM-1220.
int data
1 represents high.
0 represents low.
Output:
1 represents high.
0 represents low.
Return:
< 0 is wrong.
= 0 is correct.
How to use the GPIO
1. The device driver must be loaded.
> insmod gpio.ko
2. The program must include <moxadevice.h> and link to libmoxalib.a. Here is an example:
> arm-elf-gcc –wl, -elf2flt –o TestGpioAp TestGpioAp.c –lmoxalib –lpthread
5-4

Содержание

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

Скачать