aboutsummaryrefslogtreecommitdiffstats
path: root/firmware/source/periph/adc.hpp
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2023-08-08 23:10:02 -0400
committerClyne Sullivan <clyne@bitgloo.com>2023-08-08 23:10:02 -0400
commitf440728644ad3698ffd6af1abcfcc07aad5793c3 (patch)
tree68aff014ff17933717616f2f8d407b51611afe2b /firmware/source/periph/adc.hpp
initial commit
* combine all source files into this monorepo * convert all third-party source packages into submodules * small fixes due to changes in latest third-part packages
Diffstat (limited to 'firmware/source/periph/adc.hpp')
-rw-r--r--firmware/source/periph/adc.hpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/firmware/source/periph/adc.hpp b/firmware/source/periph/adc.hpp
new file mode 100644
index 0000000..5f7fa08
--- /dev/null
+++ b/firmware/source/periph/adc.hpp
@@ -0,0 +1,53 @@
+/**
+ * @file adc.hpp
+ * @brief Manages signal reading through the ADC.
+ *
+ * Copyright (C) 2021 Clyne Sullivan
+ *
+ * Distributed under the GNU GPL v3 or later. You should have received a copy of
+ * the GNU General Public License along with this program.
+ * If not, see <https://www.gnu.org/licenses/>.
+ */
+
+#ifndef STMDSP_ADC_HPP_
+#define STMDSP_ADC_HPP_
+
+#include "hal.h"
+#include "sclock.hpp"
+
+#include <array>
+
+class ADC
+{
+public:
+ using Operation = void (*)(adcsample_t *buffer, size_t count);
+
+ static void begin();
+
+ static void start(adcsample_t *buffer, size_t count, Operation operation);
+ static void stop();
+
+ static adcsample_t readAlt(unsigned int id);
+
+ static void setRate(SClock::Rate rate);
+ static void setOperation(Operation operation);
+
+private:
+ static ADCDriver *m_driver;
+ static ADCDriver *m_driver2;
+
+ static const ADCConfig m_config;
+ static const ADCConfig m_config2;
+ static ADCConversionGroup m_group_config;
+ static ADCConversionGroup m_group_config2;
+
+ static adcsample_t *m_current_buffer;
+ static size_t m_current_buffer_size;
+ static Operation m_operation;
+
+public:
+ static void conversionCallback(ADCDriver *);
+};
+
+#endif // STMDSP_ADC_HPP_
+