X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=firmware%2Fapps%2Fspi%2Fspi.c;h=e07cdb544a43d8a8674eb51162bf4bc2f478e095;hb=6d6a522d3adf0ddd18d30f24fd6bba0cc3547041;hp=12eaf60c1d995f612e2a57f91ac69adae755e3e9;hpb=d96bdf017938c586c4eff9e9dd981005f1af7dbe;p=goodfet diff --git a/firmware/apps/spi/spi.c b/firmware/apps/spi/spi.c index 12eaf60..e07cdb5 100644 --- a/firmware/apps/spi/spi.c +++ b/firmware/apps/spi/spi.c @@ -14,6 +14,28 @@ #include "spi.h" +//! Handles a monitor command. +void spi_handle_fn( uint8_t const app, + uint8_t const verb, + uint32_t const len); + +// define the spi app's app_t +app_t const spi_app = { + + /* app number */ + SPI, + + /* handle fn */ + spi_handle_fn, + + /* name */ + "SPI", + + /* desc */ + "\tThe SPI app handles the SPI bus protocol, turning\n" + "\tyour GoodFET into a USB-to-SPI adapter.\n" +}; + //This could be more accurate. //Does it ever need to be? #define SPISPEED 0 @@ -49,9 +71,9 @@ unsigned char spitrans8(unsigned char byte){ CLRMOSI; byte <<= 1; - SPIDELAY(100); + //SPIDELAY(100); SETCLK; - SPIDELAY(100); + //SPIDELAY(100); /* read MISO on trailing edge */ byte |= READMISO; @@ -238,13 +260,12 @@ void em260_wake(){ } //! Handle an EM260 exchange. void spi_rw_em260(u8 app, u8 verb, u32 len){ - static int state=0; unsigned long i; u8 lastin; P4DIR=0; //TODO ASAP remove P4 references. P4OUT=0xFF; - P4REN=0xFF; + //P4REN=0xFF; //See GoodFETEM260.py for details. //The EM260 requires that the host wait for the client. @@ -254,11 +275,8 @@ void spi_rw_em260(u8 app, u8 verb, u32 len){ debugstr("Detected HOST_INT."); */ - //if(!state++) - //if(state++&1) em260_wake(); - em260woken: SETMOSI; //Autodetected SPI mode. CLRSS; //Drop !SS to begin transaction. @@ -266,8 +284,9 @@ void spi_rw_em260(u8 app, u8 verb, u32 len){ for(i=0;i