2020-02-01 22:47:27 +01:00
|
|
|
#pragma once
|
2020-02-01 23:41:18 +01:00
|
|
|
|
2020-02-21 19:08:47 +01:00
|
|
|
#include "config.hpp"
|
2020-02-01 23:41:18 +01:00
|
|
|
#include "hardware.hpp"
|
|
|
|
|
2020-02-21 19:08:47 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2020-02-01 23:41:18 +01:00
|
|
|
#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");
|
2020-02-01 23:41:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
2020-02-01 23:41:18 +01:00
|
|
|
public:
|
2020-02-09 20:36:25 +01:00
|
|
|
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;
|
|
|
|
}
|
2020-02-01 23:41:18 +01:00
|
|
|
|
|
|
|
private:
|
2020-02-21 19:08:47 +01:00
|
|
|
const callback_t m_callback = nullptr;
|
2020-02-01 23:41:18 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace adc
|