Skip to content

Commit

Permalink
Merge remote-tracking branch 'mlafauci/wifishield-bugfix' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed Mar 20, 2013
2 parents 42f2b23 + 9c30c73 commit 1b0bff6
Show file tree
Hide file tree
Showing 9 changed files with 15,861 additions and 15,775 deletions.
Binary file modified hardware/arduino/firmwares/wifishield/wifiHD/Release/wifiHD.elf
Binary file not shown.
31,413 changes: 15,734 additions & 15,679 deletions hardware/arduino/firmwares/wifishield/wifiHD/Release/wifiHD.hex

Large diffs are not rendered by default.

42 changes: 27 additions & 15 deletions hardware/arduino/firmwares/wifishield/wifiHD/src/ard_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,8 @@ int write_stream(volatile avr32_spi_t *spi, const char *stream, uint16_t len)
{
uint16_t _len = 0;
unsigned short dummy=0;
bool streamExit = false;

do {
if (*stream == END_CMD)
streamExit = true;

//SIGN1_DN();
if (spi_write(spi, *stream) == SPI_ERROR_TIMEOUT)
{
Expand All @@ -350,16 +346,7 @@ int write_stream(volatile avr32_spi_t *spi, const char *stream, uint16_t len)
spi_read(spi,&dummy);
}
//SIGN1_UP();
}while ((!streamExit)&&(_len <= len));

if (!streamExit)
{
#ifdef _SPI_STATS_
statSpi.wrongFrame++;
statSpi.lastError = SPI_ERROR_ARGUMENT;
#endif
return SPI_ERROR_ARGUMENT;
}
}while (_len < len);
return SPI_OK;
}

Expand Down Expand Up @@ -1640,6 +1627,7 @@ inline int spi_slaveReceiveInt(volatile avr32_spi_t *spi)
int index = 0;
int err = SPI_OK;
state = SPI_CMD_INPUT;
bool endOfFrame = false;

do {
unsigned int timeout = SPI_TIMEOUT;
Expand Down Expand Up @@ -1680,7 +1668,31 @@ inline int spi_slaveReceiveInt(volatile avr32_spi_t *spi)
err = SPI_ERROR_OVERRUN_AND_MODE_FAULT;
break;
}
} while (_receiveBuffer[index - 1] != END_CMD);

if (_receiveBuffer[index - 1] == END_CMD)
{
int8_t numParams = 0;
int idx = PARAM_LEN_POS+1;
bool islen16bit = _receiveBuffer[CMD_POS] & DATA_FLAG;
if (index >= idx)
{
numParams = _receiveBuffer[PARAM_LEN_POS];
while (((index-1) > idx)&&(numParams>0))
{
if (islen16bit)
idx += (_receiveBuffer[idx]<<8) + _receiveBuffer[idx+1]+2;
else
idx += _receiveBuffer[idx]+1;
--numParams;
}
if (((index-1) == idx) && (numParams == 0))
endOfFrame = true;
}
if (!endOfFrame){
WARN("Wrong termination index:%d nParam:%d idx:%d 16bit:%d\n", index, numParams, idx, islen16bit);
}
}
} while (!endOfFrame);
return err;
}

Expand Down
Loading

0 comments on commit 1b0bff6

Please sign in to comment.