diff --git a/Makefile b/Makefile index 126c309..22dade5 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ TARGET = f407ve_hs_uart DEBUG = 1 # optimization OPT = -Og - +CXXSTD = -std=c++17 ####################################### # paths @@ -172,7 +172,7 @@ CC_INCLUDES = \ ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections CFLAGS = $(MCU) $(COMMON_DEFS) $(C_DEFS) $(COMMON_INCLUDES) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections -CXXFLAGS = $(MCU) $(COMMON_DEFS) $(CC_DEFS) $(COMMON_INCLUDES) $(CC_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections +CXXFLAGS = $(MCU) $(COMMON_DEFS) $(CC_DEFS) $(COMMON_INCLUDES) $(CC_INCLUDES) $(OPT) $(CXXSTD) -Wall -fdata-sections -ffunction-sections ifeq ($(DEBUG), 1) CFLAGS += -g -gdwarf-2 diff --git a/app/platform/dma_ll.h b/app/platform/dma_ll.h index a39ab1c..f17125a 100644 --- a/app/platform/dma_ll.h +++ b/app/platform/dma_ll.h @@ -1,6 +1,6 @@ #ifndef __PLATFORM_DMA_LL_H_INCLUDED #define __PLATFORM_DMA_LL_H_INCLUDED -#include "dma.h" +#include "stm32f4xx_ll_dma.h" #endif // __PLATFORM_DMA_LL_H_INCLUDED diff --git a/lib/dma_helper.c b/lib/dma_helper.c index 8a4b30b..45e69ae 100644 --- a/lib/dma_helper.c +++ b/lib/dma_helper.c @@ -25,18 +25,18 @@ volatile uint32_t* GetIcfReg(DMA_TypeDef *dma, uint32_t stream) uint32_t GetFeMask(uint32_t stream) { - static const uint32_t masks[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 }; - return masks[stream]; + return feMasks[stream]; } uint32_t GetDmeMask(uint32_t stream) { - static const uint32_t teMasks[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 }; - return teMasks[stream]; + return dmeMasks[stream]; } uint32_t GetTeMask(uint32_t stream) @@ -49,10 +49,10 @@ uint32_t GetTeMask(uint32_t stream) uint32_t GetHtMask(uint32_t stream) { - static const uint32_t teMasks[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 }; - return teMasks[stream]; + return htMasks[stream]; } uint32_t GetTcMask(uint32_t stream) diff --git a/lib/ll_dmahelper.cpp b/lib/ll_dmahelper.cpp new file mode 100644 index 0000000..24ea882 --- /dev/null +++ b/lib/ll_dmahelper.cpp @@ -0,0 +1,26 @@ +/* + * ll_dmahelper.cpp + * + * Created on: Oct 25, 2019 + * Author: abody + */ + +#include + +namespace f4ll { + +static const uint32_t 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}; +static const uint32_t 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}; +static const uint32_t 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}; +static const uint32_t 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}; +static const uint32_t 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 */ diff --git a/lib/ll_dmahelper.h b/lib/ll_dmahelper.h new file mode 100644 index 0000000..eaf7bbf --- /dev/null +++ b/lib/ll_dmahelper.h @@ -0,0 +1,46 @@ +/* + * ll_dmahelper.h + * + * Created on: Oct 25, 2019 + * Author: abody + */ + +#ifndef LL_DMAHELPER_H_ +#define LL_DMAHELPER_H_ + +#include +#include + +namespace f4ll { + +class LL_DmaHelper { +public: + LL_DmaHelper(DMA_TypeDef *dma, uint32_t stream); + ~LL_DmaHelper() = delete; + + inline DMA_TypeDef* GetDMA() { return m_dma; } + inline uint32_t GetStream() { return m_stream; } + inline volatile uint32_t* GetIsReg() { return m_isReg; } + inline volatile uint32_t* GetIcfReg() { return m_ifcReg; } + inline uint32_t GetFeMask() { return m_FEMasks[m_stream]; } + inline uint32_t GetDmeMask() { return m_DMEMasks[m_stream]; } + inline uint32_t GetTeMask() { return m_TEMasks[m_stream]; } + inline uint32_t GetHtMask() { return m_HTMasks[m_stream]; } + inline uint32_t GetTcMask() { 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_ */