void hdlc_test(void)
{
    u8_t data;

    // Enable RS-485 PIO for loopback operation
    BIT_SET_HI(PORT_RS485_TX_EN_O, BIT_RS485_TX_EN_O);
    BIT_SET_HI(DDR_RS485_TX_EN_O, BIT_RS485_TX_EN_O);

    BIT_SET_LO(PORT_RS485_RX_EN_O, BIT_RS485_RX_EN_O);
    BIT_SET_HI(DDR_RS485_RX_EN_O, BIT_RS485_RX_EN_O);

    // Initialise modules
    uart0_init();
    uart1_init();
    printf_init();
    hdlc_init(&hdlc_on_rx_frame);

    // Enable global interrupts
    sei();
        
    // Send an HDLC packet
    data = 0x55;
    hdlc_tx_frame(&data,1);

    // Process received data
    for(;;)
    {
        if(uart1_get_rx_byte(&data))
        {
            PRINTF("%02X ", data);
            // Feed received data to HDLC layer
            hdlc_on_rx_byte(data);
        }
    }
}
Example #2
0
void on_uart_data(uint8_t *data,int len)
{
    int i;
    
    for (i=0; i<len; i++)
    {
        hdlc_on_rx_byte(data[i]);
    }
}