/*
 * dma_helper.h
 *
 *  Created on: Sep 18, 2019
 *      Author: abody
 */

#ifndef DMA_HELPER_H_
#define DMA_HELPER_H_
#include <inttypes.h>
#include <platform/dma_ll.h>

#ifndef DECLARE_MOCK
#define DECLARE_MOCK(x)
#endif

#ifdef __cplusplus
extern "C" {
#endif

struct dmainfo_t {
	DMA_TypeDef			*dma;
	uint32_t 			stream;
	volatile uint32_t	*isReg;
	volatile uint32_t	*ifcReg;
	uint32_t			feMask;
	uint32_t			dmeMask;
	uint32_t			teMask;
	uint32_t			htMask;
	uint32_t			tcMask;
};

volatile uint32_t* Dma_GetIsReg(DMA_TypeDef *dma, uint32_t stream);
volatile uint32_t* Dma_GetIfcReg(DMA_TypeDef *dma, uint32_t stream);
uint32_t Dma_GetDmeMask(uint32_t stream);
uint32_t Dma_GetTeMask(uint32_t stream);
uint32_t Dma_GetHtMask(uint32_t stream);
uint32_t Dma_GetTcMask(uint32_t stream);
uint32_t Dma_GetFeMask(uint32_t stream);
void Dma_Init(struct dmainfo_t *info, DMA_TypeDef *dma, uint32_t stream);

#ifdef UNITTEST
DECLARE_MOCK(Dma_GetIsReg);
DECLARE_MOCK(Dma_GetIfcReg);
DECLARE_MOCK(Dma_GetDmeMask);
DECLARE_MOCK(Dma_GetTeMask);
DECLARE_MOCK(Dma_GetHtMask);
DECLARE_MOCK(Dma_GetTcMask);
DECLARE_MOCK(Dma_GetFeMask);
DECLARE_MOCK(Dma_Init);
#endif

#ifdef __cplusplus
}
#endif

#endif /* DMA_HELPER_H_ */
