/* * This uses SPI to talk with an "AVR Butterfly", which is a $US20 card * with a battery powered AVR microcontroller and lots of goodies. You * can use GCC to develop firmware for this. * * See Documentation/spi/butterfly.rst for information about how to build * and use this custom parallel port cable.
*/
/* set default clock polarity */ if (value != BITBANG_CS_INACTIVE)
setsck(spi, spi->mode & SPI_CPOL);
/* here, value == "activate or not"; * most PARPORT_CONTROL_* bits are negated, so we must * morph it to value == "bit value to write in control register"
*/ if (spi_cs_bit == PARPORT_CONTROL_INIT)
value = !value;
parport_frob_control(pp->port, spi_cs_bit, value ? spi_cs_bit : 0);
}
/* we only needed to implement one mode here, and choose SPI_MODE_0 */
#define spidelay(X) do { } while (0) /* #define spidelay ndelay */
/* override default partitioning with cmdlinepart */ staticstruct mtd_partition partitions[] = { { /* JFFS2 wants partitions of 4*N blocks for this device, * so sectors 0 and 1 can't be partitions by themselves.
*/
/* nCS for dataflash (this bit is inverted on output) */
parport_frob_control(pp->port, spi_cs_bit, 0);
/* stabilize power with chip in reset (nRESET), and * spi_sck_bit clear (CPOL=0)
*/
pp->lastbyte |= vcc_bits;
parport_write_data(pp->port, pp->lastbyte);
msleep(5);
/* take it out of reset; assume long reset delay */
pp->lastbyte |= butterfly_nreset;
parport_write_data(pp->port, pp->lastbyte);
msleep(100);
/* * Start SPI ... for now, hide that we're two physical busses.
*/
status = spi_bitbang_start(&pp->bitbang); if (status < 0) goto clean2;
/* Bus 1 lets us talk to at45db041b (firmware disables AVR SPI), AVR * (firmware resets at45, acts as spi slave) or neither (we ignore * both, AVR uses AT45). Here we expect firmware for the first option.
*/
/* FIXME this global is ugly ... but, how to quickly get from * the parport to the "struct butterfly" associated with it? * "old school" driver-internal device lists?
*/ if (!butterfly || butterfly->port != p) return;
pp = butterfly;
butterfly = NULL;
/* stop() unregisters child devices too */
spi_bitbang_stop(&pp->bitbang);
/* turn off VCC */
parport_write_data(pp->port, 0);
msleep(10);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.