You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54 lines
1.2 KiB
C++
54 lines
1.2 KiB
C++
4 years ago
|
/**
|
||
|
* @file adc.hpp
|
||
4 years ago
|
* @brief Manages signal reading through the ADC.
|
||
4 years ago
|
*
|
||
4 years ago
|
* Copyright (C) 2021 Clyne Sullivan
|
||
4 years ago
|
*
|
||
|
* 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/>.
|
||
|
*/
|
||
|
|
||
4 years ago
|
#ifndef STMDSP_ADC_HPP_
|
||
|
#define STMDSP_ADC_HPP_
|
||
|
|
||
|
#include "hal.h"
|
||
4 years ago
|
#include "sclock.hpp"
|
||
4 years ago
|
|
||
4 years ago
|
#include <array>
|
||
|
|
||
|
class ADC
|
||
4 years ago
|
{
|
||
4 years ago
|
public:
|
||
|
using Operation = void (*)(adcsample_t *buffer, size_t count);
|
||
4 years ago
|
|
||
4 years ago
|
static void begin();
|
||
|
|
||
|
static void start(adcsample_t *buffer, size_t count, Operation operation);
|
||
|
static void stop();
|
||
|
|
||
4 years ago
|
static adcsample_t readAlt(unsigned int id);
|
||
|
|
||
4 years ago
|
static void setRate(SClock::Rate rate);
|
||
4 years ago
|
static void setOperation(Operation operation);
|
||
|
|
||
|
private:
|
||
|
static ADCDriver *m_driver;
|
||
4 years ago
|
static ADCDriver *m_driver2;
|
||
4 years ago
|
|
||
|
static const ADCConfig m_config;
|
||
4 years ago
|
static const ADCConfig m_config2;
|
||
4 years ago
|
static ADCConversionGroup m_group_config;
|
||
4 years ago
|
static ADCConversionGroup m_group_config2;
|
||
4 years ago
|
|
||
|
static adcsample_t *m_current_buffer;
|
||
|
static size_t m_current_buffer_size;
|
||
|
static Operation m_operation;
|
||
|
|
||
4 years ago
|
public:
|
||
4 years ago
|
static void conversionCallback(ADCDriver *);
|
||
|
};
|
||
4 years ago
|
|
||
|
#endif // STMDSP_ADC_HPP_
|
||
|
|