diff options
author | Ricardo Salveti <ricardo.salveti@linaro.org> | 2017-01-25 23:19:44 -0200 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2017-01-28 08:43:41 +0200 |
commit | f27d8eef395ef79ec0c20ac1a2967402f292293d (patch) | |
tree | 9e6b0c5895dce6974c2c41f31101eb5028227b22 /drivers | |
parent | 8227c72c47bc201a70e30db40d9fc4deadbe4198 (diff) |
Bluetooth: SPI: switch to a single SPI transfer when receiving
Change-Id: I27b504032080bddf7ebc88ef4812a0e7eab691c6
Signed-off-by: Ricardo Salveti <ricardo.salveti@linaro.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/bluetooth/hci/spi.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/bluetooth/hci/spi.c b/drivers/bluetooth/hci/spi.c index babbe4c84..c7377614c 100644 --- a/drivers/bluetooth/hci/spi.c +++ b/drivers/bluetooth/hci/spi.c @@ -58,6 +58,7 @@ #define SPI_MAX_MSG_LEN 255 /* As defined by X-NUCLEO-IDB04A1 BSP */ static uint8_t rxmsg[SPI_MAX_MSG_LEN]; +static uint8_t txmsg[SPI_MAX_MSG_LEN]; static struct device *spi_dev; #if defined(CONFIG_BLUETOOTH_SPI_BLUENRG) @@ -134,8 +135,10 @@ static void bt_spi_rx_thread(void) struct net_buf *buf; uint8_t header_master[5] = { SPI_READ, 0x00, 0x00, 0x00, 0x00 }; uint8_t header_slave[5]; - uint8_t dummy = 0xFF, size, i; struct bt_hci_acl_hdr acl_hdr; + uint8_t size; + + memset(&txmsg, 0xFF, SPI_MAX_MSG_LEN); while (true) { k_sem_take(&sem_request, K_FOREVER); @@ -152,10 +155,7 @@ static void bt_spi_rx_thread(void) header_slave[STATUS_HEADER_TOREAD] == 0xFF); size = header_slave[STATUS_HEADER_TOREAD]; - - for (i = 0; i < size; i++) { - spi_transceive(spi_dev, &dummy, 1, &rxmsg[i], 1); - } + spi_transceive(spi_dev, &txmsg, size, &rxmsg, size); #if defined(CONFIG_BLUETOOTH_SPI_BLUENRG) gpio_pin_write(cs_dev, GPIO_CS_PIN, 1); |