I am experimenting with ring buffers for transmitting SPI data between tasks.
I first create a contiguous, DMA-capable and 32-bit aligned memory region; then use that memory region to create a ring buffer.
Code: Select all
StaticRingbuffer_t *buffer_struct = (StaticRingbuffer_t *)heap_caps_malloc(sizeof(StaticRingbuffer_t), MALLOC_CAP_DEFAULT);
uint8_t *buffer_storage= (uint8_t *)heap_caps_malloc(sizeof(uint8_t)*1024, MALLOC_CAP_DMA);
// Then create ring buffers with manually allocated memory
afe1_ring_buffer_handle = xRingbufferCreateStatic(1024, RINGBUF_TYPE_BYTEBUF, buffer_storage, buffer_struct);
if (afe1_ring_buffer_handle == NULL)
ESP_LOGE(TAG, "Failed to create ring buffer\n");
Code: Select all
BaseType_t ret = xRingbufferSendAcquire(in_args->ringBufHandle, &fifo_buffer, 3*128, portMAX_DELAY);
Best,
Simon