adc/adc.hpp

59 lines
938 B
C++

#pragma once
#include "config.hpp"
#include "hardware.hpp"
#include <stdint.h>
#include "../io/io.hpp"
namespace adc {
template <typename Cfg, typename Input, Input src>
class Adc {
public:
static_assert(sizeof(Input) == -1, "Invalid input source selected");
};
template <typename Cfg, io::P pin>
class Adc<Cfg, io::P, pin> {
private:
using callback_t = void (*)(uint16_t);
public:
static_assert(detail::supports_adc_v<pin>, "Pin does not support ADC");
Adc() {}
Adc(callback_t callback) : m_callback(callback) {}
uint16_t read()
{
return 0;
}
private:
const callback_t m_callback = nullptr;
};
template <typename Cfg, InputSource src>
class Adc<Cfg, InputSource, src> {
private:
using callback_t = void (*)(uint16_t);
public:
Adc() {}
Adc(callback_t callback) : m_callback(callback) {}
uint16_t read()
{
return 0;
}
private:
const callback_t m_callback = nullptr;
};
} // namespace adc