Moved interrupt vectors to their own translation unit to solve redefinition error

This commit is contained in:
BlackMark 2019-08-02 20:29:04 +02:00
parent 33c3cedb1e
commit 2cd4069654
4 changed files with 64 additions and 28 deletions

30
hardware0.cpp Normal file
View File

@ -0,0 +1,30 @@
#include "hardware0.hpp"
#include <avr/interrupt.h>
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

View File

@ -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<int>(rhs); } constexpr int operator<<(const int &lhs, const ControlFlagsC0 &rhs) { return lhs << static_cast<int>(rhs); }
// clang-format on // clang-format on
static void (*fnRx0IntHandler)() = nullptr; extern void (*fnRx0IntHandler)();
static void (*fnDataReg0EmptyIntHandler)() = nullptr; extern void (*fnDataReg0EmptyIntHandler)();
ISR(USART0_RX_vect)
{
if (fnRx0IntHandler)
fnRx0IntHandler();
}
ISR(USART0_UDRE_vect)
{
if (fnDataReg0EmptyIntHandler)
fnDataReg0EmptyIntHandler();
}
#else #else
#error "This chip is not supported" #error "This chip is not supported"

30
hardware1.cpp Normal file
View File

@ -0,0 +1,30 @@
#include "hardware1.hpp"
#include <avr/interrupt.h>
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

View File

@ -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<int>(rhs); } constexpr int operator<<(const int &lhs, const ControlFlagsC1 &rhs) { return lhs << static_cast<int>(rhs); }
// clang-format on // clang-format on
static void (*fnRx1IntHandler)() = nullptr; extern void (*fnRx1IntHandler)();
static void (*fnDataReg1EmptyIntHandler)() = nullptr; extern void (*fnDataReg1EmptyIntHandler)();
ISR(USART1_RX_vect)
{
if (fnRx1IntHandler)
fnRx1IntHandler();
}
ISR(USART1_UDRE_vect)
{
if (fnDataReg1EmptyIntHandler)
fnDataReg1EmptyIntHandler();
}
#define HAS_UART1 #define HAS_UART1