2020-02-05 23:09:23 +01:00
|
|
|
#ifndef __DMA_RING_BUFFER_H__
|
|
|
|
#define __DMA_RING_BUFFER_H__
|
|
|
|
|
2020-02-09 19:13:37 +01:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stm32f4xx.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
struct dma_ring_buffer {
|
|
|
|
char *data_ptr;
|
|
|
|
size_t buffer_count;
|
|
|
|
DMA_Stream_TypeDef *dma;
|
|
|
|
size_t get_idx;
|
|
|
|
uint8_t base_dma_id;
|
|
|
|
};
|
|
|
|
|
|
|
|
int dma_ring_buffer_initialize(struct dma_ring_buffer *dma_buffer, uint8_t base_dma_id, DMA_Stream_TypeDef *dma_stream, size_t buffer_element_count, char *data_buffer, void *src_reg, uint8_t dma_trigger_channel);
|
|
|
|
int dma_ring_buffer_get_data(struct dma_ring_buffer *buff, const char **data_buff, size_t *len);
|
|
|
|
|
|
|
|
void dma_ring_buffer_stop(struct dma_ring_buffer *buff);
|
|
|
|
|
2020-02-05 23:09:23 +01:00
|
|
|
#endif /* __DMA_RING_BUFFER_H__ */
|
2020-02-09 19:13:37 +01:00
|
|
|
|
|
|
|
|
|
|
|
|