#include "stdafx.h"
#include <windows.h>
#include <winioctl.h>
#include <stdio.h>


#ifdef __cplusplus    // If used by C++ code, 
extern "C" {          // we need to export the C interface
#endif


#define SPEAKER_IO_ADDRESS 0x303
#define SPEAKER_BIT 0
#define SPEAKER_BIT_DISABLE 0
#define SPEAKER_BIT_BEEP 1

#define UART_AUTODIRECTION_CONTROL_ADDRESS 0xF0  // In ITE Super IO
#define UART

#define UART_MODE_IO_ADDRESS 0x304 //General IO Address
#define UART_MODE_BIT_COM1_RS232 1
#define UART_MODE_BIT_COM1_RS485 0
#define UART_MODE_BIT_COM1_RS422 3

#define UART_MODE_BIT_COM2_RS232 4
#define UART_MODE_BIT_COM2_RS485 5
#define UART_MODE_BIT_COM2_RS422 2


int UartModeGet(int portNum);
int UartModeSet(int portNum, int portMode);
int EnableAutoDirectionControl(int portNum);
int DisableAutoDirectionControl(int portNum);
UCHAR ReadPortData(ULONG address);
int WritePortData(ULONG	address, UCHAR ucMemData);
UCHAR ReadSuperIoChar(ULONG address, int portNum);
int WriteSuperIoChar(ULONG	address, int portNum, UCHAR	ucMemData);
int SetAutoDirectionControl(int portNum);

HANDLE mxsp_open();
void mxsp_close();
int mxsp_get_interface(HANDLE fd, int port_index);
int mxsp_set_interface(HANDLE fd, int port_index, int port_interface);



#ifdef __cplusplus    // If used by C++ code, 
}
#endif
