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

#include <ll_dmahelper.h>

namespace f4ll {

const uint32_t LL_DmaHelper::m_FEMasks[8]  = {DMA_LISR_FEIF0,  DMA_LISR_FEIF1,  DMA_LISR_FEIF2,  DMA_LISR_FEIF3,  DMA_HISR_FEIF4,  DMA_HISR_FEIF5,  DMA_HISR_FEIF6,  DMA_HISR_FEIF7};
const uint32_t LL_DmaHelper::m_DMEMasks[8] = {DMA_LISR_DMEIF0, DMA_LISR_DMEIF1, DMA_LISR_DMEIF2, DMA_LISR_DMEIF3, DMA_HISR_DMEIF4, DMA_HISR_DMEIF5, DMA_HISR_DMEIF6, DMA_HISR_DMEIF7};
const uint32_t LL_DmaHelper::m_TEMasks[8]  = {DMA_LISR_TEIF0,  DMA_LISR_TEIF1,  DMA_LISR_TEIF2,  DMA_LISR_TEIF3,  DMA_HISR_TEIF4,  DMA_HISR_TEIF5,  DMA_HISR_TEIF6,  DMA_HISR_TEIF7};
const uint32_t LL_DmaHelper::m_HTMasks[8]  = {DMA_LISR_HTIF0,  DMA_LISR_HTIF1,  DMA_LISR_HTIF2,  DMA_LISR_HTIF3,  DMA_HISR_HTIF4,  DMA_HISR_HTIF5,  DMA_HISR_HTIF6,  DMA_HISR_HTIF7};
const uint32_t LL_DmaHelper::m_TCMasks[8]  = {DMA_LISR_TCIF0,  DMA_LISR_TCIF1,  DMA_LISR_TCIF2,  DMA_LISR_TCIF3,  DMA_HISR_TCIF4,  DMA_HISR_TCIF5,  DMA_HISR_TCIF6,  DMA_HISR_TCIF7};

LL_DmaHelper::LL_DmaHelper(DMA_TypeDef *dma, uint32_t stream)
: m_dma(dma)
, m_stream(stream)
, m_isReg((dma == DMA1) ? ((m_stream < LL_DMA_STREAM_4) ? &DMA1->LISR : &DMA1->HISR) : ((m_stream < LL_DMA_STREAM_4) ? &DMA2->LISR : &DMA2->HISR))
, m_ifcReg((dma == DMA1) ? ((m_stream < LL_DMA_STREAM_4) ? &DMA1->LIFCR : &DMA1->HIFCR) : ((m_stream < LL_DMA_STREAM_4) ? &DMA2->LIFCR : &DMA2->HIFCR))
{
}

} /* namespace f4ll */
