prepared dmahelper to push back upstream
This commit is contained in:
parent
17b146c018
commit
4754b65041
2 changed files with 27 additions and 53 deletions
29
dmahelper.c
29
dmahelper.c
|
@ -6,6 +6,10 @@
|
||||||
*/
|
*/
|
||||||
#include <f4ll_c/dmahelper.h>
|
#include <f4ll_c/dmahelper.h>
|
||||||
|
|
||||||
|
#ifndef DEFINE_MOCKPTR
|
||||||
|
#define DEFINE_MOCKPTR(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef UNITTEST
|
#ifdef UNITTEST
|
||||||
DEFINE_MOCKPTR(volatile uint32_t*, Dma_GetIsReg, DMA_TypeDef*, uint32_t)
|
DEFINE_MOCKPTR(volatile uint32_t*, Dma_GetIsReg, DMA_TypeDef*, uint32_t)
|
||||||
DEFINE_MOCKPTR(volatile uint32_t*, Dma_GetIfcReg, DMA_TypeDef*, uint32_t)
|
DEFINE_MOCKPTR(volatile uint32_t*, Dma_GetIfcReg, DMA_TypeDef*, uint32_t)
|
||||||
|
@ -15,18 +19,9 @@ DEFINE_MOCKPTR(uint32_t, Dma_GetHtMask, uint32_t)
|
||||||
DEFINE_MOCKPTR(uint32_t, Dma_GetTcMask, uint32_t)
|
DEFINE_MOCKPTR(uint32_t, Dma_GetTcMask, uint32_t)
|
||||||
DEFINE_MOCKPTR(uint32_t, Dma_GetFeMask, uint32_t)
|
DEFINE_MOCKPTR(uint32_t, Dma_GetFeMask, uint32_t)
|
||||||
DEFINE_MOCKPTR(void, Dma_Init, struct dmainfo_t*, DMA_TypeDef*, uint32_t)
|
DEFINE_MOCKPTR(void, Dma_Init, struct dmainfo_t*, DMA_TypeDef*, uint32_t)
|
||||||
|
|
||||||
#define Dma_GetIsReg(...) Dma_GetIsReg_(__VA_ARGS__)
|
|
||||||
#define Dma_GetIfcReg(...) Dma_GetIfcReg_(__VA_ARGS__)
|
|
||||||
#define Dma_GetDmeMask(...) Dma_GetDmeMask_(__VA_ARGS__)
|
|
||||||
#define Dma_GetTeMask(...) Dma_GetTeMask_(__VA_ARGS__)
|
|
||||||
#define Dma_GetHtMask(...) Dma_GetHtMask_(__VA_ARGS__)
|
|
||||||
#define Dma_GetTcMask(...) Dma_GetTcMask_(__VA_ARGS__)
|
|
||||||
#define Dma_GetFeMask(...) Dma_GetFeMask_(__VA_ARGS__)
|
|
||||||
#define Dma_Init(...) Dma_Init_(__VA_ARGS__)
|
|
||||||
#endif // UNITTEST
|
#endif // UNITTEST
|
||||||
|
|
||||||
volatile uint32_t* Dma_GetIsReg(DMA_TypeDef *dma, uint32_t stream)
|
volatile uint32_t* MOCKABLE(Dma_GetIsReg)(DMA_TypeDef *dma, uint32_t stream)
|
||||||
{
|
{
|
||||||
if(dma == DMA1)
|
if(dma == DMA1)
|
||||||
return (stream < LL_DMA_STREAM_4) ? &DMA1->LISR : &DMA1->HISR;
|
return (stream < LL_DMA_STREAM_4) ? &DMA1->LISR : &DMA1->HISR;
|
||||||
|
@ -34,7 +29,7 @@ volatile uint32_t* Dma_GetIsReg(DMA_TypeDef *dma, uint32_t stream)
|
||||||
return (stream < LL_DMA_STREAM_4) ? &DMA2->LISR : &DMA2->HISR;
|
return (stream < LL_DMA_STREAM_4) ? &DMA2->LISR : &DMA2->HISR;
|
||||||
}
|
}
|
||||||
|
|
||||||
volatile uint32_t* Dma_GetIfcReg(DMA_TypeDef *dma, uint32_t stream)
|
volatile uint32_t* MOCKABLE(Dma_GetIfcReg)(DMA_TypeDef *dma, uint32_t stream)
|
||||||
{
|
{
|
||||||
if(dma == DMA1)
|
if(dma == DMA1)
|
||||||
return (stream < LL_DMA_STREAM_4) ? &DMA1->LIFCR : &DMA1->HIFCR;
|
return (stream < LL_DMA_STREAM_4) ? &DMA1->LIFCR : &DMA1->HIFCR;
|
||||||
|
@ -42,7 +37,7 @@ volatile uint32_t* Dma_GetIfcReg(DMA_TypeDef *dma, uint32_t stream)
|
||||||
return (stream < LL_DMA_STREAM_4) ? &DMA2->LIFCR : &DMA2->HIFCR;
|
return (stream < LL_DMA_STREAM_4) ? &DMA2->LIFCR : &DMA2->HIFCR;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Dma_GetFeMask(uint32_t stream)
|
uint32_t MOCKABLE(Dma_GetFeMask)(uint32_t stream)
|
||||||
{
|
{
|
||||||
static const uint32_t feMasks[8] = {
|
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
|
DMA_LISR_FEIF0, DMA_LISR_FEIF1, DMA_LISR_FEIF2, DMA_LISR_FEIF3, DMA_HISR_FEIF4, DMA_HISR_FEIF5, DMA_HISR_FEIF6, DMA_HISR_FEIF7
|
||||||
|
@ -50,7 +45,7 @@ uint32_t Dma_GetFeMask(uint32_t stream)
|
||||||
return feMasks[stream];
|
return feMasks[stream];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Dma_GetDmeMask(uint32_t stream)
|
uint32_t MOCKABLE(Dma_GetDmeMask)(uint32_t stream)
|
||||||
{
|
{
|
||||||
static const uint32_t dmeMasks[8] = {
|
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
|
DMA_LISR_DMEIF0, DMA_LISR_DMEIF1, DMA_LISR_DMEIF2, DMA_LISR_DMEIF3, DMA_HISR_DMEIF4, DMA_HISR_DMEIF5, DMA_HISR_DMEIF6, DMA_HISR_DMEIF7
|
||||||
|
@ -58,7 +53,7 @@ uint32_t Dma_GetDmeMask(uint32_t stream)
|
||||||
return dmeMasks[stream];
|
return dmeMasks[stream];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Dma_GetTeMask(uint32_t stream)
|
uint32_t MOCKABLE(Dma_GetTeMask)(uint32_t stream)
|
||||||
{
|
{
|
||||||
static const uint32_t teMasks[8] = {
|
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
|
DMA_LISR_TEIF0, DMA_LISR_TEIF1, DMA_LISR_TEIF2, DMA_LISR_TEIF3, DMA_HISR_TEIF4, DMA_HISR_TEIF5, DMA_HISR_TEIF6, DMA_HISR_TEIF7
|
||||||
|
@ -66,7 +61,7 @@ uint32_t Dma_GetTeMask(uint32_t stream)
|
||||||
return teMasks[stream];
|
return teMasks[stream];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Dma_GetHtMask(uint32_t stream)
|
uint32_t MOCKABLE(Dma_GetHtMask)(uint32_t stream)
|
||||||
{
|
{
|
||||||
static const uint32_t htMasks[8] = {
|
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
|
DMA_LISR_HTIF0, DMA_LISR_HTIF1, DMA_LISR_HTIF2, DMA_LISR_HTIF3, DMA_HISR_HTIF4, DMA_HISR_HTIF5, DMA_HISR_HTIF6, DMA_HISR_HTIF7
|
||||||
|
@ -74,7 +69,7 @@ uint32_t Dma_GetHtMask(uint32_t stream)
|
||||||
return htMasks[stream];
|
return htMasks[stream];
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Dma_GetTcMask(uint32_t stream)
|
uint32_t MOCKABLE(Dma_GetTcMask)(uint32_t stream)
|
||||||
{
|
{
|
||||||
static const uint32_t tcMasks[8] = {
|
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
|
DMA_LISR_TCIF0, DMA_LISR_TCIF1, DMA_LISR_TCIF2, DMA_LISR_TCIF3, DMA_HISR_TCIF4, DMA_HISR_TCIF5, DMA_HISR_TCIF6, DMA_HISR_TCIF7
|
||||||
|
@ -83,7 +78,7 @@ uint32_t Dma_GetTcMask(uint32_t stream)
|
||||||
return tcMasks[stream];
|
return tcMasks[stream];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dma_Init(struct dmainfo_t *info, DMA_TypeDef *dma, uint32_t stream)
|
void MOCKABLE(Dma_Init)(struct dmainfo_t *info, DMA_TypeDef *dma, uint32_t stream)
|
||||||
{
|
{
|
||||||
info->dma = dma;
|
info->dma = dma;
|
||||||
info->stream = stream;
|
info->stream = stream;
|
||||||
|
|
51
dmahelper.h
51
dmahelper.h
|
@ -10,6 +10,13 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <platform/dma_ll.h>
|
#include <platform/dma_ll.h>
|
||||||
|
|
||||||
|
#ifndef DECLARE_MOCKPTR
|
||||||
|
#define DECLARE_MOCKPTR(...)
|
||||||
|
#endif
|
||||||
|
#ifndef MOCKABLE
|
||||||
|
#define MOCKABLE(x) x
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@ -26,7 +33,6 @@ struct dmainfo_t {
|
||||||
uint32_t tcMask;
|
uint32_t tcMask;
|
||||||
};
|
};
|
||||||
|
|
||||||
//>>>>>>>>>> MOCK <<<<<<<<<<
|
|
||||||
#ifdef UNITTEST
|
#ifdef UNITTEST
|
||||||
DECLARE_MOCKPTR(volatile uint32_t*, Dma_GetIsReg, DMA_TypeDef*, uint32_t)
|
DECLARE_MOCKPTR(volatile uint32_t*, Dma_GetIsReg, DMA_TypeDef*, uint32_t)
|
||||||
DECLARE_MOCKPTR(volatile uint32_t*, Dma_GetIfcReg, DMA_TypeDef*, uint32_t)
|
DECLARE_MOCKPTR(volatile uint32_t*, Dma_GetIfcReg, DMA_TypeDef*, uint32_t)
|
||||||
|
@ -36,43 +42,16 @@ DECLARE_MOCKPTR(uint32_t, Dma_GetHtMask, uint32_t)
|
||||||
DECLARE_MOCKPTR(uint32_t, Dma_GetTcMask, uint32_t)
|
DECLARE_MOCKPTR(uint32_t, Dma_GetTcMask, uint32_t)
|
||||||
DECLARE_MOCKPTR(uint32_t, Dma_GetFeMask, uint32_t)
|
DECLARE_MOCKPTR(uint32_t, Dma_GetFeMask, uint32_t)
|
||||||
DECLARE_MOCKPTR(void, Dma_Init, struct dmainfo_t*, DMA_TypeDef*, uint32_t)
|
DECLARE_MOCKPTR(void, Dma_Init, struct dmainfo_t*, DMA_TypeDef*, uint32_t)
|
||||||
|
|
||||||
#define Dma_GetIsReg(...) Dma_GetIsReg_(__VA_ARGS__)
|
|
||||||
#define Dma_GetIfcReg(...) Dma_GetIfcReg_(__VA_ARGS__)
|
|
||||||
#define Dma_GetDmeMask(...) Dma_GetDmeMask_(__VA_ARGS__)
|
|
||||||
#define Dma_GetTeMask(...) Dma_GetTeMask_(__VA_ARGS__)
|
|
||||||
#define Dma_GetHtMask(...) Dma_GetHtMask_(__VA_ARGS__)
|
|
||||||
#define Dma_GetTcMask(...) Dma_GetTcMask_(__VA_ARGS__)
|
|
||||||
#define Dma_GetFeMask(...) Dma_GetFeMask_(__VA_ARGS__)
|
|
||||||
#define Dma_Init(...) Dma_Init_(__VA_ARGS__)
|
|
||||||
//#define (...) _(__VA_ARGS__)
|
|
||||||
#endif // UNITTEST
|
#endif // UNITTEST
|
||||||
//>>>>>>>>>> MOCK end <<<<<<<<<<
|
|
||||||
|
|
||||||
//>>>>>> Real Stuff (tm) <<<<<<<<
|
volatile uint32_t* MOCKABLE(Dma_GetIsReg)(DMA_TypeDef *dma, uint32_t stream);
|
||||||
|
volatile uint32_t* MOCKABLE(Dma_GetIfcReg)(DMA_TypeDef *dma, uint32_t stream);
|
||||||
volatile uint32_t* Dma_GetIsReg(DMA_TypeDef *dma, uint32_t stream);
|
uint32_t MOCKABLE(Dma_GetDmeMask)(uint32_t stream);
|
||||||
volatile uint32_t* Dma_GetIfcReg(DMA_TypeDef *dma, uint32_t stream);
|
uint32_t MOCKABLE(Dma_GetTeMask)(uint32_t stream);
|
||||||
uint32_t Dma_GetDmeMask(uint32_t stream);
|
uint32_t MOCKABLE(Dma_GetHtMask)(uint32_t stream);
|
||||||
uint32_t Dma_GetTeMask(uint32_t stream);
|
uint32_t MOCKABLE(Dma_GetTcMask)(uint32_t stream);
|
||||||
uint32_t Dma_GetHtMask(uint32_t stream);
|
uint32_t MOCKABLE(Dma_GetFeMask)(uint32_t stream);
|
||||||
uint32_t Dma_GetTcMask(uint32_t stream);
|
void MOCKABLE(Dma_Init)(struct dmainfo_t *info, DMA_TypeDef *dma, uint32_t stream);
|
||||||
uint32_t Dma_GetFeMask(uint32_t stream);
|
|
||||||
void Dma_Init(struct dmainfo_t *info, DMA_TypeDef *dma, uint32_t stream);
|
|
||||||
|
|
||||||
//>>>>>> Real Stuff (tm) end <<<<<<<<
|
|
||||||
|
|
||||||
//>>>>>>>>>> MOCK <<<<<<<<<<
|
|
||||||
#ifdef UNITTEST
|
|
||||||
#undef Dma_GetIsReg
|
|
||||||
#undef Dma_GetIfcReg
|
|
||||||
#undef Dma_GetDmeMask
|
|
||||||
#undef Dma_GetHtMask
|
|
||||||
#undef Dma_GetTcMask
|
|
||||||
#undef Dma_GetFeMask
|
|
||||||
#undef Dma_Init
|
|
||||||
#endif // UNITTEST
|
|
||||||
//>>>>>>>>>> MOCK end <<<<<<<<<<
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue