Zephyr API Documentation 4.3.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
USB buffer macros and definitions

USB buffer macros and definitions. More...

Macros

#define USB_BUF_ALIGN   USB_PRIV_BUFALIGN
 Buffer alignment required by the UDC driver.
#define USB_BUF_GRANULARITY   USB_PRIV_BUFGRANULARITY
 Buffer granularity required by the UDC driver.
#define USB_BUF_ROUND_UP(size)
 Round up to the granularity required by the UDC driver.
#define USB_STATIC_BUF_DEFINE(name, size)
 Define a UDC driver-compliant static buffer.
#define IS_USB_BUF_ALIGNED(buf)
 Verify that the buffer is aligned as required by the UDC driver.
#define USB_BUF_POOL_VAR_DEFINE(pname, count, size, ud_size, fdestroy)
 Define a new pool for UDC buffers with variable-size payloads.
#define USB_BUF_POOL_DEFINE(pname, count, size, ud_size, fdestroy)
 Define a new pool for UDC buffers based on fixed-size data.
#define UDC_BUF_ALIGN   USB_BUF_ALIGN
 Buffer alignment required by the UDC driver.
#define UDC_BUF_GRANULARITY   USB_BUF_GRANULARITY
 Buffer granularity required by the UDC driver.
#define UDC_ROUND_UP(size)
 Round up to the granularity required by the UDC driver.
#define UDC_STATIC_BUF_DEFINE(name, size)
 Define a UDC driver-compliant static buffer.
#define IS_UDC_ALIGNED(buf)
 Verify that the buffer is aligned as required by the UDC driver.
#define UDC_BUF_POOL_VAR_DEFINE(pname, count, size, ud_size, fdestroy)
 Define a new pool for UDC buffers based on fixed-size data.
#define UDC_BUF_POOL_DEFINE(pname, count, size, ud_size, fdestroy)
 Define a new pool for UDC buffers based on fixed-size data.

Detailed Description

USB buffer macros and definitions.

Since
4.0
Version
0.1.1

Macro Definition Documentation

◆ IS_UDC_ALIGNED

#define IS_UDC_ALIGNED ( buf)

#include <zephyr/drivers/usb/usb_buf.h>

Value:
#define IS_USB_BUF_ALIGNED(buf)
Verify that the buffer is aligned as required by the UDC driver.
Definition usb_buf.h:95

Verify that the buffer is aligned as required by the UDC driver.

See also
IS_UDC_ALIGNED

◆ IS_USB_BUF_ALIGNED

#define IS_USB_BUF_ALIGNED ( buf)

#include <zephyr/drivers/usb/usb_buf.h>

Value:
#define IS_ALIGNED(ptr, align)
Check if ptr is aligned to align alignment.
Definition util.h:313
#define USB_BUF_ALIGN
Buffer alignment required by the UDC driver.
Definition usb_buf.h:67

Verify that the buffer is aligned as required by the UDC driver.

See also
IS_ALIGNED
Parameters
bufBuffer pointer

◆ UDC_BUF_ALIGN

#define UDC_BUF_ALIGN   USB_BUF_ALIGN

#include <zephyr/drivers/usb/usb_buf.h>

Buffer alignment required by the UDC driver.

See also
USB_BUF_ALIGN

◆ UDC_BUF_GRANULARITY

#define UDC_BUF_GRANULARITY   USB_BUF_GRANULARITY

#include <zephyr/drivers/usb/usb_buf.h>

Buffer granularity required by the UDC driver.

See also
USB_BUF_GRANULARITY

◆ UDC_BUF_POOL_DEFINE

#define UDC_BUF_POOL_DEFINE ( pname,
count,
size,
ud_size,
fdestroy )

#include <zephyr/drivers/usb/usb_buf.h>

Value:
USB_BUF_POOL_DEFINE(pname, count, size, ud_size, fdestroy)
#define USB_BUF_POOL_DEFINE(pname, count, size, ud_size, fdestroy)
Define a new pool for UDC buffers based on fixed-size data.
Definition usb_buf.h:159

Define a new pool for UDC buffers based on fixed-size data.

See also
USB_BUF_POOL_DEFINE

◆ UDC_BUF_POOL_VAR_DEFINE

#define UDC_BUF_POOL_VAR_DEFINE ( pname,
count,
size,
ud_size,
fdestroy )

#include <zephyr/drivers/usb/usb_buf.h>

Value:
USB_BUF_POOL_VAR_DEFINE(pname, count, size, ud_size, fdestroy)
#define USB_BUF_POOL_VAR_DEFINE(pname, count, size, ud_size, fdestroy)
Define a new pool for UDC buffers with variable-size payloads.
Definition usb_buf.h:132

Define a new pool for UDC buffers based on fixed-size data.

See also
USB_BUF_POOL_VAR_DEFINE

◆ UDC_ROUND_UP

#define UDC_ROUND_UP ( size)

#include <zephyr/drivers/usb/usb_buf.h>

Value:
#define USB_BUF_ROUND_UP(size)
Round up to the granularity required by the UDC driver.
Definition usb_buf.h:73

Round up to the granularity required by the UDC driver.

See also
USB_BUF_ROUND_UP

◆ UDC_STATIC_BUF_DEFINE

#define UDC_STATIC_BUF_DEFINE ( name,
size )

#include <zephyr/drivers/usb/usb_buf.h>

Value:
#define USB_STATIC_BUF_DEFINE(name, size)
Define a UDC driver-compliant static buffer.
Definition usb_buf.h:84

Define a UDC driver-compliant static buffer.

See also
USB_STATIC_BUF_DEFINE

◆ USB_BUF_ALIGN

#define USB_BUF_ALIGN   USB_PRIV_BUFALIGN

#include <zephyr/drivers/usb/usb_buf.h>

Buffer alignment required by the UDC driver.

◆ USB_BUF_GRANULARITY

#define USB_BUF_GRANULARITY   USB_PRIV_BUFGRANULARITY

#include <zephyr/drivers/usb/usb_buf.h>

Buffer granularity required by the UDC driver.

◆ USB_BUF_POOL_DEFINE

#define USB_BUF_POOL_DEFINE ( pname,
count,
size,
ud_size,
fdestroy )

#include <zephyr/drivers/usb/usb_buf.h>

Value:
_NET_BUF_ARRAY_DEFINE(pname, count, ud_size); \
BUILD_ASSERT((USB_BUF_GRANULARITY) % (USB_BUF_ALIGN) == 0, \
"Code assumes granurality is multiple of alignment"); \
static uint8_t USB_PRIV_BUFSECTION __aligned(USB_BUF_ALIGN) \
net_buf_data_##pname[count][USB_BUF_ROUND_UP(size)]; \
static const struct net_buf_pool_fixed net_buf_fixed_##pname = { \
.data_pool = (uint8_t *)net_buf_data_##pname, \
}; \
static const struct net_buf_data_alloc net_buf_fixed_alloc_##pname = { \
.cb = &net_buf_fixed_cb, \
.alloc_data = (void *)&net_buf_fixed_##pname, \
.max_alloc_size = USB_BUF_ROUND_UP(size), \
}; \
static STRUCT_SECTION_ITERABLE(net_buf_pool, pname) = \
NET_BUF_POOL_INITIALIZER(pname, &net_buf_fixed_alloc_##pname, \
_net_buf_##pname, count, ud_size, \
fdestroy)
#define STRUCT_SECTION_ITERABLE(struct_type, varname)
Defines a new element for an iterable section.
Definition iterable_sections.h:216
#define USB_BUF_GRANULARITY
Buffer granularity required by the UDC driver.
Definition usb_buf.h:70
__UINT8_TYPE__ uint8_t
Definition stdint.h:88

Define a new pool for UDC buffers based on fixed-size data.

This macro is similar to NET_BUF_POOL_DEFINE, but provides buffers with alignment and granularity suitable for use by UDC driver.

See also
NET_BUF_POOL_DEFINE
Parameters
pnameName of the pool variable.
countNumber of buffers in the pool.
sizeMaximum data payload per buffer.
ud_sizeUser data space to reserve per buffer.
fdestroyOptional destroy callback when buffer is freed.

◆ USB_BUF_POOL_VAR_DEFINE

#define USB_BUF_POOL_VAR_DEFINE ( pname,
count,
size,
ud_size,
fdestroy )

#include <zephyr/drivers/usb/usb_buf.h>

Value:
_NET_BUF_ARRAY_DEFINE(pname, count, ud_size); \
USB_BUF_K_HEAP_DEFINE(net_buf_mem_pool_##pname, size); \
static const struct net_buf_data_alloc net_buf_data_alloc_##pname = { \
.cb = &net_buf_dma_cb, \
.alloc_data = &net_buf_mem_pool_##pname, \
.max_alloc_size = 0, \
}; \
NET_BUF_POOL_INITIALIZER(pname, &net_buf_data_alloc_##pname, \
_net_buf_##pname, count, ud_size, \
fdestroy)
Network buffer pool representation.
Definition net_buf.h:1079

Define a new pool for UDC buffers with variable-size payloads.

This macro is similar to NET_BUF_POOL_VAR_DEFINE, but provides buffers with alignment and granularity suitable for use by UDC driver.

See also
NET_BUF_POOL_VAR_DEFINE
Parameters
pnameName of the pool variable.
countNumber of buffers in the pool.
sizeMaximum data payload per buffer.
ud_sizeUser data space to reserve per buffer.
fdestroyOptional destroy callback when buffer is freed.

◆ USB_BUF_ROUND_UP

#define USB_BUF_ROUND_UP ( size)

#include <zephyr/drivers/usb/usb_buf.h>

Value:
ROUND_UP(size, USB_PRIV_BUFGRANULARITY)
#define ROUND_UP(x, align)
Value of x rounded up to the next multiple of align.
Definition util.h:318

Round up to the granularity required by the UDC driver.

◆ USB_STATIC_BUF_DEFINE

#define USB_STATIC_BUF_DEFINE ( name,
size )

#include <zephyr/drivers/usb/usb_buf.h>

Value:
static uint8_t USB_PRIV_BUFSECTION __aligned(USB_BUF_ALIGN) \
name[USB_BUF_ROUND_UP(size)];

Define a UDC driver-compliant static buffer.

This macro should be used if the application defines its own buffers to be used for USB transfers.

Parameters
nameBuffer name
sizeBuffer size