Zephyr API 3.6.99
Loading...
Searching...
No Matches
Buffer macros and definitions used in USB device support

Buffer macros and definitions used in USB device support . More...

Macros

#define UDC_BUF_ALIGN   Z_UDC_BUF_ALIGN
 Buffer alignment required by the UDC driver.
 
#define UDC_BUF_GRANULARITY   Z_UDC_BUF_GRANULARITY
 Buffer 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 with variable-size payloads.
 
#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

Buffer macros and definitions used in USB device support .

Macro Definition Documentation

◆ IS_UDC_ALIGNED

#define IS_UDC_ALIGNED ( buf)

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

Value:
#define IS_ALIGNED(ptr, align)
Check if ptr is aligned to align alignment.
Definition util.h:324
#define UDC_BUF_ALIGN
Buffer alignment required by the UDC driver.
Definition udc_buf.h:45

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   Z_UDC_BUF_ALIGN

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

Buffer alignment required by the UDC driver.

◆ UDC_BUF_GRANULARITY

#define UDC_BUF_GRANULARITY   Z_UDC_BUF_GRANULARITY

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

Buffer granularity required by the UDC driver.

◆ UDC_BUF_POOL_DEFINE

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

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

Value:
_NET_BUF_ARRAY_DEFINE(pname, count, ud_size); \
BUILD_ASSERT((UDC_BUF_GRANULARITY) % (UDC_BUF_ALIGN) == 0, \
"Code assumes granurality is multiple of alignment"); \
static uint8_t __nocache __aligned(UDC_BUF_ALIGN) \
net_buf_data_##pname[count][ROUND_UP(size, UDC_BUF_GRANULARITY)];\
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 = ROUND_UP(size, UDC_BUF_GRANULARITY), \
}; \
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 ROUND_UP(x, align)
Value of x rounded up to the next multiple of align.
Definition util.h:329
#define UDC_BUF_GRANULARITY
Buffer granularity required by the UDC driver.
Definition udc_buf.h:48
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Network buffer pool representation.
Definition net_buf.h:1078

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.

◆ UDC_BUF_POOL_VAR_DEFINE

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

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

Value:
_NET_BUF_ARRAY_DEFINE(pname, count, ud_size); \
UDC_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)

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.

◆ UDC_STATIC_BUF_DEFINE

#define UDC_STATIC_BUF_DEFINE ( name,
size )

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

Value:
static uint8_t __aligned(UDC_BUF_ALIGN) name[ROUND_UP(size, UDC_BUF_GRANULARITY)];

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