Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/thirdpin/libopencm3_cpp_extensions.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'cm3cpp/adc_dma.hpp')
-rw-r--r--cm3cpp/adc_dma.hpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/cm3cpp/adc_dma.hpp b/cm3cpp/adc_dma.hpp
new file mode 100644
index 0000000..0c059ca
--- /dev/null
+++ b/cm3cpp/adc_dma.hpp
@@ -0,0 +1,46 @@
+#ifndef CM3CPP_ADC_DMA_H_
+#define CM3CPP_ADC_DMA_H_
+
+#include <cstring>
+#include <libopencm3/stm32/dma.h>
+
+#include "adc.hpp"
+#include "private/assert.h"
+
+namespace cm3cpp {
+
+namespace adc {
+
+class AdcDma
+{
+ public:
+ struct DmaConf
+ {
+ uint32_t number;
+ uint32_t stream;
+ uint32_t channel;
+ };
+
+ struct AdcConf
+ {
+ Adc::Number number;
+ Adc::Channel* channels;
+ uint8_t channels_count;
+ };
+
+ AdcDma(DmaConf dma, AdcConf adc, bool is_temp_sensor);
+
+ CM3CPP_EXPLISIT_DESTRUCTOR(AdcDma)
+
+ uint16_t get_value(uint8_t index);
+
+ private:
+ Adc* _adc;
+ uint16_t* _data;
+};
+
+} // namespace adc
+
+} // namespace cm3cpp
+
+#endif /* CM3CPP_ADC_DMA_H_ */