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:
parent
f27d8eef39
commit
2569e2e8d1
1 changed files with 6 additions and 2 deletions
|
@ -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 */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue