Added compile time check to verify pin supports ADC
This commit is contained in:
1 parent
2f54f9217f
commit
f7f02b76a8
2 files changed
+11
-1
No files matched your search
@@ -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:
|
||||
|
||||
+9
-1
@@ -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
|
||||
|
||||
Reference in new issue
Block a user