assembly prolog based mocking
This commit is contained in:
parent
833d604b2f
commit
c2f84b23ee
2 changed files with 31 additions and 31 deletions
19
dmahelper.c
19
dmahelper.c
|
@ -5,8 +5,11 @@
|
|||
* Author: abody
|
||||
*/
|
||||
#include <f4ll_c/dmahelper.h>
|
||||
#ifndef MOCKABLE
|
||||
#define MOCKABLE(x)
|
||||
#endif
|
||||
|
||||
volatile uint32_t* MOCKME(Dma_GetIsReg)(DMA_TypeDef *dma, uint32_t stream)
|
||||
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;
|
||||
|
@ -15,7 +18,7 @@ volatile uint32_t* MOCKME(Dma_GetIsReg)(DMA_TypeDef *dma, uint32_t stream)
|
|||
}
|
||||
|
||||
|
||||
volatile uint32_t* MOCKME(Dma_GetIfcReg)(DMA_TypeDef *dma, uint32_t stream)
|
||||
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;
|
||||
|
@ -23,7 +26,7 @@ volatile uint32_t* MOCKME(Dma_GetIfcReg)(DMA_TypeDef *dma, uint32_t stream)
|
|||
return (stream < LL_DMA_STREAM_4) ? &DMA2->LIFCR : &DMA2->HIFCR;
|
||||
}
|
||||
|
||||
uint32_t MOCKME(Dma_GetFeMask)(uint32_t stream)
|
||||
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
|
||||
|
@ -31,7 +34,7 @@ uint32_t MOCKME(Dma_GetFeMask)(uint32_t stream)
|
|||
return feMasks[stream];
|
||||
}
|
||||
|
||||
uint32_t MOCKME(Dma_GetDmeMask)(uint32_t 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
|
||||
|
@ -39,7 +42,7 @@ uint32_t MOCKME(Dma_GetDmeMask)(uint32_t stream)
|
|||
return dmeMasks[stream];
|
||||
}
|
||||
|
||||
uint32_t MOCKME(Dma_GetTeMask)(uint32_t 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
|
||||
|
@ -47,7 +50,7 @@ uint32_t MOCKME(Dma_GetTeMask)(uint32_t stream)
|
|||
return teMasks[stream];
|
||||
}
|
||||
|
||||
uint32_t MOCKME(Dma_GetHtMask)(uint32_t 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
|
||||
|
@ -55,7 +58,7 @@ uint32_t MOCKME(Dma_GetHtMask)(uint32_t stream)
|
|||
return htMasks[stream];
|
||||
}
|
||||
|
||||
uint32_t MOCKME(Dma_GetTcMask)(uint32_t 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
|
||||
|
@ -64,7 +67,7 @@ uint32_t MOCKME(Dma_GetTcMask)(uint32_t stream)
|
|||
return tcMasks[stream];
|
||||
}
|
||||
|
||||
void MOCKME(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->stream = stream;
|
||||
|
|
43
dmahelper.h
43
dmahelper.h
|
@ -10,11 +10,8 @@
|
|||
#include <inttypes.h>
|
||||
#include <platform/dma_ll.h>
|
||||
|
||||
#ifndef DECLARE_MOCKPTR
|
||||
#define DECLARE_MOCKPTR(...)
|
||||
#endif
|
||||
#ifndef MAKE_MOCKABLE
|
||||
#define MAKE_MOCKABLE(x) x
|
||||
#ifndef DECLARE_MOCK
|
||||
#define DECLARE_MOCK(x)
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -33,25 +30,25 @@ struct dmainfo_t {
|
|||
uint32_t tcMask;
|
||||
};
|
||||
|
||||
#ifdef UNITTEST
|
||||
DECLARE_MOCKPTR(volatile uint32_t*, Dma_GetIsReg, DMA_TypeDef*, uint32_t)
|
||||
DECLARE_MOCKPTR(volatile uint32_t*, Dma_GetIfcReg, DMA_TypeDef*, uint32_t)
|
||||
DECLARE_MOCKPTR(uint32_t, Dma_GetDmeMask, uint32_t)
|
||||
DECLARE_MOCKPTR(uint32_t, Dma_GetTeMask, uint32_t)
|
||||
DECLARE_MOCKPTR(uint32_t, Dma_GetHtMask, uint32_t)
|
||||
DECLARE_MOCKPTR(uint32_t, Dma_GetTcMask, uint32_t)
|
||||
DECLARE_MOCKPTR(uint32_t, Dma_GetFeMask, uint32_t)
|
||||
DECLARE_MOCKPTR(void, Dma_Init, struct dmainfo_t*, DMA_TypeDef*, uint32_t)
|
||||
#endif // UNITTEST
|
||||
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);
|
||||
|
||||
volatile uint32_t* MAKE_MOCKABLE(Dma_GetIsReg)(DMA_TypeDef *dma, uint32_t stream);
|
||||
volatile uint32_t* MAKE_MOCKABLE(Dma_GetIfcReg)(DMA_TypeDef *dma, uint32_t stream);
|
||||
uint32_t MAKE_MOCKABLE(Dma_GetDmeMask)(uint32_t stream);
|
||||
uint32_t MAKE_MOCKABLE(Dma_GetTeMask)(uint32_t stream);
|
||||
uint32_t MAKE_MOCKABLE(Dma_GetHtMask)(uint32_t stream);
|
||||
uint32_t MAKE_MOCKABLE(Dma_GetTcMask)(uint32_t stream);
|
||||
uint32_t MAKE_MOCKABLE(Dma_GetFeMask)(uint32_t stream);
|
||||
void MAKE_MOCKABLE(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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue