diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2022-04-30 08:41:56 -0400 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2022-04-30 08:42:45 -0400 |
commit | e164629b3839eee0fda0be0e0a9842e78cf02f2b (patch) | |
tree | b72b58665b85a104e5b953af45f00579341b2802 /source/periph/adc.hpp | |
parent | 162dd6de8a0d883962b0b1475f47cbb08e0958d4 (diff) | |
parent | 3dd57491b1e81a9d93054eff19ca0e6c65c85b9b (diff) |
merge in branch devel
Diffstat (limited to 'source/periph/adc.hpp')
-rw-r--r-- | source/periph/adc.hpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/source/periph/adc.hpp b/source/periph/adc.hpp new file mode 100644 index 0000000..5f7fa08 --- /dev/null +++ b/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_ + |