/*
Filename: TOGGLE_D0.CPP
Purpose: Toggle output line D0 (Data 0) of the parallel port repeatedly.
Date: Monday 17 October 2005
Author: Chris Carter, chris.carter@iee.org
Usage: ./toggle_d0
*/

// Header files

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <unistd.h>
#include <sys/io.h>

using namespace std;

unsigned int port = 0x378;		// Address of the first parallel port in hexadecimal
long int i;						// A loop counter variable
long int tdelay = 5000000;		// A trial-and-error number to give an acceptable delay

// Start of the main function

int main()
{
	while (1 > 0)				// Loop forever
		{
			outb(0, port);		// Send 0 to the port (turns D0 - D7 off)

			i = tdelay;			// Crude delay loop
			while (i > 0)
			{
				i = i - 1;
			}

			outb(1, port);		// Send 1 to the port (turns D0 on)

			i = tdelay;			// Same crude delay loop again
			while (i > 0)
			{
				i = i - 1;
			}
		}
	exit(0);
}

// End of file.
