Lines Matching +full:cs +full:- +full:setup +full:- +full:time
1 /* hci_spi_st.c - STMicroelectronics HCI SPI Bluetooth driver */
7 * SPDX-License-Identifier: Apache-2.0
65 #define MAX_MTU (SPI_MAX_MSG_LEN - H4_HDR_SIZE - BT_L2CAP_HDR_SIZE - BT_HCI_ACL_HDR_SIZE)
126 return -ENOTSUP; in bluenrg_bt_reset()
138 /* Give firmware some time to read the IRQ high */ in bluenrg_bt_reset()
210 /* On BlueNRG-MS, host is expected to read */
236 return -EINVAL; in bt_spi_get_header()
247 /* Make sure CS is raised before a new attempt */ in bt_spi_get_header()
248 gpio_pin_set_dt(&bus.config.cs.gpio, 0); in bt_spi_get_header()
257 attempts--; in bt_spi_get_header()
297 /* To make sure we have a minimum delay from previous release cs */ in bt_spi_get_header()
301 return -EINVAL; in bt_spi_get_header()
307 /* Perform a zero byte SPI transaction to acquire the SPI lock and lower CS in bt_spi_get_header()
313 /* Wait up to a maximum time of 100 ms */ in bt_spi_get_header()
316 return -EIO; in bt_spi_get_header()
342 return -ENOBUFS; in bt_spi_send_aci_config()
362 const bt_addr_t *addr = ¶ms->public_addr; in bt_spi_bluenrg_setup()
372 addr->val, sizeof(addr->val)); in bt_spi_bluenrg_setup()
401 net_buf_add_mem(buf, msg, MIN(size, len - buf->len)); in bt_spi_rx_buf_construct()
402 if (buf->len >= len) { in bt_spi_rx_buf_construct()
405 return -EINPROGRESS; in bt_spi_rx_buf_construct()
416 if (sys_le16_to_cpu(evt->len) > 0xff) { in bt_spi_rx_buf_construct()
417 return -ENOMEM; in bt_spi_rx_buf_construct()
420 memmove(msg + (1 + sizeof(*evt2)), msg + (1 + sizeof(*evt)), evt2->len); in bt_spi_rx_buf_construct()
429 return -ECANCELED; in bt_spi_rx_buf_construct()
443 return -ENOMEM; in bt_spi_rx_buf_construct()
451 return -ENOMEM; in bt_spi_rx_buf_construct()
454 size = size - 1; in bt_spi_rx_buf_construct()
458 ret = -EINPROGRESS; in bt_spi_rx_buf_construct()
469 return -ENOMEM; in bt_spi_rx_buf_construct()
483 return -ENOMEM; in bt_spi_rx_buf_construct()
488 return -ENOMEM; in bt_spi_rx_buf_construct()
495 return -ENOTSUP; in bt_spi_rx_buf_construct()
505 struct bt_spi_data *hci = dev->data; in bt_spi_rx_thread()
549 hci->recv(dev, buf); in bt_spi_rx_thread()
567 if (buf->len >= SPI_MAX_MSG_LEN) { in bt_spi_send()
568 LOG_ERR("Message too long (%d)", buf->len); in bt_spi_send()
569 return -EINVAL; in bt_spi_send()
586 return -EINVAL; in bt_spi_send()
591 data_ptr = buf->data; in bt_spi_send()
592 remaining_bytes = buf->len; in bt_spi_send()
602 ret = -ECANCELED; in bt_spi_send()
610 remaining_bytes -= size; in bt_spi_send()
623 LOG_HEXDUMP_DBG(buf->data, buf->len, "SPI TX"); in bt_spi_send()
633 if (bt_spi_get_cmd(buf->data) == BT_HCI_OP_RESET) { in bt_spi_send()
644 struct bt_spi_data *hci = dev->data; in bt_spi_open()
653 /* Configure IRQ pin and the IRQ call-back/handler */ in bt_spi_open()
671 hci->recv = recv; in bt_spi_open()
698 .setup = bt_spi_bluenrg_setup,
709 return -ENODEV; in bt_spi_init()
714 return -ENODEV; in bt_spi_init()
719 return -ENODEV; in bt_spi_init()