spi_butterfly - parport-to-butterfly adapter driver

This is a hardware and software project that includes building and usinga parallel port adapter cable, together with an “AVR Butterfly” to runfirmware for user interfacing and/or sensors. A Butterfly is a $US20battery powered card with an AVR microcontroller and lots of goodies:sensors, LCD, flash, toggle stick, and more. You can use AVR-GCC todevelop firmware for this, and flash it using this adapter cable.

You can make this adapter from an old printer cable and solder thingsdirectly to the Butterfly. Or (if you have the parts and skills) youcan come up with something fancier, providing ciruit protection to theButterfly and the printer port, or with a better power supply than twosignal pins from the printer port. Or for that matter, you can usesimilar cables to talk to many AVR boards, even a breadboard.

This is more powerful than “ISP programming” cables since it lets kernelSPI protocol drivers interact with the AVR, and could even let the AVRissue interrupts to them. Later, your protocol driver should workeasily with a “real SPI controller”, instead of this bitbanger.

The first cable connections will hook Linux up to one SPI bus, with theAVR and a DataFlash chip; and to the AVR reset line. This is all youneed to reflash the firmware, and the pins are the standard Atmel “ISP”connector pins (used also on non-Butterfly AVR boards). On the parportside this is like “sp12” programming cables.

SignalButterflyParport (DB-25)
SCKJ403.PB1/SCKpin 2/D0
RESETJ403.nRSTpin 3/D1
VCCJ403.VCC_EXTpin 8/D6
MOSIJ403.PB2/MOSIpin 9/D7
MISOJ403.PB3/MISOpin 11/S7,nBUSY
GNDJ403.GNDpin 23/GND

Then to let Linux master that bus to talk to the DataFlash chip, you must(a) flash new firmware that disables SPI (set PRR.2, and disable pullupsby clearing PORTB.[0-3]); (b) configure the mtd_dataflash driver; and(c) cable in the chipselect.

SignalButterflyParport (DB-25)
VCCJ400.VCC_EXTpin 7/D5
SELECTJ400.PB0/nSSpin 17/C3,nSELECT
GNDJ400.GNDpin 24/GND

Or you could flash firmware making the AVR into an SPI slave (keeping theDataFlash in reset) and tweak the spi_butterfly driver to make it bind tothe driver for your custom SPI-based protocol.

The “USI” controller, using J405, can also be used for a second SPI bus.That would let you talk to the AVR using custom SPI-with-USI firmware,while letting either Linux or the AVR use the DataFlash. There are plentyof spare parport pins to wire this one up, such as:

SignalButterflyParport (DB-25)
SCKJ403.PE4/USCKpin 5/D3
MOSIJ403.PE5/DIpin 6/D4
MISOJ403.PE6/DOpin 12/S5,nPAPEROUT
GNDJ403.GNDpin 22/GND
IRQJ402.PF4pin 10/S6,ACK
GNDJ402.GND(P2)pin 25/GND