thejpster / monotron

A simple 8-bit home computer style application for the TI Tiva-C Launchpad
Apache License 2.0
191 stars 9 forks source link

Printer support #48

Open thejpster opened 5 years ago

thejpster commented 5 years ago

It would be fun to add Printer Support. There's two primary interfaces:

Obviously the latter requires USB host support but I think the first option is acheivable with an SPI or I2C I/O expander and some bit bashing. It wouldn't be fast, but it should work.

I have an old Panasonic dot-matrix I can test with. We would add LPT: as a device type you can open, along with disks, joysticks, keyboard and the screen.

thejpster commented 5 years ago

A Microchip MCP23S17 or MCP23017 would be ideal. An IEEE1284 'Centronics' interface has 8 data pins (host to device), 4 control lines (host to device) and 4 status lines (device to host). This matches the 16 pins on the MCP23x17. The MCP23x17 also has two interrupt lines, which we can use to avoid busy-waiting on the status lines, transferring bytes under interrupt from a small ring buffer.

The SPI version would have to share with the SD/MMC interface, but the I2C version could just sit on the I2C bus. Using I2C (which is open-drain) would also allow us to run the MCP23017 at 5V without needing level shifters either on the GPIO device input/output pin, or between the GPIO device and the host (because it's open-drain and the Launchpad is 5V tolerant).

So, we should use the MCP23017 for parallel printer support.

thejpster commented 5 years ago

The PCB has an Atmega48 wired up to the printer port.