

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

/*	open a GPIO handle for later uses
	Inputs:
		none
	Returns:
		pointer to a GPIO handle. Return 0 on failure.
*/
HANDLE mxgpio_open(void);


/*	close a GPIO handle
	Inputs:
		<fd> the handle
	Returns:
		none
*/
void mxgpio_close(HANDLE fd);


/*	set the mode of GPIO port
	Inputs:
		<fd>	the GPIO handle
		<port_no> the port number (started from 0)
		<mode>    1:Input, 0:Output
	Returns:
		0 on success, otherwise the function fails
*/
int mxgpio_set_mode(HANDLE fd, unsigned int port_no, int mode);


/*	get the mode of GPIO port
	Inputs:
		<fd>	the GPIO handle
		<port_no> the port number (started from 0)
	Returns:
		1 indicates Input, 0 indicates Output, otherwise the function fails
*/
int mxgpio_get_mode(HANDLE fd, unsigned int port_no);


/*	get the value (HIGH or LOW) of GPIO port
	Inputs:
		<fd>	the GPIO handle
		<port_no> the port number (started from 0)
		<data>    1:HIGH, 0:LOW
	Returns:
		0 on success, otherwise the function fails
*/
int mxgpio_set_data(HANDLE fd, unsigned int port_no, int data);


/*	set the value (HIGH or LOW) of GPIO port
	Inputs:
		<fd>	the GPIO handle
		<port_no> the port number (started from 0)
	Returns:
		1 indicates HIGH, 0 indicates LOW, otherwise the function fails
*/
int mxgpio_get_data(HANDLE fd, unsigned int port_no);

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