f103c8_minimal_ll/f1ll/inc/f1ll/dma_helper.h

50 lines
1.5 KiB
C++

/*
* ll_dmahelper.h
*
* Created on: Oct 25, 2019
* Author: abody
*/
#ifndef LL_DMAHELPER_H_
#define LL_DMAHELPER_H_
#include <inttypes.h>
#include <platform/dma_ll.h>
namespace f1ll
{
class dma_helper
{
public:
dma_helper(DMA_TypeDef *dma, uint32_t channel);
dma_helper(dma_helper const &base) = default;
inline DMA_TypeDef *get_dma() const { return m_dma; }
inline uint32_t get_channel() const { return m_channel; }
inline volatile uint32_t *get_is_reg() const { return m_is_reg; }
inline volatile uint32_t *get_ifc_reg() const { return m_ifc_reg; }
inline uint32_t get_te_mask() const { return m_te_masks[m_channel - 1]; }
inline uint32_t get_ht_mask() const { return m_ht_masks[m_channel - 1]; }
inline uint32_t get_tc_mask() const { return m_tc_masks[m_channel - 1]; }
inline uint32_t get_gi_mask() const { return m_gi_masks[m_channel - 1]; }
inline bool is_enabled_it_te() { return LL_DMA_IsEnabledIT_TE(m_dma, m_channel) != 0; }
inline bool is_enabled_it_ht() { return LL_DMA_IsEnabledIT_HT(m_dma, m_channel) != 0; }
inline bool is_enabled_it_tc() { return LL_DMA_IsEnabledIT_TC(m_dma, m_channel) != 0; }
private:
DMA_TypeDef *m_dma;
uint32_t m_channel;
volatile uint32_t *m_is_reg;
volatile uint32_t *m_ifc_reg;
static const uint32_t m_te_masks[7];
static const uint32_t m_ht_masks[7];
static const uint32_t m_tc_masks[7];
static const uint32_t m_gi_masks[7];
};
} /* namespace f4ll */
#endif /* LL_DMAHELPER_H_ */