diff --git a/hardware0.cpp b/hardware0.cpp new file mode 100644 index 0000000..220f9b4 --- /dev/null +++ b/hardware0.cpp @@ -0,0 +1,30 @@ +#include "hardware0.hpp" + +#include + +namespace uart { +namespace detail { + +#if defined(__AVR_ATmega1284P__) + +void (*fnRx0IntHandler)() = nullptr; +void (*fnDataReg0EmptyIntHandler)() = nullptr; + +ISR(USART0_RX_vect) +{ + if (fnRx0IntHandler) + fnRx0IntHandler(); +} + +ISR(USART0_UDRE_vect) +{ + if (fnDataReg0EmptyIntHandler) + fnDataReg0EmptyIntHandler(); +} + +#else +#error "This chip is not supported" +#endif + +} // namespace detail +} // namespace uart diff --git a/hardware0.hpp b/hardware0.hpp index ace10ba..8ce0629 100644 --- a/hardware0.hpp +++ b/hardware0.hpp @@ -63,20 +63,8 @@ constexpr int operator<<(const int &lhs, const ControlFlagsB0 &rhs) { return lhs constexpr int operator<<(const int &lhs, const ControlFlagsC0 &rhs) { return lhs << static_cast(rhs); } // clang-format on -static void (*fnRx0IntHandler)() = nullptr; -static void (*fnDataReg0EmptyIntHandler)() = nullptr; - -ISR(USART0_RX_vect) -{ - if (fnRx0IntHandler) - fnRx0IntHandler(); -} - -ISR(USART0_UDRE_vect) -{ - if (fnDataReg0EmptyIntHandler) - fnDataReg0EmptyIntHandler(); -} +extern void (*fnRx0IntHandler)(); +extern void (*fnDataReg0EmptyIntHandler)(); #else #error "This chip is not supported" diff --git a/hardware1.cpp b/hardware1.cpp new file mode 100644 index 0000000..f7b70cc --- /dev/null +++ b/hardware1.cpp @@ -0,0 +1,30 @@ +#include "hardware1.hpp" + +#include + +namespace uart { +namespace detail { + +#if defined(__AVR_ATmega1284P__) + +void (*fnRx1IntHandler)() = nullptr; +void (*fnDataReg1EmptyIntHandler)() = nullptr; + +ISR(USART1_RX_vect) +{ + if (fnRx1IntHandler) + fnRx1IntHandler(); +} + +ISR(USART1_UDRE_vect) +{ + if (fnDataReg1EmptyIntHandler) + fnDataReg1EmptyIntHandler(); +} + +#else +#error "This chip is not supported" +#endif + +} // namespace detail +} // namespace uart diff --git a/hardware1.hpp b/hardware1.hpp index f3e8572..5528b32 100644 --- a/hardware1.hpp +++ b/hardware1.hpp @@ -63,20 +63,8 @@ constexpr int operator<<(const int &lhs, const ControlFlagsB1 &rhs) { return lhs constexpr int operator<<(const int &lhs, const ControlFlagsC1 &rhs) { return lhs << static_cast(rhs); } // clang-format on -static void (*fnRx1IntHandler)() = nullptr; -static void (*fnDataReg1EmptyIntHandler)() = nullptr; - -ISR(USART1_RX_vect) -{ - if (fnRx1IntHandler) - fnRx1IntHandler(); -} - -ISR(USART1_UDRE_vect) -{ - if (fnDataReg1EmptyIntHandler) - fnDataReg1EmptyIntHandler(); -} +extern void (*fnRx1IntHandler)(); +extern void (*fnDataReg1EmptyIntHandler)(); #define HAS_UART1