esp_ringbuf: Add xRingbufferCreateWithCaps()

This commit adds APIS to create a ring buffer with specific memory caps. The
following APIs have been added:

- xRingbufferGetStaticBuffer()
- xRingbufferCreateWithCaps()
- vRingbufferDeleteWithCaps()
This commit is contained in:
Darian Leung
2023-06-24 21:30:53 +08:00
parent ddb9c1172f
commit 7d983fe5a3
3 changed files with 128 additions and 1 deletions

View File

@@ -513,6 +513,40 @@ void vRingbufferGetInfo(RingbufHandle_t xRingbuffer,
*/
void xRingbufferPrintInfo(RingbufHandle_t xRingbuffer);
/**
* @brief Retrieve the pointers to a statically created ring buffer
*
* @param[in] xRingbuffer Ring buffer
* @param[out] ppucRingbufferStorage Used to return a pointer to the queue's storage area buffer
* @param[out] ppxStaticRingbuffer Used to return a pointer to the queue's data structure buffer
* @return pdTRUE if buffers were retrieved, pdFALSE otherwise.
*/
BaseType_t xRingbufferGetStaticBuffer(RingbufHandle_t xRingbuffer, uint8_t **ppucRingbufferStorage, StaticRingbuffer_t **ppxStaticRingbuffer);
/**
* @brief Creates a ring buffer with specific memory capabilities
*
* This function is similar to xRingbufferCreate(), except that it allows the
* memory allocated for the ring buffer to have specific capabilities (e.g.,
* MALLOC_CAP_INTERNAL).
*
* @note A queue created using this function must only be deleted using
* vRingbufferDeleteWithCaps()
* @param[in] xBufferSize Size of the buffer in bytes
* @param[in] xBufferType Type of ring buffer, see documentation.
* @param[in] uxMemoryCaps Memory capabilities of the queue's memory (see
* esp_heap_caps.h)
* @return Handle to the created ring buffer or NULL on failure.
*/
RingbufHandle_t xRingbufferCreateWithCaps(size_t xBufferSize, RingbufferType_t xBufferType, UBaseType_t uxMemoryCaps);
/**
* @brief Deletes a ring buffer previously created using xRingbufferCreateWithCaps()
*
* @param xRingbuffer Ring buffer
*/
void vRingbufferDeleteWithCaps(RingbufHandle_t xRingbuffer);
#ifdef __cplusplus
}
#endif