#include "LPT-I2C.h"
#include <stdio.h>

int main()
	{
	// check the DLL version:
	if ((LPT_I2C_Version() & 0xFF00) != 0x0100)
		{
		printf ("Wrong DLL Version: expected 1.x, found %d.%02d\n",
			LPT_I2C_Version() / 0x100, LPT_I2C_Version() & 0xFF);
		return -1;
		}

	// open the port:
	if (LPT_I2C_Open())
		{
		// handle a possible error:
		printf ("%s\n", LPT_I2C_ErrorMessage());
		return 1;
		}

	// Flush the interface buffers:
	if (LPT_I2C_Flush_LPT())
		{
		// handle a possible error:
		printf ("%s\n", LPT_I2C_ErrorMessage());
		return 2;
		}

	// Select the UDB slot number 5:
	if (LPT_I2C_SetSlot (5, false))
		{
		// handle a possible error:
		printf ("%s\n", LPT_I2C_ErrorMessage());
		return 3;
		}

	// Send data 0x1234 to the I2C address 32:
	BYTE Data[] = { 0x34, 0x12 };
	if (LPT_I2C_Send (32, Data, sizeof (Data), false))
		{
		// handle a possible error:
		printf ("%s\n", LPT_I2C_ErrorMessage());
		return 4;
		}

	// Receive Pascal string from the I2C address 32
	// Finish with STOP
	char String [256];
	if (LPT_I2C_ReceiveString (32, String, 256, true))
		{
		// handle a possible error:
		printf ("%s\n", LPT_I2C_ErrorMessage());
		return 5;
		}

	//finish the program:
	return 0;
	}
