Author Topic: How do we re-initalise the ethernet phy  (Read 5884 times)

Offline CarlMLE

  • Newbie
  • *
  • Posts: 5
    • View Profile
How do we re-initalise the ethernet phy
« on: July 28, 2009, 03:09:24 PM »
How do you re-initalise the ethernet connection ?

I can see that the fnTaskEthernet function creates a local instance of the ETHTABLE structure called ethernet, its loads it up then 'opens' the device returning a handle thats used from then on ...

My PHY is attached to a reset line which other IC's are attached to, occasionally we want to reset these other IC's so the PHY gets reset, not ideal. Using utasker whats the best way of re-initalising the PHY/ethernet connection with out restarting utasker.

do i just clear the Ethernet_handle and let the ethernet task re-init or ... is there away of closing an open handle?

Thanks
Carl

Offline mark

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3234
    • View Profile
    • uTasker
Re: How do we re-initalise the ethernet phy
« Reply #1 on: July 28, 2009, 03:33:36 PM »
Hi Carl

The Ethernet interface is not designed to be initialised more than once so it is not practical to re-initialise it (it would do a lot of things correctly but would also allocate more Ethernet buffers, which would result in heap problems).

I would do the following:

When the PHY has been reset call fnConfigEthernet() - it is a global routine so can be called from anywhere, but add a second parameter to it (this will make it project specific but it is probably the simplest solution).

It now looks something like fnConfigEthernet(pars, 0); when called from Ethernet.c (which you will need to modify)
and fnConfigEthernet(pars, 1) when called from other code (repeat init).

In the fnConfigEthernet() itself you can use the new parameter to control just the code which is relevant to the PHY. This will be only quite a small part in fact - note too that the PHY may need a short delay after reset before it responds so it may also be an idea not to call the re-init immediately.
The PHY re-initialisation involves (optionally) checking that it responds, followed by reading its present config and setting the mode as defined by the pars. Finally its interrupt operation is set up.

The PHY reset will otherwise not affect the MAC configuration, including port defines, so you essentially need only repeat the parts specifically for the PHY (accesses via the management serial interface).

Good luck

Regards

Mark