From c1820f62f1729714039a01299cd33a065237b241 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Fri, 26 Jul 2019 19:44:20 +0200 Subject: [PATCH] Added support for hardware toggle --- io.hpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/io.hpp b/io.hpp index c32341d..db5de65 100644 --- a/io.hpp +++ b/io.hpp @@ -14,6 +14,10 @@ defined(__AVR_ATmega8__) || defined(__AVR_ATmega8A__) || defined(__AVR_ATmega168A__) || defined(__AVR_ATmega328P__) #define GPIO_6 defined(__AVR_ATtiny13A__) || defined(__AVR_ATtiny85__) +#define HARDWARE_TOGGLE \ + defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega168A__) || \ + defined(__AVR_ATmega328P__) || defined(__AVR_ATtiny13A__) || defined(__AVR_ATtiny85__) + #define PORT_A_AVAILABLE GPIO_32 #define PORT_B_AVAILABLE GPIO_32 || GPIO_23 || GPIO_6 #define PORT_C_AVAILABLE GPIO_32 || GPIO_23 @@ -255,11 +259,19 @@ class Pin { static inline void toggle() FORCE_INLINE { +#if HARDWARE_TOGGLE + constexpr auto bus = detail::getBus(pin); + constexpr auto pinReg = detail::getPIN(bus); + constexpr auto pinBit = detail::getPin(pin); + + *pinReg |= (1 << pinBit); +#else constexpr auto bus = detail::getBus(pin); constexpr auto portReg = detail::getPORT(bus); constexpr auto pinBit = detail::getPin(pin); *portReg ^= (1 << pinBit); +#endif } static inline bool read() FORCE_INLINE