Zephyr API Documentation  3.6.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
bluetooth.h File Reference

Bluetooth HCI driver API. More...

#include <stdbool.h>
#include <stdint.h>
#include <zephyr/net/buf.h>
#include <zephyr/bluetooth/buf.h>
#include <zephyr/bluetooth/addr.h>
#include <zephyr/bluetooth/hci_vs.h>
#include <zephyr/device.h>

Go to the source code of this file.

Data Structures

struct  bt_hci_setup_params
 
struct  bt_hci_driver_api
 

Macros

#define BT_DT_HCI_QUIRK_OR(node_id, prop, idx)   DT_STRING_TOKEN_BY_IDX(node_id, prop, idx)
 
#define BT_DT_HCI_QUIRKS_GET(node_id)
 
#define BT_DT_HCI_QUIRKS_INST_GET(inst)   BT_DT_HCI_QUIRKS_GET(DT_DRV_INST(inst))
 
#define BT_DT_HCI_NAME_GET(node_id)   DT_PROP_OR(node_id, bt_hci_name, "HCI")
 
#define BT_DT_HCI_NAME_INST_GET(inst)   BT_DT_HCI_NAME_GET(DT_DRV_INST(inst))
 
#define BT_DT_HCI_BUS_GET(node_id)   DT_STRING_TOKEN_OR(node_id, bt_hci_bus, BT_HCI_BUS_VIRTUAL)
 
#define BT_DT_HCI_BUS_INST_GET(inst)   BT_DT_HCI_BUS_GET(DT_DRV_INST(inst))
 

Typedefs

typedef int(* bt_hci_recv_t) (const struct device *dev, struct net_buf *buf)
 

Enumerations

enum  { BT_HCI_QUIRK_NO_RESET = BIT(0) , BT_HCI_QUIRK_NO_AUTO_DLE = BIT(1) }
 
enum  bt_hci_bus {
  BT_HCI_BUS_VIRTUAL = 0 , BT_HCI_BUS_USB = 1 , BT_HCI_BUS_PCCARD = 2 , BT_HCI_BUS_UART = 3 ,
  BT_HCI_BUS_RS232 = 4 , BT_HCI_BUS_PCI = 5 , BT_HCI_BUS_SDIO = 6 , BT_HCI_BUS_SPI = 7 ,
  BT_HCI_BUS_I2C = 8 , BT_HCI_BUS_IPM = 9
}
 Possible values for the 'bus' member of the bt_hci_driver struct. More...
 

Functions

static int bt_hci_open (const struct device *dev, bt_hci_recv_t recv)
 Open the HCI transport.
 
static int bt_hci_close (const struct device *dev)
 Close the HCI transport.
 
static int bt_hci_send (const struct device *dev, struct net_buf *buf)
 Send HCI buffer to controller.
 
static int bt_hci_setup (const struct device *dev, struct bt_hci_setup_params *params)
 HCI vendor-specific setup.
 
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.
 
struct net_bufbt_hci_evt_create (uint8_t evt, uint8_t len)
 Allocate an HCI event buffer.
 
struct net_bufbt_hci_cmd_complete_create (uint16_t op, uint8_t plen)
 Allocate an HCI Command Complete event buffer.
 
struct net_bufbt_hci_cmd_status_create (uint16_t op, uint8_t status)
 Allocate an HCI Command Status event buffer.
 

Detailed Description

Bluetooth HCI driver API.

Copyright (c) 2024 Johan Hedberg

SPDX-License-Identifier: Apache-2.0

Function Documentation

◆ bt_hci_cmd_complete_create()

struct net_buf * bt_hci_cmd_complete_create ( uint16_t  op,
uint8_t  plen 
)

Allocate an HCI Command Complete event buffer.

This function allocates a new buffer for HCI Command Complete event. It is given the OpCode (encoded e.g. using the BT_OP macro) and the total length of the parameters. Upon successful return the buffer is ready to have the parameters encoded into it.

Parameters
opHCI command OpCode.
plenLength of command parameters.
Returns
Newly allocated buffer.

◆ bt_hci_cmd_status_create()

struct net_buf * bt_hci_cmd_status_create ( uint16_t  op,
uint8_t  status 
)

Allocate an HCI Command Status event buffer.

This function allocates a new buffer for HCI Command Status event. It is given the OpCode (encoded e.g. using the BT_OP macro) and the status code. Upon successful return the buffer is ready to have the parameters encoded into it.

Parameters
opHCI command OpCode.
statusStatus code.
Returns
Newly allocated buffer.

◆ bt_hci_evt_create()

struct net_buf * bt_hci_evt_create ( uint8_t  evt,
uint8_t  len 
)

Allocate an HCI event buffer.

This function allocates a new buffer for an HCI event. It is given the event code and the total length of the parameters. Upon successful return the buffer is ready to have the parameters encoded into it.

Parameters
evtHCI event OpCode.
lenLength of event parameters.
Returns
Newly allocated buffer.

◆ bt_hci_transport_setup()

int bt_hci_transport_setup ( const struct device dev)

Setup the HCI transport, which usually means to reset the Bluetooth IC.

Note
A weak version of this function is included in the H4 driver, so defining it is optional per board.
Parameters
devThe device structure for the bus connecting to the IC
Returns
0 on success, negative error value on failure

◆ bt_hci_transport_teardown()

int bt_hci_transport_teardown ( const struct device dev)

Teardown the HCI transport.

Note
A weak version of this function is included in the IPC driver, so defining it is optional. NRF5340 includes support to put network core in reset state.
Parameters
devThe device structure for the bus connecting to the IC
Returns
0 on success, negative error value on faulure