From 4cf3fdb6a6d9a8844481d661e4d4c957c6a2ec87 Mon Sep 17 00:00:00 2001 From: travisutk Date: Sat, 18 Jul 2009 15:54:22 +0000 Subject: [PATCH] SPI Flash writing support. Does not quite behave properly. Maybe the block size isn't negotiable? git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@67 12e2690d-a6be-4b82-a7b7-67c4a43b65c8 --- firmware/apps/spi/spi.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/firmware/apps/spi/spi.c b/firmware/apps/spi/spi.c index 785c476..0a15799 100644 --- a/firmware/apps/spi/spi.c +++ b/firmware/apps/spi/spi.c @@ -69,7 +69,10 @@ unsigned char spitrans8(unsigned char byte){ //! Enable SPI writing void spiflash_wrten(){ P5OUT&=~SS; //Drop !SS to begin transaction. - spitrans8(0x06);//Chip Erase + spitrans8(0x04);//Write Disable + P5OUT|=SS; //Raise !SS to end transaction. + P5OUT&=~SS; //Drop !SS to begin transaction. + spitrans8(0x06);//Write Enable P5OUT|=SS; //Raise !SS to end transaction. } @@ -110,7 +113,15 @@ void spihandle(unsigned char app, P5OUT|=SS; //Raise !SS to end transaction. break; case POKE://Poke up bytes from an SPI Flash ROM. + spiflash_wrten(); + P5OUT&=~SS; //Drop !SS to begin transaction. + spitrans8(0x02); //Poke command. + //First three bytes are address, then data. + for(i=0;i