/*
 * Copyright (C) 2020-2021 Aloysius Indrayanto
 *
 * This file is part of the eCxx library, see LICENSE file for the license details.
 */


#ifndef INCLUDE_ECXX_PLATFORM_AVR_ISR_UART_CPP
#error "this file cannot be compiled directly"
#endif
#undef INCLUDE_ECXX_PLATFORM_AVR_ISR_UART_CPP


#if ( defined(UBRRH) && defined(UBRRL) ) || ( defined(UBRR0H) && defined(UBRR0L) )


//
// UART/UART0 'Rx Complete' interrupt vectors
//
#if defined(USART_RXC_vect)
ISR(USART_RXC_vect)
#elif defined(USART_RX_vect)
ISR(USART_RX_vect)
#elif defined(USART0_RX_vect)
ISR(USART0_RX_vect)
#else
#error "unsupported USART/USART0 'Rx Complete' interrupt vector name"
#endif
{
    eCxx::uart0_rxComplete_isr();
}


//
// UART/UART0 'Data Register Empty' interrupt vectors
//
#if defined(USART_UDRE_vect)
ISR(USART_UDRE_vect)
#elif defined(USART0_UDRE_vect)
ISR(USART0_UDRE_vect)
#else
#error "unsupported USART/USART0 'Data Register Empty' interrupt vector name"
#endif
{
    eCxx::uart0_udrEmpty_isr();
}


#endif


#if defined(UBRR1H) && defined(UBRR1L)


//
// UART1 'Rx Complete' interrupt vectors
//
#if defined(USART1_RX_vect)
ISR(USART1_RX_vect)
#else
#error "unsupported USART1 'Rx Complete' interrupt vector name"
#endif
{
    eCxx::uart1_rxComplete_isr();
}


//
// UART1 'Data Register Empty' interrupt vectors
//
#if defined(USART1_UDRE_vect)
ISR(USART1_UDRE_vect)
#else
#error "unsupported USART1 'Data Register Empty' interrupt vector name"
#endif
{
    eCxx::uart1_udrEmpty_isr();
}


#endif


#if defined(UBRR2H) && defined(UBRR2L)


//
// UART2 'Rx Complete' interrupt vectors
//
#if defined(USART2_RX_vect)
ISR(USART2_RX_vect)
#else
#error "unsupported USART2 'Rx Complete' interrupt vector name"
#endif
{
    eCxx::uart2_rxComplete_isr();
}


//
// UART2 'Data Register Empty' interrupt vectors
//
#if defined(USART2_UDRE_vect)
ISR(USART2_UDRE_vect)
#else
#error "unsupported USART2 'Data Register Empty' interrupt vector name"
#endif
{
    eCxx::uart2_udrEmpty_isr();
}


#endif


#if defined(UBRR3H) && defined(UBRR3L)


//
// UART3 'Rx Complete' interrupt vectors
//
#if defined(USART3_RX_vect)
ISR(USART3_RX_vect)
#else
#error "unsupported USART3 'Rx Complete' interrupt vector name"
#endif
{
    eCxx::uart3_rxComplete_isr();
}


//
// UART3 'Data Register Empty' interrupt vectors
//
#if defined(USART3_UDRE_vect)
ISR(USART3_UDRE_vect)
#else
#error "unsupported USART3 'Data Register Empty' interrupt vector name"
#endif
{
    eCxx::uart3_udrEmpty_isr();
}


#endif

