adc/adc.hpp

59 lines
938 B
C++
Raw Normal View History

2020-02-01 22:47:27 +01:00
#pragma once
2020-02-21 19:08:47 +01:00
#include "config.hpp"
#include "hardware.hpp"
2020-02-21 19:08:47 +01:00
#include <stdint.h>
#include "../io/io.hpp"
namespace adc {
2020-02-21 19:08:47 +01:00
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>
2020-02-21 19:08:47 +01:00
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");
2020-02-21 19:08:47 +01:00
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:
2020-02-21 19:08:47 +01:00
const callback_t m_callback = nullptr;
};
} // namespace adc