Hello,
I need to make sure that my LPC2478 will configure its DHCP only after the physical insertion of the Ethernet cable into the controller (it seems that TCPNet cannot handle a situation where a DHCP enabled controller is startup without a network connection, thus the need to configure TCPNet again or for the firs time once the cable is inserted. Note: of the controller already got an IP address, then had his cable disconnected, there is no problem). It seems that simple interrupt detection won't do the job. Any ideas?
@IB Shy,
To my understanding, your extension of the driver executes some parts of the "init_ethernet" in order to setup everything when a cable is inserted. Can you give some more details? For example, how did you conclude that such a call is necessary? Or, if the essential parts of the code are compact, can you post it here?
What I assume right now is that you detected the link as done in "init_ethernet", and if detected, you just perform the configuration. If so, I can do it myself...
Tamir,
The 'init_ethernet' gets called during the initialisation of the TCPnet. The Keil implementation (through conditional compilation) configures the PHY and MAC.
If auto-discrimination is selected, the routine waits for either 1) success or 2) a large timeout. If success, then fine. If timeout, then assume some fixed parameters and continue as it sees fit.
My code triggers the auto-discrimination of the PHY (if that is the required option) and then exits. The timeslot is then called periodically to check the status of the PHY. If a new connection is made, it reads the parameters and sets the MAC accordingly. If a connection is lost, it re-triggers an auto-negotiation.
The timeslot also takes a snapshot of Ethernet parameters (speed, duplex, connection). These details are available through a 'status' call so I can check them within the main application.
I used a timeslot (that is called from the same task that maintains the TCP) because I do not know what the TCPnet does internally [thanks to the crazy pricing of Keil's TCPnet sourcecode!] and I did not want to interfere with it's workings. It could have been done in ways other than a timeslot, but I think it all turned out rather neat. I need to do a little more checking, but so far it looks like a worthwhile effort.
Sorry, but I think code is too big to post here.
IB Shy,
I get it more or less. Just one more thing: what exactly do you mean by "timeslot" ?
I use the word timeslot to describe a function that is called repeatedly from a supervisory loop.
My TCPnet supervisory loop is similar to the following:
static TASK void TaskTcpPoll(void) { for (;;) { ETHERNET_Timeslot(); // Maintain the Ethernet link main_TcpNet(); // Maintains the TCP TCPCLIENT_Timeslot(); // Maintain the TCP client(s) TCPSERVER_Timeslot(); // Maintain the TCP server(s) UDPSERVER_Timeslot(); // Maintain the UDP server(s) } os_dly_wait(1); // Wait a while } }
Thanks a lot for your help!