Zephyr Project API 4.0.0
A Scalable Open Source RTOS
|
Packed buffer API. More...
Data Structures | |
struct | pbuf_cfg |
Control block of packet buffer. More... | |
struct | pbuf_data |
Data block of the packed buffer. More... | |
struct | pbuf |
Scure packed buffer. More... | |
Macros | |
#define | PBUF_PACKET_LEN_SZ sizeof(uint32_t) |
Size of packet length field. | |
#define | PBUF_MAYBE_CONST const |
#define | PBUF_CFG_INIT(mem_addr, size, dcache_align) |
Macro for configuration initialization. | |
#define | PBUF_HEADER_OVERHEAD(dcache_align) (MAX(dcache_align, _PBUF_IDX_SIZE) + _PBUF_IDX_SIZE) |
Macro calculates memory overhead taken by the header in shared memory. | |
#define | PBUF_DEFINE(name, mem_addr, size, dcache_align) |
Statically define and initialize pbuf. | |
Functions | |
int | pbuf_tx_init (struct pbuf *pb) |
Initialize the Tx packet buffer. | |
int | pbuf_rx_init (struct pbuf *pb) |
Initialize the Rx packet buffer. | |
int | pbuf_write (struct pbuf *pb, const char *buf, uint16_t len) |
Write specified amount of data to the packet buffer. | |
int | pbuf_read (struct pbuf *pb, char *buf, uint16_t len) |
Read specified amount of data from the packet buffer. | |
Packed buffer API.
#define PBUF_CFG_INIT | ( | mem_addr, | |
size, | |||
dcache_align | |||
) |
#include <include/zephyr/ipc/pbuf.h>
Macro for configuration initialization.
It is recommended to use this macro to initialize packed buffer configuration.
mem_addr | Memory address for pbuf. |
size | Size of the memory. |
dcache_align | Data cache alignment. |
#define PBUF_DEFINE | ( | name, | |
mem_addr, | |||
size, | |||
dcache_align | |||
) |
#include <include/zephyr/ipc/pbuf.h>
Statically define and initialize pbuf.
name | Name of the pbuf. |
mem_addr | Memory address for pbuf. |
size | Size of the memory. |
dcache_align | Data cache line size. |
#define PBUF_HEADER_OVERHEAD | ( | dcache_align | ) | (MAX(dcache_align, _PBUF_IDX_SIZE) + _PBUF_IDX_SIZE) |
#include <include/zephyr/ipc/pbuf.h>
Macro calculates memory overhead taken by the header in shared memory.
It contains the read index, write index and padding.
dcache_align | Data cache alignment. |
#define PBUF_MAYBE_CONST const |
#include <include/zephyr/ipc/pbuf.h>
#include <include/zephyr/ipc/pbuf.h>
Size of packet length field.
#include <include/zephyr/ipc/pbuf.h>
Read specified amount of data from the packet buffer.
Single read allows to read the message send by the single write. The provided p buf must be big enough to store the whole message.
pb | A buffer from which data will be read. |
buf | Data pointer to which read data will be written. If NULL, len of stored message is returned. |
len | Number of bytes to be read from the buffer. |
int | Bytes read, negative error code on fail. Bytes to be read, if buf == NULL. -EINVAL, if any of input parameter is incorrect. -ENOMEM, if message can not fit in provided buf. -EAGAIN, if not whole message is ready yet. |
int pbuf_rx_init | ( | struct pbuf * | pb | ) |
#include <include/zephyr/ipc/pbuf.h>
Initialize the Rx packet buffer.
This function initializes the Rx packet buffer. If the configuration is incorrect, the function will return error.
It is recommended to use PBUF_DEFINE macro for build time initialization.
pb | Pointer to the packed buffer containing configuration and data. Configuration has to be fixed before the initialization. |
0 | on success. |
-EINVAL | when the input parameter is incorrect. |
int pbuf_tx_init | ( | struct pbuf * | pb | ) |
#include <include/zephyr/ipc/pbuf.h>
Initialize the Tx packet buffer.
This function initializes the Tx packet buffer based on provided configuration. If the configuration is incorrect, the function will return error.
It is recommended to use PBUF_DEFINE macro for build time initialization.
pb | Pointer to the packed buffer containing configuration and data. Configuration has to be fixed before the initialization. |
0 | on success. |
-EINVAL | when the input parameter is incorrect. |
#include <include/zephyr/ipc/pbuf.h>
Write specified amount of data to the packet buffer.
This function call writes specified amount of data to the packet buffer if the buffer will fit the data.
pb | A buffer to which to write. |
buf | Pointer to the data to be written to the buffer. |
len | Number of bytes to be written to the buffer. Must be positive. |
int | Number of bytes written, negative error code on fail. -EINVAL, if any of input parameter is incorrect. -ENOMEM, if len is bigger than the buffer can fit. |