User`s manual

EM-1220 LX User’s Manual EM-1220-LX Device API
Limits
1. Both SD card and GPIO share the same signals. To enable GPIO, SD must be disabled, and
vice versa. Drivers will not automatically check if it is SD or GPIO signals, users must decide
before using these signals.
2. Both moxadevice.h and libmoxalib.a are supported in Tool Chain v1.6 or newer version.
GPIO Library Source Code
/*
.* History:
.* Date Author Comment
.* 12-06-2005 Victor Yu. Create it.
.*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
// following about GPIO API implement
#define GPIO_DEVICE_NODE “/dev/pio”
#define IOCTL_GPIO_GET_MODE 1
#define IOCTL_GPIO_SET_MODE 2
#define IOCTL_GPIO_GET_DATA 3
#define IOCTL_GPIO_SET_DATA 4
#define MAX_GPIO 10
#define GPIO_NO_ERROR -1 // the GPIO number error
#define GPIO_MODE_ERROR -2 // the GPIO mode error
#define GPIO_DATA_ERROR -3 // the GPIO data error
#define GPIO_NODE_ERROR -4 // open GPIO device node error
#define GPIO_ERROR -5 // some error, get error number from errno
#define GPIO_INPUT 1 // the GPIO mode is input
#define GPIO_OUTPUT 0 // the GPIO mode is output
#define GPIO_HIGH 1 // the GPIO data is high
#define GPIO_LOW 0 // the GPIO data is low
#define GPIO_OK 0 // function is OK
#define CHECK_GPIO_NO(p) { \
if ( (p) >= MAX_GPIO ) \
return GPIO_NO_ERROR; \
}
#define CHECK_GPIO_MODE(m) { \
if ( (m) != GPIO_INPUT && (m) != GPIO_OUTPUT ) \
return GPIO_MODE_ERROR; \
}
#define CHECK_GPIO_DATA(d) { \
if ( (d) != GPIO_HIGH && (d) != GPIO_LOW ) \
return GPIO_DATA_ERROR; \
5-5