distortos  v0.7.0
object-oriented C++ RTOS for microcontrollers
STM32-DMAv2-DmaPeripheral.hpp
Go to the documentation of this file.
1 
12 #ifndef SOURCE_CHIP_STM32_PERIPHERALS_DMAV2_INCLUDE_DISTORTOS_CHIP_STM32_DMAV2_DMAPERIPHERAL_HPP_
13 #define SOURCE_CHIP_STM32_PERIPHERALS_DMAV2_INCLUDE_DISTORTOS_CHIP_STM32_DMAV2_DMAPERIPHERAL_HPP_
14 
16 
17 namespace distortos
18 {
19 
20 namespace chip
21 {
22 
25 {
26 public:
27 
34  constexpr explicit DmaPeripheral(const uintptr_t dmaBase) :
35  dmaBase_{dmaBase}
36  {
37 
38  }
39 
44  uint32_t readHisr() const
45  {
46  return getDma().HISR;
47  }
48 
53  uint32_t readLisr() const
54  {
55  return getDma().LISR;
56  }
57 
64  void writeHifcr(const uint32_t hifcr) const
65  {
66  getDma().HIFCR = hifcr;
67  }
68 
75  void writeLifcr(const uint32_t lifcr) const
76  {
77  getDma().LIFCR = lifcr;
78  }
79 
80 private:
81 
86  DMA_TypeDef& getDma() const
87  {
88  return *reinterpret_cast<DMA_TypeDef*>(dmaBase_);
89  }
90 
92  uintptr_t dmaBase_;
93 };
94 
95 } // namespace chip
96 
97 } // namespace distortos
98 
99 #endif // SOURCE_CHIP_STM32_PERIPHERALS_DMAV2_INCLUDE_DISTORTOS_CHIP_STM32_DMAV2_DMAPERIPHERAL_HPP_
void writeLifcr(const uint32_t lifcr) const
Writes value to LIFCR register.
Definition: STM32-DMAv2-DmaPeripheral.hpp:75
constexpr DmaPeripheral(const uintptr_t dmaBase)
DmaPeripheral's constructor.
Definition: STM32-DMAv2-DmaPeripheral.hpp:34
DMA_TypeDef & getDma() const
Definition: STM32-DMAv2-DmaPeripheral.hpp:86
CMSIS proxy header for STM32F4.
DmaPeripheral class is a raw DMA peripheral for DMAv2 in STM32.
Definition: STM32-DMAv2-DmaPeripheral.hpp:24
Top-level namespace of distortos project.
Definition: buttons.hpp:33
uint32_t readHisr() const
Definition: STM32-DMAv2-DmaPeripheral.hpp:44
uintptr_t dmaBase_
base address of DMA peripheral
Definition: STM32-DMAv2-DmaPeripheral.hpp:92
void writeHifcr(const uint32_t hifcr) const
Writes value to HIFCR register.
Definition: STM32-DMAv2-DmaPeripheral.hpp:64
uint32_t readLisr() const
Definition: STM32-DMAv2-DmaPeripheral.hpp:53