Added constexpr and checking of supported chip

This commit is contained in:
BlackMark 2020-02-21 17:35:23 +01:00
parent 4b644b22bf
commit 70aabc07f6

View File

@ -4,6 +4,8 @@
namespace spi { namespace spi {
#if defined(__AVR_ATmega328P__)
template <class Cfg> template <class Cfg>
class Hardware { class Hardware {
public: public:
@ -101,7 +103,7 @@ class Hardware {
static void setBitOrder() static void setBitOrder()
{ {
if (Cfg::BIT_ORDER == BitOrder::LSB_FIRST) { if constexpr (Cfg::BIT_ORDER == BitOrder::LSB_FIRST) {
SPCR |= (1 << DORD); SPCR |= (1 << DORD);
} else { } else {
SPCR &= ~(1 << DORD); SPCR &= ~(1 << DORD);
@ -126,4 +128,8 @@ class Hardware {
} }
}; };
#else
#error "This chip is not supported"
#endif
} // namespace spi } // namespace spi