/*++

Copyright (c) 1990-2000 Microsoft Corporation, All Rights Reserved
 
Module Name:

    gpioctl.h  

Abstract:   Include file for Generic Port I/O Example Driver


Author:    Robert R. Howell  January 8, 1993


Revision History:

 Robert B. Nelson (Microsoft)     March 1, 1993
 Epson Chiang (MOXA)							September 3, 2010

--*/

#if     !defined(__GPIOCTL_H__)
#define __GPIOCTL_H__

//
// Define the IOCTL codes we will use.  The IOCTL code contains a command
// identifier, plus other information about the device, the type of access
// with which the file must have been opened, and the type of buffering.
//
typedef struct _DIO {
	int	port;
	int	data;
} DIO, *PDIO;

typedef struct _GPIO {
	int	port;
	int	data;
} GPIO, *PGPIO;

typedef struct _IOADDR_DEF {
    unsigned long IOAddress;
	unsigned long DataFilter;
	unsigned long DataOffset;
	unsigned long DataBit;
  	char *Desc;
} IOADDR_DEF;

//
// Device type           -- in the "User Defined" range."
// The IOCTL function codes from 0x800 to 0xFFF are for customer use.

#define GPD_TYPE 40000

// The IOCTL function codes from 0x800 to 0xFFF are for customer use.
#define MOXA_IOCTL              0x800
#define IOCTL_SET_MODE   CTL_CODE(FILE_DEVICE_SERIAL_PORT, MOXA_IOCTL+23,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_GET_MODE   CTL_CODE(FILE_DEVICE_SERIAL_PORT, MOXA_IOCTL+24,METHOD_BUFFERED,FILE_ANY_ACCESS)


#define MOXA_DIO_IOCTL 0x900 

#define IOCTL_SET_DOUT_ALL \
    CTL_CODE( GPD_TYPE, MOXA_DIO_IOCTL, METHOD_BUFFERED, FILE_ANY_ACCESS ) //0x900
    
#define IOCTL_GET_DOUT_ALL \
    CTL_CODE(GPD_TYPE,  MOXA_DIO_IOCTL+1, METHOD_BUFFERED, FILE_ANY_ACCESS)//0x901

#define IOCTL_SET_DOUT \
    CTL_CODE( GPD_TYPE, MOXA_DIO_IOCTL+2, METHOD_BUFFERED, FILE_ANY_ACCESS )//0x902

#define IOCTL_GET_DOUT \
    CTL_CODE( GPD_TYPE, MOXA_DIO_IOCTL+3, METHOD_BUFFERED, FILE_ANY_ACCESS )//0x903

#define IOCTL_GET_DIN_ALL \
    CTL_CODE(GPD_TYPE,  MOXA_DIO_IOCTL+4, METHOD_BUFFERED, FILE_ANY_ACCESS) //0x904

#define IOCTL_GET_DIN \
    CTL_CODE( GPD_TYPE, MOXA_DIO_IOCTL+5, METHOD_BUFFERED, FILE_ANY_ACCESS ) //0x905
    
#define IOCTL_SET_COUNTER_PCI \
    CTL_CODE(GPD_TYPE,  MOXA_DIO_IOCTL+6, METHOD_BUFFERED, FILE_ANY_ACCESS ) //0x906
    
#define IOCTL_GET_COUNTER_PCI \
    CTL_CODE(GPD_TYPE,  MOXA_DIO_IOCTL+7, METHOD_BUFFERED, FILE_ANY_ACCESS ) //0x907

#define IOCTL_CLEAR_COUNTER_PCI \
    CTL_CODE(GPD_TYPE,  MOXA_DIO_IOCTL+8, METHOD_BUFFERED, FILE_ANY_ACCESS ) //0x908


#define MOXA_GPIO_IOCTL 0x910 

#define IOCTL_GPIO_SET \
    CTL_CODE(GPD_TYPE,  MOXA_GPIO_IOCTL, METHOD_BUFFERED, FILE_WRITE_ACCESS) //0x910

#define IOCTL_GPIO_GET \
    CTL_CODE(GPD_TYPE,  MOXA_GPIO_IOCTL+1, METHOD_BUFFERED, FILE_READ_ACCESS) //0x911
    
#define IOCTL_GPIO_SET_MODE \
    CTL_CODE(GPD_TYPE,  MOXA_GPIO_IOCTL+2, METHOD_BUFFERED, FILE_WRITE_ACCESS)//0x912

#define IOCTL_GPIO_GET_MODE \
    CTL_CODE(GPD_TYPE,  MOXA_GPIO_IOCTL+3, METHOD_BUFFERED, FILE_WRITE_ACCESS)//0x913

#define IOCTL_SET_LED \
    CTL_CODE(GPD_TYPE,  MOXA_GPIO_IOCTL+4, METHOD_BUFFERED, FILE_WRITE_ACCESS)//0x914

#define IOCTL_GET_LED \
    CTL_CODE(GPD_TYPE,  MOXA_GPIO_IOCTL+5, METHOD_BUFFERED, FILE_READ_ACCESS) //0x915
    
    
#define MOXA_BIOS_IOCTL 0x920 

#define IOCTL_SET_BIOSINFO \
    CTL_CODE( GPD_TYPE, MOXA_BIOS_IOCTL, METHOD_BUFFERED, FILE_WRITE_ACCESS ) //0x920

#define IOCTL_GET_BIOSINFO \
    CTL_CODE( GPD_TYPE, MOXA_BIOS_IOCTL+1, METHOD_BUFFERED, FILE_WRITE_ACCESS )//0x921

#define IOCTL_SET_LVDS_SETTING \
    CTL_CODE( GPD_TYPE, MOXA_BIOS_IOCTL+2, METHOD_BUFFERED, FILE_WRITE_ACCESS )//0x922
    
#define IOCTL_GET_LVDS_SETTING \
    CTL_CODE( GPD_TYPE, MOXA_BIOS_IOCTL+3, METHOD_BUFFERED, FILE_WRITE_ACCESS )//0x923
#endif

