arch/z80/src/ez80/ez80_spi.c: Fix a poorly constructed loop that would lead to hangs.

This commit is contained in:
Gregory Nutt 2019-06-18 09:28:13 -06:00
parent 4bfa6fe511
commit ad0181a6d4

View File

@ -369,28 +369,26 @@ static int spi_transfer(uint8_t chout, FAR uint8_t *chin)
uint8_t response; uint8_t response;
int ret; int ret;
/* Send the byte, repeating if some error occurs */ /* Send the byte */
for (; ; ) outp(EZ80_SPI_TSR, chout);
/* Wait for the device to be ready to accept another byte */
ret = spi_waitspif();
if (ret < 0)
{ {
outp(EZ80_SPI_TSR, chout); spierr("ERROR: spi_waitspif returned %d\n", ret);
return ret;
/* Wait for the device to be ready to accept another byte */
ret = spi_waitspif();
if (ret < 0)
{
spierr("ERROR: spi_waitspif returned %d\n", ret);
return ret;
}
response = inp(EZ80_SPI_RBR);
if (chin != NULL)
{
*chin = response;
return OK;
}
} }
response = inp(EZ80_SPI_RBR);
if (chin != NULL)
{
*chin = response;
}
return OK;
} }
/**************************************************************************** /****************************************************************************