mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
freertos/ringbuf: Added an API xRingbufferCreateNoSplit()
This is a wrapper API for creating a Ring Buffer, which ensures that the ringbuffer can hold the given number of items, each item being of the same given length. Signed-off-by: Piyush Shah <piyush@espressif.com>
This commit is contained in:
parent
3c199b0de6
commit
91968ef464
@ -77,6 +77,19 @@ typedef enum {
|
||||
*/
|
||||
RingbufHandle_t xRingbufferCreate(size_t buf_length, ringbuf_type_t type);
|
||||
|
||||
/**
|
||||
* @brief Create a ring buffer of type RINGBUF_TYPE_NOSPLIT for a fixed item_size
|
||||
*
|
||||
* This API is similar to xRingbufferCreate(), but it will internally allocate
|
||||
* additional space for the headers.
|
||||
*
|
||||
* @param item_size Size of each item to be put into the ring buffer
|
||||
* @param num_item Maximum number of items the buffer needs to hold simultaneously
|
||||
*
|
||||
* @return A RingbufHandle_t handle to the created ringbuffer, or NULL in case of error.
|
||||
*/
|
||||
RingbufHandle_t xRingbufferCreateNoSplit(size_t item_size, size_t num_item);
|
||||
|
||||
/**
|
||||
* @brief Delete a ring buffer
|
||||
*
|
||||
|
@ -541,6 +541,12 @@ err:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
RingbufHandle_t xRingbufferCreateNoSplit(size_t item_size, size_t num_item)
|
||||
{
|
||||
size_t aligned_size = (item_size+3)&~3;
|
||||
return xRingbufferCreate((aligned_size + sizeof(buf_entry_hdr_t)) * num_item, RINGBUF_TYPE_NOSPLIT);
|
||||
}
|
||||
|
||||
void vRingbufferDelete(RingbufHandle_t ringbuf) {
|
||||
ringbuf_t *rb=(ringbuf_t *)ringbuf;
|
||||
if (rb) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user