/** @file dma_mbuf.h * Module handling Direct Memory Access controller's TX functions * * The module provides convenient tools to send data to a peripheral in a * buffered, non-blocking way */ #ifndef _DMA_MBUF_H_ #define _DMA_MBUF_H_ //--includes-------------------------------------------------------------------- #include "dma.h" //--type definitions------------------------------------------------------------ struct DmaMultiBuffer { void** buffers; //list of buffers to write to volatile void* dest; //destination peripheral register uint16_t buffer_size; //size of a single buffer uint16_t byte_index; //index of the current byte in the current buffer uint8_t buffer_nb; //total number of buffers uint8_t free_buffer_nb; //number of buffers not currently used uint8_t buffer_index; //index of the current buffer uint8_t dma_buffer_index; //index of the DMA's current buffer enum DmaPeriph dma; //DMA peripheral, must correspond to peripheral enum DmaChannel channel; //DMA channel, must correspond to peripheral enum DmaConfig config; //DMA config, must correspond to peripheral }; //--functions------------------------------------------------------------------- void dma_mbuf_configure(volatile struct DmaMultiBuffer* buffer, void** buffers, volatile void* dest, uint16_t buffer_size, uint8_t buffer_nb, enum DmaPeriph dma, enum DmaChannel channel, enum DmaConfig config); uint32_t dma_mbuf_write_byte(volatile struct DmaMultiBuffer* buffer, uint8_t byte); void dma_mbuf_refresh(volatile struct DmaMultiBuffer* buffer); #endif //_DMA_MBUF_H_