[En-Nut-Discussion] Re: Link status of RTL8019AS

Peter Cobb pcobb at daintree.net
Thu Jul 21 06:45:03 CEST 2005


Hi Harald,

Thanks for the tip. Checking that bit seems to do the trick. I added the
link checking to the NicRx thread. The link status will be checked every two
seconds or whenever a frame is received.

Add the following to rtlregs.h:

    /*
     * Configuration register 0 bits.
     */
    #define NIC_CONFIG0_LINK_FAIL   0x04 /*!< \brief Set when link is down*/

Add the following to nictrl.h:
    /*!
     * \brief Link status definitions.
     */
    #define NIC_LINK_UNSUPPORTED 0x00
    #define NIC_LINK_UP          0x01
    #define NIC_LINK_DOWN        0x02

Add to the end of the NICINFO struct in nictrl.h:
    u_char ni_link_status;          /*!< Current link status. */

Add the following to the THREAD(NicRx, arg) function in the nicrtl.c:

    volatile u_char *base = (u_char *) (dev->dev_base);

    .
    .
    .

    NutEventWait(&ni->ni_rx_rdy, 2000);   (After this line add link check)

    /*
     * Switch to register page 3. For the mode we're in 
     * Config reg 0 bit 2 is set when the link is down.
     */
    nic_write(NIC_CR, NIC_CR_PS0 | NIC_CR_PS1);
    if ( (nic_read(NIC_PG3_CONFIG0) & NIC_CONFIG0_LINK_FAIL) == 0) {
        ni->ni_link_status = NIC_LINK_UP;
    } else {
        ni->ni_link_status = NIC_LINK_DOWN;
    }


Cheers,
Peter





More information about the En-Nut-Discussion mailing list