Zephyr API Documentation
2.7.0-rc2
A Scalable Open Source RTOS
buf.h
Go to the documentation of this file.
1
5
/*
6
* Copyright (c) 2016 Intel Corporation
7
*
8
* SPDX-License-Identifier: Apache-2.0
9
*/
10
11
#ifndef ZEPHYR_INCLUDE_BLUETOOTH_BUF_H_
12
#define ZEPHYR_INCLUDE_BLUETOOTH_BUF_H_
13
21
#include <
zephyr/types.h
>
22
#include <
net/buf.h
>
23
#include <
bluetooth/hci.h
>
24
#include <
sys/util.h
>
25
26
#ifdef __cplusplus
27
extern
"C"
{
28
#endif
29
31
enum
bt_buf_type
{
33
BT_BUF_CMD
,
35
BT_BUF_EVT
,
37
BT_BUF_ACL_OUT
,
39
BT_BUF_ACL_IN
,
41
BT_BUF_ISO_OUT
,
43
BT_BUF_ISO_IN
,
45
BT_BUF_H4
,
46
};
47
49
struct
bt_buf_data
{
50
uint8_t
type
;
51
};
52
53
#if defined(CONFIG_BT_HCI_RAW)
54
#define BT_BUF_RESERVE MAX(CONFIG_BT_HCI_RESERVE, CONFIG_BT_HCI_RAW_RESERVE)
55
#else
56
#define BT_BUF_RESERVE CONFIG_BT_HCI_RESERVE
57
#endif
58
60
#define BT_BUF_SIZE(size) (BT_BUF_RESERVE + (size))
61
63
#define BT_BUF_ACL_SIZE(size) BT_BUF_SIZE(BT_HCI_ACL_HDR_SIZE + (size))
64
66
#define BT_BUF_EVT_SIZE(size) BT_BUF_SIZE(BT_HCI_EVT_HDR_SIZE + (size))
67
69
#define BT_BUF_CMD_SIZE(size) BT_BUF_SIZE(BT_HCI_CMD_HDR_SIZE + (size))
70
72
#define BT_BUF_ACL_RX_SIZE BT_BUF_ACL_SIZE(CONFIG_BT_BUF_ACL_RX_SIZE)
73
75
#define BT_BUF_EVT_RX_SIZE BT_BUF_EVT_SIZE(CONFIG_BT_BUF_EVT_RX_SIZE)
76
78
#define BT_BUF_RX_SIZE (MAX(BT_BUF_ACL_RX_SIZE, BT_BUF_EVT_RX_SIZE))
79
81
#define BT_BUF_CMD_TX_SIZE BT_BUF_CMD_SIZE(CONFIG_BT_BUF_CMD_TX_SIZE)
82
94
struct
net_buf
*
bt_buf_get_rx
(
enum
bt_buf_type
type,
k_timeout_t
timeout
);
95
109
struct
net_buf
*
bt_buf_get_tx
(
enum
bt_buf_type
type,
k_timeout_t
timeout
,
110
const
void
*
data
,
size_t
size
);
111
121
struct
net_buf
*
bt_buf_get_cmd_complete
(
k_timeout_t
timeout
);
122
134
struct
net_buf
*
bt_buf_get_evt
(
uint8_t
evt,
bool
discardable,
k_timeout_t
timeout
);
135
141
static
inline
void
bt_buf_set_type
(
struct
net_buf
*buf,
enum
bt_buf_type
type)
142
{
143
((
struct
bt_buf_data
*)
net_buf_user_data
(buf))->
type
=
type
;
144
}
145
152
static
inline
enum
bt_buf_type
bt_buf_get_type
(
struct
net_buf
*buf)
153
{
154
return
(
enum
bt_buf_type
)((
struct
bt_buf_data
*)
net_buf_user_data
(buf))
155
->
type
;
156
}
157
162
#ifdef __cplusplus
163
}
164
#endif
165
166
#endif
/* ZEPHYR_INCLUDE_BLUETOOTH_BUF_H_ */
timeout
ZTEST_BMEM int timeout
Definition:
main.c:31
bt_buf_get_type
static enum bt_buf_type bt_buf_get_type(struct net_buf *buf)
Definition:
buf.h:152
bt_buf_get_rx
struct net_buf * bt_buf_get_rx(enum bt_buf_type type, k_timeout_t timeout)
bt_buf_get_tx
struct net_buf * bt_buf_get_tx(enum bt_buf_type type, k_timeout_t timeout, const void *data, size_t size)
bt_buf_get_evt
struct net_buf * bt_buf_get_evt(uint8_t evt, bool discardable, k_timeout_t timeout)
bt_buf_get_cmd_complete
struct net_buf * bt_buf_get_cmd_complete(k_timeout_t timeout)
bt_buf_set_type
static void bt_buf_set_type(struct net_buf *buf, enum bt_buf_type type)
Definition:
buf.h:141
bt_buf_type
bt_buf_type
Definition:
buf.h:31
BT_BUF_EVT
@ BT_BUF_EVT
Definition:
buf.h:35
BT_BUF_ISO_OUT
@ BT_BUF_ISO_OUT
Definition:
buf.h:41
BT_BUF_ACL_OUT
@ BT_BUF_ACL_OUT
Definition:
buf.h:37
BT_BUF_ISO_IN
@ BT_BUF_ISO_IN
Definition:
buf.h:43
BT_BUF_CMD
@ BT_BUF_CMD
Definition:
buf.h:33
BT_BUF_H4
@ BT_BUF_H4
Definition:
buf.h:45
BT_BUF_ACL_IN
@ BT_BUF_ACL_IN
Definition:
buf.h:39
net_buf_user_data
static void * net_buf_user_data(const struct net_buf *buf)
Get a pointer to the user data of a buffer.
Definition:
buf.h:1445
hci.h
types.h
buf.h
Buffer management.
uint8_t
__UINT8_TYPE__ uint8_t
Definition:
stdint.h:58
bt_buf_data
This is a base type for bt_buf user data.
Definition:
buf.h:49
bt_buf_data::type
uint8_t type
Definition:
buf.h:50
k_timeout_t
Kernel timeout type.
Definition:
sys_clock.h:65
net_buf
Network buffer representation.
Definition:
buf.h:919
net_buf::size
uint16_t size
Definition:
buf.h:950
data
static fdata_t data[2]
Definition:
test_fifo_contexts.c:15
util.h
Misc utilities.
include
bluetooth
buf.h
Generated on Sun Oct 9 2022 09:21:56 for Zephyr API Documentation by
1.9.4