subrepo: subdir: "components/f4ll_c" merged: "5d26fdc" upstream: origin: "git@git.pcmuhely.hu:compi/f4ll_c.git" branch: "master" commit: "5d26fdc" git-subrepo: version: "0.4.0" origin: "https://github.com/ingydotnet/git-subrepo" commit: "5d6aba9"
81 lines
2.3 KiB
C
81 lines
2.3 KiB
C
/*
|
|
* dma_helper.c
|
|
*
|
|
* Created on: Sep 18, 2019
|
|
* Author: abody
|
|
*/
|
|
#include <f4ll_c/dmahelper.h>
|
|
#ifndef MOCKABLE
|
|
#define MOCKABLE(x) x
|
|
#endif
|
|
|
|
volatile uint32_t* MOCKABLE(Dma_GetIsReg)(DMA_TypeDef *dma, uint32_t stream)
|
|
{
|
|
if(dma == DMA1)
|
|
return (stream < LL_DMA_STREAM_4) ? &DMA1->LISR : &DMA1->HISR;
|
|
else
|
|
return (stream < LL_DMA_STREAM_4) ? &DMA2->LISR : &DMA2->HISR;
|
|
}
|
|
|
|
|
|
volatile uint32_t* MOCKABLE(Dma_GetIfcReg)(DMA_TypeDef *dma, uint32_t stream)
|
|
{
|
|
if(dma == DMA1)
|
|
return (stream < LL_DMA_STREAM_4) ? &DMA1->LIFCR : &DMA1->HIFCR;
|
|
else
|
|
return (stream < LL_DMA_STREAM_4) ? &DMA2->LIFCR : &DMA2->HIFCR;
|
|
}
|
|
|
|
uint32_t MOCKABLE(Dma_GetFeMask)(uint32_t stream)
|
|
{
|
|
static const uint32_t 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
|
|
};
|
|
return feMasks[stream];
|
|
}
|
|
|
|
uint32_t MOCKABLE(Dma_GetDmeMask)(uint32_t stream)
|
|
{
|
|
static const uint32_t 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
|
|
};
|
|
return dmeMasks[stream];
|
|
}
|
|
|
|
uint32_t MOCKABLE(Dma_GetTeMask)(uint32_t stream)
|
|
{
|
|
static const uint32_t 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
|
|
};
|
|
return teMasks[stream];
|
|
}
|
|
|
|
uint32_t MOCKABLE(Dma_GetHtMask)(uint32_t stream)
|
|
{
|
|
static const uint32_t 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
|
|
};
|
|
return htMasks[stream];
|
|
}
|
|
|
|
uint32_t MOCKABLE(Dma_GetTcMask)(uint32_t stream)
|
|
{
|
|
static const uint32_t 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
|
|
};
|
|
|
|
return tcMasks[stream];
|
|
}
|
|
|
|
void MOCKABLE(Dma_Init)(struct dmainfo_t *info, DMA_TypeDef *dma, uint32_t stream)
|
|
{
|
|
info->dma = dma;
|
|
info->stream = stream;
|
|
info->isReg = Dma_GetIsReg(dma, stream);
|
|
info->ifcReg = Dma_GetIfcReg(dma, stream);
|
|
info->feMask = Dma_GetFeMask(stream);
|
|
info->dmeMask = Dma_GetDmeMask(stream);
|
|
info->teMask = Dma_GetTeMask(stream);
|
|
info->htMask = Dma_GetHtMask(stream);
|
|
info->tcMask = Dma_GetTcMask(stream);
|
|
}
|