AllJoyn/Samples/BACnetAdapter/bacnet-stack-0.8.2/ports/xplained/rs485.c
void rs485_init(void)
{
    usart_rs232_options_t option;

    /* initialize the Rx and Tx byte queues */
    FIFO_Init(&Receive_Queue, &Receive_Queue_Data[0],
        (unsigned) sizeof(Receive_Queue_Data));
    FIFO_Init(&Transmit_Queue, &Transmit_Queue_Data[0],
        (unsigned) sizeof(Transmit_Queue_Data));
    /* initialize the silence timer */
    timer_elapsed_start(&Silence_Timer);
    /* configure the TX pin */
    ioport_configure_pin(RS485_TXD,
        IOPORT_DIR_OUTPUT | IOPORT_INIT_HIGH);
    /* configure the RX pin */
    ioport_configure_pin(RS485_RXD, 
		IOPORT_DIR_INPUT);
    /* configure the RTS pins */
    ioport_configure_pin(RS485_RE,
        IOPORT_DIR_OUTPUT | IOPORT_INIT_LOW);
    ioport_configure_pin(RS485_DE,
        IOPORT_DIR_OUTPUT | IOPORT_INIT_LOW);
    option.baudrate = Baud_Rate;
    option.charlength = USART_CHSIZE_8BIT_gc;
    option.paritytype = USART_PMODE_DISABLED_gc;
    option.stopbits = false;
    usart_init_rs232(&RS485_USART, &option);
    usart_set_rx_interrupt_level(&RS485_USART, USART_INT_LVL_HI);
}
/**
 *  Initialize the RS-485 UART interface, receive interrupts enabled
 */
Initialize the RS-485 UART interface, receive interrupts enabled
Initialize the RS - 485 UART interface receive interrupts enabled
void rs485_init(void)
{
    usart_rs232_options_t option;
    FIFO_Init(&Receive_Queue, &Receive_Queue_Data[0],
        (unsigned) sizeof(Receive_Queue_Data));
    FIFO_Init(&Transmit_Queue, &Transmit_Queue_Data[0],
        (unsigned) sizeof(Transmit_Queue_Data));
    timer_elapsed_start(&Silence_Timer);
    ioport_configure_pin(RS485_TXD,
        IOPORT_DIR_OUTPUT | IOPORT_INIT_HIGH);
    ioport_configure_pin(RS485_RXD, 
		IOPORT_DIR_INPUT);
    ioport_configure_pin(RS485_RE,
        IOPORT_DIR_OUTPUT | IOPORT_INIT_LOW);
    ioport_configure_pin(RS485_DE,
        IOPORT_DIR_OUTPUT | IOPORT_INIT_LOW);
    option.baudrate = Baud_Rate;
    option.charlength = USART_CHSIZE_8BIT_gc;
    option.paritytype = USART_PMODE_DISABLED_gc;
    option.stopbits = false;
    usart_init_rs232(&RS485_USART, &option);
    usart_set_rx_interrupt_level(&RS485_USART, USART_INT_LVL_HI);
}
void rs485_init ( void ) { usart_rs232_options_t option ; FIFO_Init ( & Receive_Queue , & Receive_Queue_Data [ 0 ] , ( unsigned ) sizeof ( Receive_Queue_Data ) ) ; FIFO_Init ( & Transmit_Queue , & Transmit_Queue_Data [ 0 ] , ( unsigned ) sizeof ( Transmit_Queue_Data ) ) ; timer_elapsed_start ( & Silence_Timer ) ; ioport_configure_pin ( RS485_TXD , IOPORT_DIR_OUTPUT | IOPORT_INIT_HIGH ) ; ioport_configure_pin ( RS485_RXD , IOPORT_DIR_INPUT ) ; ioport_configure_pin ( RS485_RE , IOPORT_DIR_OUTPUT | IOPORT_INIT_LOW ) ; ioport_configure_pin ( RS485_DE , IOPORT_DIR_OUTPUT | IOPORT_INIT_LOW ) ; option . baudrate = Baud_Rate ; option . charlength = USART_CHSIZE_8BIT_gc ; option . paritytype = USART_PMODE_DISABLED_gc ; option . stopbits = false ; usart_init_rs232 ( & RS485_USART , & option ) ; usart_set_rx_interrupt_level ( & RS485_USART , USART_INT_LVL_HI ) ; }
Initialize the RS-485 UART interface, receive interrupts enabled
Initialize the RS - 485 UART interface receive interrupts enabled
/* initialize the Rx and Tx byte queues */ /* initialize the silence timer */ /* configure the TX pin */ /* configure the RX pin */ /* configure the RTS pins */