Skip to content

Commit b594aa9

Browse files
authored
✨ (minor) Add acquire_adc to stm32f1 (#152)
1 parent 5c91614 commit b594aa9

File tree

1 file changed

+19
-3
lines changed
  • include/libhal-arm-mcu/stm32f1

1 file changed

+19
-3
lines changed

include/libhal-arm-mcu/stm32f1/adc.hpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <libhal-arm-mcu/stm32f1/constants.hpp>
1818
#include <libhal/adc.hpp>
1919
#include <libhal/lock.hpp>
20+
#include <libhal/pointers.hpp>
2021
#include <libhal/units.hpp>
2122

2223
namespace hal::stm32f1 {
@@ -125,13 +126,14 @@ class adc_manager::channel : public hal::adc
125126
*/
126127
template<peripheral id>
127128
channel(stm32f1::adc<id>& p_adc, adc_pins p_pin)
128-
: channel(p_adc, p_pin)
129+
: m_manager(&p_adc)
130+
, m_pin(p_pin)
129131
{
130132
}
131133
channel(channel const& p_other) = delete;
132134
channel& operator=(channel const& p_other) = delete;
133-
channel(channel&& p_other) noexcept = delete;
134-
channel& operator=(channel&& p_other) noexcept = delete;
135+
channel(channel&& p_other) noexcept = default;
136+
channel& operator=(channel&& p_other) noexcept = default;
135137
~channel() override;
136138

137139
private:
@@ -152,4 +154,18 @@ class adc_manager::channel : public hal::adc
152154
/// The pin that is used for this channel.
153155
adc_pins m_pin;
154156
};
157+
158+
template<peripheral id>
159+
hal::v5::strong_ptr<adc_manager::channel> acquire_adc(
160+
std::pmr::polymorphic_allocator<> p_allocator,
161+
stm32f1::adc<id>& p_adc,
162+
adc_pins p_pin)
163+
{
164+
return hal::v5::make_strong_ptr<hal::stm32f1::adc_manager::channel>(
165+
p_allocator, p_adc, p_pin);
166+
}
155167
} // namespace hal::stm32f1
168+
169+
namespace hal {
170+
using hal::stm32f1::acquire_adc;
171+
}

0 commit comments

Comments
 (0)