/*
 * ll_dmahelper.h
 *
 *  Created on: Oct 25, 2019
 *      Author: abody
 */

#ifndef LL_DMAHELPER_H_
#define LL_DMAHELPER_H_

#include <inttypes.h>
#include <platform/dma_ll.h>

namespace f4ll {

class LL_DmaHelper {
public:
	LL_DmaHelper(DMA_TypeDef *dma, uint32_t stream);
	LL_DmaHelper(LL_DmaHelper const &base) = default;

	inline DMA_TypeDef* GetDma() const          { return m_dma; }
	inline uint32_t GetStream() const           { return m_stream; }
	inline volatile uint32_t* GetIsReg() const 	{ return m_isReg; }
	inline volatile uint32_t* GetIcfReg() const { return m_ifcReg; }
	inline uint32_t GetFeMask() const           { return m_FEMasks[m_stream]; }
	inline uint32_t GetDmeMask() const          { return m_DMEMasks[m_stream]; }
	inline uint32_t GetTeMask() const           { return m_TEMasks[m_stream]; }
	inline uint32_t GetHtMask() const           { return m_HTMasks[m_stream]; }
	inline uint32_t GetTcMask() const           { return m_TCMasks[m_stream]; }

private:
	DMA_TypeDef			*m_dma;
	uint32_t 			m_stream;
	volatile uint32_t	*m_isReg;
	volatile uint32_t	*m_ifcReg;

	static const uint32_t m_FEMasks[8];
	static const uint32_t m_DMEMasks[8];
	static const uint32_t m_TEMasks[8];
	static const uint32_t m_HTMasks[8];
	static const uint32_t m_TCMasks[8];
};

} /* namespace f4ll */

#endif /* LL_DMAHELPER_H_ */
