From 4ac7c1b66e11d318601c537dd34c3b8a96ca0301 Mon Sep 17 00:00:00 2001 From: follower Date: Sat, 3 Nov 2007 11:52:37 +0000 Subject: [PATCH] For Arduino we don't want to re-configure the SPI each time as we assume it's configured elsewhere. We also only want to touch the chip select pin unlike the original driver code. git-svn-id: svn+ssh://oldsvn/home/mlalondesvn/svn/cral@43 3ee9b42a-b53c-0410-a25e-f0b6218d5d5b --- branches/follower/wiz810mj/src/lib/w5100.c | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/branches/follower/wiz810mj/src/lib/w5100.c b/branches/follower/wiz810mj/src/lib/w5100.c index 1e4b59d..ab55c49 100644 --- a/branches/follower/wiz810mj/src/lib/w5100.c +++ b/branches/follower/wiz810mj/src/lib/w5100.c @@ -81,6 +81,7 @@ uint8 IINCHIP_WRITE(uint16 addr,uint8 data) #elif (__DEF_IINCHIP_BUS__ == __DEF_IINCHIP_SPI_MODE__) //SPI MODE I/F IINCHIP_ISR_DISABLE(); +#ifndef __ARDUINO__ DDRB = 0x07; // MISO=input, etc.=output // PB3(MISO), PB2(MOSI), PB1(SCK), PB0(/SS) PORTB = 0x01; // CS=1, waiting for SPI start @@ -88,6 +89,9 @@ uint8 IINCHIP_WRITE(uint16 addr,uint8 data) SPSR = 0x01; // SPI2X=0 PORTB = 0x00; // CS=0, SPI start +#else + PORTB = PORTB & ~CS_PIN; // CS=0, SPI start +#endif // ifndef __ARDUINO__ SPDR = 0xF0; while((SPSR&0x80)==0x00); SPDR = (uint8)((addr & 0xFF00) >> 8); @@ -96,8 +100,12 @@ uint8 IINCHIP_WRITE(uint16 addr,uint8 data) while((SPSR&0x80)==0x00); SPDR = data; while((SPSR&0x80)==0x00); +#ifndef __ARDUINO__ PORTB = 0x01; // SPI end // CS=1, waiting for SPI start +#else + PORTB = PORTB | CS_PIN; // SPI end +#endif // ifndef __ARDUINO__ IINCHIP_ISR_ENABLE(); #else #error "unknown bus type" @@ -129,6 +137,7 @@ uint8 IINCHIP_READ(uint16 addr) #elif (__DEF_IINCHIP_BUS__ == __DEF_IINCHIP_SPI_MODE__) //SPI MODE I/F IINCHIP_ISR_DISABLE(); +#ifndef __ARDUINO__ DDRB = 0x07; // MISO=input, etc.=output // PB3(MISO), PB2(MOSI), PB1(SCK), PB0(/SS) PORTB = 0x01; // CS=1, waiting for SPI start @@ -136,6 +145,9 @@ uint8 IINCHIP_READ(uint16 addr) SPSR = 0x01; // SPI2X=0 PORTB = 0x00; // CS=0, SPI start +#else + PORTB = PORTB & ~CS_PIN; // CS=0, SPI start +#endif // ifndef __ARDUINO__ SPDR = 0x0F; while((SPSR&0x80)==0x00); SPDR = (uint8)((addr & 0xFF00) >> 8); @@ -145,8 +157,12 @@ uint8 IINCHIP_READ(uint16 addr) SPDR = 0x00; // write dummy data while((SPSR&0x80)==0x00); data = SPDR; // read data +#ifndef __ARDUINO__ PORTB = 0x01; // SPI end // CS=1, waiting for SPI start +#else + PORTB = PORTB | CS_PIN; // SPI end +#endif // ifndef __ARDUINO__ IINCHIP_ISR_ENABLE(); #else #error "unknown bus type" @@ -178,6 +194,7 @@ uint16 wiz_write_buf(uint16 addr,uint8* buf,uint16 len) for(ii=0;ii> 8); @@ -193,8 +213,12 @@ uint16 wiz_write_buf(uint16 addr,uint8* buf,uint16 len) while((SPSR&0x80)==0x00); SPDR = buf[ii]; while((SPSR&0x80)==0x00); +#ifndef __ARDUINO__ PORTB = 0x01; // SPI end // CS=1, waiting for SPI start +#else + PORTB = PORTB | CS_PIN; // SPI end +#endif // ifndef __ARDUINO__ } IINCHIP_ISR_ENABLE(); #else @@ -226,6 +250,7 @@ uint16 wiz_read_buf(uint16 addr, uint8* buf,uint16 len) uint16 iii=0; for (iii=0; iii> 8); @@ -245,8 +273,12 @@ uint16 wiz_read_buf(uint16 addr, uint8* buf,uint16 len) while((SPSR&0x80)==0x00); buf[iii]=SPDR; // read data //} +#ifndef __ARDUINO__ PORTB = 0x01; // SPI end // CS=1, waiting for SPI start +#else + PORTB = PORTB | CS_PIN; // SPI end +#endif // ifndef __ARDUINO__ } IINCHIP_ISR_ENABLE(); #else