Bluetooth: SPI: retry spi_transceive calls if invalid

spi_transceive can return successfuly even if the data provided by the
slave is invalid, so check if the content is correct and retry until a
valid data is available.

Change-Id: Ia951de391e0b24c5b41eeabfb5c10b056d32b62e
Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
This commit is contained in:
Ricardo Salveti 2017-01-25 23:26:10 -02:00 committed by Johan Hedberg
commit 2569e2e8d1

View file

@ -155,7 +155,9 @@ static void bt_spi_rx_thread(void)
header_slave[STATUS_HEADER_TOREAD] == 0xFF);
size = header_slave[STATUS_HEADER_TOREAD];
spi_transceive(spi_dev, &txmsg, size, &rxmsg, size);
do {
spi_transceive(spi_dev, &txmsg, size, &rxmsg, size);
} while (rxmsg[0] == 0);
#if defined(CONFIG_BLUETOOTH_SPI_BLUENRG)
gpio_pin_write(cs_dev, GPIO_CS_PIN, 1);
@ -251,7 +253,9 @@ static int bt_spi_send(struct net_buf *buf)
(rxmsg[1] | rxmsg[2] | rxmsg[3] | rxmsg[4]) == 0);
/* Transmit the message */
spi_transceive(spi_dev, buf->data, buf->len, rxmsg, buf->len);
do {
spi_transceive(spi_dev, buf->data, buf->len, rxmsg, buf->len);
} while (rxmsg[0] == 0);
#if defined(CONFIG_BLUETOOTH_SPI_BLUENRG)
/* Deselect chip */