Lines Matching +full:bt +full:- +full:hci +full:- +full:spi +full:- +full:slave
1 /* spi.c - SPI based Bluetooth driver */
8 * SPDX-License-Identifier: Apache-2.0
13 #include <zephyr/drivers/spi.h>
17 #include <zephyr/bluetooth/hci.h>
47 /* Max SPI buffer length for transceive operations.
50 * required by the SPI slave, as the legacy spi_transceive requires both RX/TX
52 * slave device used (e.g. nRF5X max buffer length for SPIS is 255).
54 #define SPI_MAX_MSG_LEN 255 /* As defined by X-NUCLEO-IDB04A1 BSP */
62 #define MAX_MTU (SPI_MAX_MSG_LEN - H4_HDR_SIZE - BT_L2CAP_HDR_SIZE - BT_HCI_ACL_HDR_SIZE)
66 be transmitted across this HCI link
156 return -EINVAL; in bt_spi_get_header()
234 LOG_ERR("Unknown BT buf type %d", msg[0]); in bt_spi_rx_buf_construct()
244 struct bt_spi_data *hci = dev->data; in bt_spi_rx_thread() local
261 /* Wait for SPI bus to be available */ in bt_spi_rx_thread()
273 /* Consider increasing controller-data-delay-us in bt_spi_rx_thread()
276 LOG_DBG("Controller not ready for SPI transaction " in bt_spi_rx_thread()
291 LOG_HEXDUMP_DBG(rxmsg, size, "SPI RX"); in bt_spi_rx_thread()
293 /* Construct net_buf from SPI data */ in bt_spi_rx_thread()
296 /* Handle the received HCI data */ in bt_spi_rx_thread()
297 hci->recv(dev, buf); in bt_spi_rx_thread()
313 if (buf->len >= SPI_MAX_MSG_LEN) { in bt_spi_send()
314 LOG_ERR("Message too long (%d)", buf->len); in bt_spi_send()
315 return -EINVAL; in bt_spi_send()
318 /* Wait for SPI bus to be available */ in bt_spi_send()
331 return -EINVAL; in bt_spi_send()
335 size = MIN(buf->len, size); in bt_spi_send()
337 if (size < buf->len) { in bt_spi_send()
340 ret = -ECANCELED; in bt_spi_send()
348 ret = bt_spi_transceive(buf->data, size, in bt_spi_send()
353 /* Consider increasing controller-data-delay-us in bt_spi_send()
356 LOG_DBG("Controller not ready for SPI transaction of %d bytes", size); in bt_spi_send()
367 LOG_HEXDUMP_DBG(buf->data, buf->len, "SPI TX"); in bt_spi_send()
377 struct bt_spi_data *hci = dev->data; in bt_spi_open() local
386 /* Configure IRQ pin and the IRQ call-back/handler */ in bt_spi_open()
404 hci->recv = recv; in bt_spi_open()
434 LOG_ERR("SPI device not ready"); in bt_spi_init()
435 return -ENODEV; in bt_spi_init()
440 return -ENODEV; in bt_spi_init()
445 return -ENODEV; in bt_spi_init()
448 LOG_DBG("BT SPI initialized"); in bt_spi_init()