H89 Projects Downloads - USB Adapter

Projects Home

----------

PCDVD6A.ASM     -	Device driver source code for USB adapter.  Compiling this driver
			requires several of the standard, Heath provided .ACM files.

PC6A.DVD          -	Loadable device driver.  Copy to HDOS boot disk and rename to PC.DVD

h89mount3.zip    -	Zip file of test deployment of a Windows version of the H89Mount3 program.
			Testing is not complete so use at your own risk.  However, I would appreciate
			comments on the experiences of anyone who is brave enough to try to run the
			executable.  It should start and allow you to load an H8D image whether
			you have an FTDI FD245 installed in your H8/89 or not.

			NOTE: If you've never connected to an FTDI device, you will likely have
			to go to http://www.ftdichip.com/FTDrivers.htm to download the
			ftd2xx.dll for your platform.  If the DLL isn't present,
			Windows will complain and will not run the utility.

The Driver and the Protocol

The device driver provides only very basic capabilities. It has no set options and does no processing of the data passed through it. It provides input and output routines sufficient only to read from and write to a directory device via the USB adapter.

As mentioned elsewhere on this site, the user of the PC host program must load an H8D image and select the appropriate USB device from those offered by the program. The program only recognizes FTDI devices, so there will be no confusion with other possible USB devices connected to the host. In addition, once the user has completed using of the H8D image(s), the images must be manually unloaded. Upon unload, the user is offered the option of saving any possible changes or unloading without saving changes. It may be desirable to change the program so that any "writes" by the H8/89 are automatically saved to the image. This is similar to the periodic "sync", i.e., physical write to disk media, done by many modern operating systems.

Once images are loaded and the USB device is selected, the host program event loop checks the USB port for input upon each pass through the loop. If input is detected the program requests 12 bytes of input. These 12 bytes constitute the Command Packet sent by the PC.DVD device driver. The Command Packet indicates whether the device driver wants to read from the PC image or write to it. It also contains information on which "sectors" in the image to use and how many bytes to transfer.

The format of the Command Packet is:

		Byte count		- 2 bytes	(always 12)
		Command Byte		- 1 byte
		Sector Number		- 2 bytes
		Bytes Requested		- 2 bytes
		Unit Number     	- 1 byte
		Reserved		- 3 bytes
		Checksum		- 1 byte

Currently the Checksum is not being generated nor checked. A Command Packet requesting to read the label sector from the image would be:

		0x0c, 0x00		byte count for Command Packet (12)
		0x03			command to read
		0x09, 0x00		sector number 9
		0x01, 0x00		256 bytes
		0x01			from PC1:
		0x00, 0x00, 0x00	reserved
		0x00			checksum (currently not used)

The PC decodes the Command Packet and then sends an Acknowledgement Packet to the device driver. If the packet is valid, the PC so indicates and the driver proceeds to wait for further input. The PC continues by retrieving the sector requested and creating a Data Packet. The format of the Data Packet is:

		Byte count		- 2 bytes
		Data retrieved		- Multiple of 256 bytes
		Checksum		- 1 byte (currently not used)

The device driver reads two bytes and determines how many more bytes will be delivered. It then continues polling the FT245 FIFO status and accepting data until the transfer count is exhausted. Once this occurs, the driver returns to HDOS until called to process additional transfers.

The write process is handled in a similar manner. There is an additional transmission of an Acknowledgement Packet to advise the H8/89 as to the success of the write attempt. A PDF file is being drafted to provide more details for those who may be interested.


Dan Emrick
March 14, 2010