distortos  v0.7.0
object-oriented C++ RTOS for microcontrollers
DmaChannelHandle.hpp
Go to the documentation of this file.
1 
12 #ifndef SOURCE_CHIP_STM32_INCLUDE_DISTORTOS_CHIP_DMACHANNELHANDLE_HPP_
13 #define SOURCE_CHIP_STM32_INCLUDE_DISTORTOS_CHIP_DMACHANNELHANDLE_HPP_
14 
16 
17 namespace distortos
18 {
19 
20 namespace chip
21 {
22 
30 {
31 public:
32 
35 
40  constexpr DmaChannelHandle() :
41  channel_{}
42  {
43 
44  }
45 
53  {
54  assert(channel_ == nullptr);
55  }
56 
63  size_t getTransactionsLeft() const
64  {
65  assert(channel_ != nullptr);
66  return channel_->getTransactionsLeft();
67  }
68 
77  void release()
78  {
79  if (channel_ == nullptr)
80  return;
81 
82  channel_->release();
83  channel_ = {};
84  }
85 
101  int reserve(DmaChannel& channel, const uint8_t request, DmaChannelFunctor& functor)
102  {
103  assert(channel_ == nullptr);
104 
105  const auto ret = channel.reserve(request, functor);
106  if (ret != 0)
107  return ret;
108 
109  channel_ = &channel;
110  return {};
111  }
112 
134  void startTransfer(const uintptr_t memoryAddress, const uintptr_t peripheralAddress, const size_t transactions,
135  const Flags flags) const
136  {
137  assert(channel_ != nullptr);
138  channel_->startTransfer(memoryAddress, peripheralAddress, transactions, flags);
139  }
140 
152  void stopTransfer() const
153  {
154  assert(channel_ != nullptr);
156  }
157 
158  DmaChannelHandle(const DmaChannelHandle&) = delete;
160  const DmaChannelHandle& operator=(const DmaChannelHandle&) = delete;
161  DmaChannelHandle& operator=(DmaChannelHandle&&) = delete;
162 
163 private:
164 
167 };
168 
169 } // namespace chip
170 
171 } // namespace distortos
172 
173 #endif // SOURCE_CHIP_STM32_INCLUDE_DISTORTOS_CHIP_DMACHANNELHANDLE_HPP_
size_t getTransactionsLeft() const
Definition: STM32-DMAv2-DmaChannel.cpp:217
DmaChannel class header for DMAv2 in STM32.
void startTransfer(const uintptr_t memoryAddress, const uintptr_t peripheralAddress, const size_t transactions, const Flags flags) const
Configures and starts asynchronous transfer.
Definition: DmaChannelHandle.hpp:134
DmaChannelFlags
DMA transfer configuration flags.
Definition: DmaChannel.hpp:32
DmaChannel * channel_
pointer to low-level DMA channel driver associated with this handle
Definition: DmaChannelHandle.hpp:166
int reserve(DmaChannel &channel, const uint8_t request, DmaChannelFunctor &functor)
Reserves low-level DMA channel driver for exclusive use via this handle.
Definition: DmaChannelHandle.hpp:101
Definition: DmaChannel.hpp:149
size_t getTransactionsLeft() const
Definition: DmaChannelHandle.hpp:63
~DmaChannelHandle()
DmaChannelHandle's destructor.
Definition: DmaChannelHandle.hpp:52
constexpr DmaChannelHandle()
DmaChannelHandle's constructor.
Definition: DmaChannelHandle.hpp:40
Definition: DmaChannelHandle.hpp:29
Top-level namespace of distortos project.
Definition: buttons.hpp:33
void release()
Releases any associated low-level DMA channel driver.
Definition: DmaChannelHandle.hpp:77
void stopTransfer() const
Stops transfer.
Definition: STM32-DMAv2-DmaChannel.cpp:295
void stopTransfer() const
Stops transfer.
Definition: DmaChannelHandle.hpp:152
Definition: DmaChannelFunctor.hpp:29
void release()
Releases low-level DMA channel driver.
Definition: STM32-DMAv2-DmaChannel.cpp:222
int reserve(uint8_t request, DmaChannelFunctor &functor)
Reserves low-level DMA channel driver for exclusive use.
Definition: STM32-DMAv2-DmaChannel.cpp:228
void startTransfer(uintptr_t memoryAddress, uintptr_t peripheralAddress, size_t transactions, Flags flags) const
Configures and starts asynchronous transfer.
Definition: STM32-DMAv2-DmaChannel.cpp:243