Added compile time check to verify pin supports ADC
This commit is contained in:
parent
2f54f9217f
commit
f7f02b76a8
2
adc.hpp
2
adc.hpp
@ -13,6 +13,8 @@ struct Config {
|
||||
template <typename Cfg, io::P pin>
|
||||
class Adc {
|
||||
public:
|
||||
static_assert(detail::supports_adc_v<pin>, "Pin does not support ADC");
|
||||
|
||||
void read() {}
|
||||
|
||||
private:
|
||||
|
10
hardware.hpp
10
hardware.hpp
@ -2,7 +2,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <avr/io.h>
|
||||
#include "../io/io.hpp"
|
||||
|
||||
namespace adc {
|
||||
|
||||
@ -70,6 +70,14 @@ enum class ControlFlagsDigInDis {
|
||||
DIGITAL_INPUT_DISABLE_5 = ADC5D,
|
||||
};
|
||||
|
||||
template <io::P pin>
|
||||
struct supports_adc {
|
||||
static constexpr auto value = (io::detail::getBus(pin) == io::Bus::C) ? true : false;
|
||||
};
|
||||
|
||||
template <io::P pin>
|
||||
constexpr auto supports_adc_v = supports_adc<pin>::value;
|
||||
|
||||
#pragma pop_macro("_MMIO_BYTE")
|
||||
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user