![]() |
flexPTP 1.0
An IEEE 1588 PTP implementation designed for microcontrollers
|
This module implements a circular buffer that is used for accepting and omitting received and to be transmissed packets in a controlled way. The implementation does not rely on any OS features, will not block. More...
Go to the source code of this file.
Data Structures | |
struct | PtpCircBuf |
"Ring" buffer for PTP-messages. More... | |
Functions | |
void | ptp_circ_buf_init (PtpCircBuf *pCircBuf, RawPtpMessage *pMsgPool, uint8_t n) |
RawPtpMessage * | ptp_circ_buf_alloc (PtpCircBuf *pCircBuf) |
int | ptp_circ_buf_commit (PtpCircBuf *pCircBuf) |
void | ptp_circ_buf_free (PtpCircBuf *pCircBuf) |
RawPtpMessage * | ptp_circ_buf_get (PtpCircBuf *pCircBuf, uint8_t idx) |
This module implements a circular buffer that is used for accepting and omitting received and to be transmissed packets in a controlled way. The implementation does not rely on any OS features, will not block.
Definition in file ptp_raw_msg_circbuf.h.
RawPtpMessage * ptp_circ_buf_alloc | ( | PtpCircBuf * | pCircBuf | ) |
Allocate an available buffer area from the circular buffer.
pCircBuf | pointer to an existing PtpCircBuf object |
Definition at line 12 of file ptp_raw_msg_circbuf.c.
int ptp_circ_buf_commit | ( | PtpCircBuf * | pCircBuf | ) |
Commit last allocation, claim the first available area. The first available area can be obtained through ptp_circ_buf_alloc().
pCircBuf | pointer to an existing PtpCircBuf object |
Definition at line 22 of file ptp_raw_msg_circbuf.c.
void ptp_circ_buf_free | ( | PtpCircBuf * | pCircBuf | ) |
Release the oldest allocation.
pCircBuf | pointer to an existing PtpCircBuf object |
Definition at line 33 of file ptp_raw_msg_circbuf.c.
RawPtpMessage * ptp_circ_buf_get | ( | PtpCircBuf * | pCircBuf, |
uint8_t | idx | ||
) |
Peek an allocated area by index. Read the circular buffer like it was an array.
pCircBuf | pointer to an existing PtpCircBuf object |
idx | index of the allocation |
Definition at line 39 of file ptp_raw_msg_circbuf.c.
void ptp_circ_buf_init | ( | PtpCircBuf * | pCircBuf, |
RawPtpMessage * | pMsgPool, | ||
uint8_t | n | ||
) |
Initialize circular buffer.
pCircBuf | pointer to an empty (non-initialized) PtpCircBuf object |
pMsgPool | pointer to an allocated pool that supports holding at least n full PTP messages |
n | number of supported elements |
Definition at line 3 of file ptp_raw_msg_circbuf.c.