import com.dalsemi.system.BitPort;
import com.dalsemi.system.DataPort;
import com.dalsemi.system.IllegalAddressException;

class BitTwiddler {
	static final int ADDRESS = 0x800000;

	public static void main(String[] args) {
		// Create and initialize DataPort object
		DataPort dp = new DataPort(ADDRESS);
		dp.setStretchCycles(DataPort.STRETCH7);
		dp.setFIFOMode(true);
		
		// Create BitPort object to expose 8 independant I/O lines
		BitPort bp = new BitPort(dp);
		try {
			while (true) {
				int pos = 0;
				for (pos = 0; pos < 8; pos++) {
					bp.set(pos);
					try {
						Thread.sleep(100);	
					} catch (InterruptedException ie) {}

				}
				for (pos = 7; pos >= 0; pos--) {
					bp.clear(pos);
					try {
						Thread.sleep(100);	
					} catch (InterruptedException ie) {}
				}
			}
		} catch (IllegalAddressException iae) {
			iae.printStackTrace();
		}
	}
}
