15#ifndef ZEPHYR_INCLUDE_DRIVERS_BLUETOOTH_H_
16#define ZEPHYR_INCLUDE_DRIVERS_BLUETOOTH_H_
68#define BT_DT_HCI_QUIRK_OR(node_id, prop, idx) \
69 UTIL_CAT(BT_HCI_QUIRK_, DT_STRING_UPPER_TOKEN_BY_IDX(node_id, prop, idx))
70#define BT_DT_HCI_QUIRKS_GET(node_id) COND_CODE_1(DT_NODE_HAS_PROP(node_id, bt_hci_quirks), \
71 (DT_FOREACH_PROP_ELEM_SEP(node_id, \
76#define BT_DT_HCI_QUIRKS_INST_GET(inst) BT_DT_HCI_QUIRKS_GET(DT_DRV_INST(inst))
78#define BT_DT_HCI_NAME_GET(node_id) DT_PROP_OR(node_id, bt_hci_name, "HCI")
79#define BT_DT_HCI_NAME_INST_GET(inst) BT_DT_HCI_NAME_GET(DT_DRV_INST(inst))
82#define BT_PRIV_HCI_BUS_DEFAULT (0)
83#define BT_DT_HCI_BUS_GET(node_id) DT_ENUM_IDX_OR(node_id, bt_hci_bus, BT_PRIV_HCI_BUS_DEFAULT)
85#define BT_DT_HCI_BUS_INST_GET(inst) BT_DT_HCI_BUS_GET(DT_DRV_INST(inst))
104#define BT_DT_HCI_DRIVER_CONFIG_GET(node_id) \
106 .quirks = (uint32_t)BT_DT_HCI_QUIRKS_GET(node_id), \
117#define BT_DT_HCI_DRIVER_CONFIG_INST_GET(inst) \
118 BT_DT_HCI_DRIVER_CONFIG_GET(DT_DRV_INST(inst))
184#if defined(CONFIG_BT_HCI_SETUP) || defined(__DOXYGEN__)
218 if (data->
recv == NULL) {
223 return data->
recv(dev, buf);
266 if (data->
recv != NULL) {
296 if (api->
close == NULL) {
300 err = api->
close(dev);
332#if defined(CONFIG_BT_HCI_SETUP) || defined(__DOXYGEN__)
349 if (api->
setup == NULL) {
353 return api->
setup(dev, params);
Bluetooth device address definitions and utilities.
Bluetooth data buffer API.
#define DEVICE_API_GET(_class, _dev)
Expands to the pointer of a device's API for a given class.
Definition device.h:1425
struct net_buf * bt_hci_evt_create(uint8_t evt, uint8_t len)
Allocate an HCI event buffer.
struct net_buf * bt_hci_cmd_complete_create(uint16_t op, uint8_t plen)
Allocate an HCI Command Complete event buffer.
struct net_buf * bt_hci_cmd_status_create(uint16_t op, uint8_t status)
Allocate an HCI Command Status event buffer.
int bt_hci_transport_setup(const struct device *dev)
Setup the HCI transport, which usually means to reset the Bluetooth IC.
int bt_hci_transport_teardown(const struct device *dev)
Teardown the HCI transport.
int(* bt_hci_api_send_t)(const struct device *dev, struct net_buf *buf)
Callback API to send an HCI buffer to the controller.
Definition bluetooth.h:159
int(* bt_hci_recv_t)(const struct device *dev, struct net_buf *buf)
Deliver HCI data from the controller to the host.
Definition bluetooth.h:130
int(* bt_hci_api_close_t)(const struct device *dev)
Callback API to close the HCI transport.
Definition bluetooth.h:153
int(* bt_hci_api_setup_t)(const struct device *dev, const struct bt_hci_setup_params *param)
Callback API for HCI vendor-specific setup.
Definition bluetooth.h:165
int(* bt_hci_api_open_t)(const struct device *dev)
Callback API to open the HCI transport.
Definition bluetooth.h:147
static void bt_hci_recv(const struct device *dev, struct net_buf *buf)
Deliver an HCI packet from the driver.
Definition bluetooth.h:235
static int bt_hci_setup(const struct device *dev, struct bt_hci_setup_params *params)
HCI vendor-specific setup.
Definition bluetooth.h:345
static int bt_hci_send(const struct device *dev, struct net_buf *buf)
Send HCI buffer to controller.
Definition bluetooth.h:327
static int bt_hci_recv_err(const struct device *dev, struct net_buf *buf)
Deliver an HCI packet from the driver.
Definition bluetooth.h:214
static int bt_hci_open(const struct device *dev, bt_hci_recv_t recv)
Open the HCI transport.
Definition bluetooth.h:261
static int bt_hci_close(const struct device *dev)
Close the HCI transport.
Definition bluetooth.h:290
@ BT_HCI_QUIRK_NO_AUTO_DLE
Definition bluetooth.h:65
@ BT_HCI_QUIRK_NO_RESET
Definition bluetooth.h:51
void net_buf_unref(struct net_buf *buf)
Decrements the reference count of a buffer.
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition util_macro.h:44
#define ENOSYS
Function not implemented.
Definition errno.h:82
#define EALREADY
Operation already in progress.
Definition errno.h:104
#define ENOTCONN
Socket is not connected.
Definition errno.h:112
ssize_t recv(int sock, void *buf, size_t max_len, int flags)
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Bluetooth Device Address.
Definition addr.h:40
<span class="mlabel">Driver Operations</span> Bluetooth HCI driver operations
Definition bluetooth.h:171
bt_hci_api_close_t close
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition bluetooth.h:179
bt_hci_api_send_t send
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition bluetooth.h:183
bt_hci_api_open_t open
<span class="op-badge op-req" title="This operation MUST be implemented by the driver....
Definition bluetooth.h:175
bt_hci_api_setup_t setup
<span class="op-badge op-opt" title="This operation MAY optionally be implemented by the driver....
Definition bluetooth.h:189
Common Bluetooth HCI driver configuration.
Definition bluetooth.h:94
uint32_t quirks
Quirks for this HCI device instance.
Definition bluetooth.h:96
Common Bluetooth HCI driver data.
Definition bluetooth.h:138
bt_hci_recv_t recv
Callback for the driver to deliver data received from the controller to the host.
Definition bluetooth.h:140
Definition bluetooth.h:41
bt_addr_t public_addr
The public identity address to give to the controller.
Definition bluetooth.h:46
Runtime device structure (in ROM) per driver instance.
Definition device.h:513
void * data
Address of the device instance private data.
Definition device.h:523
Network buffer representation.
Definition net_buf.h:1015
uint16_t len
Length of the data behind the data pointer.
Definition net_buf.h:1107