diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2012-02-26 15:06:27 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2012-02-26 15:06:27 +0000 |
commit | dfaf4d61e227b7a5a3434b99b00c1b5f9a8d3ce9 (patch) | |
tree | 2b3e9a976af7a6354879900c72e28105a79c00d6 /os | |
parent | 3c7d97c61e32d7ca023ff0c308fd52015f9abdd4 (diff) | |
download | ChibiOS-dfaf4d61e227b7a5a3434b99b00c1b5f9a8d3ce9.tar.gz ChibiOS-dfaf4d61e227b7a5a3434b99b00c1b5f9a8d3ce9.tar.bz2 ChibiOS-dfaf4d61e227b7a5a3434b99b00c1b5f9a8d3ce9.zip |
Improved link status detection.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3988 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r-- | os/hal/platforms/STM32/mac_lld.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/os/hal/platforms/STM32/mac_lld.c b/os/hal/platforms/STM32/mac_lld.c index 236f96fc4..669c4ad94 100644 --- a/os/hal/platforms/STM32/mac_lld.c +++ b/os/hal/platforms/STM32/mac_lld.c @@ -585,19 +585,22 @@ void mac_lld_release_receive_descriptor(MACReceiveDescriptor *rdp) { bool_t mac_lld_poll_link_status(MACDriver *macp) {
uint32_t maccr, bmsr, bmcr;
- /* Checks if the link is up, updates the status accordingly and returns.*/
+ maccr = ETH->MACCR;
+
+ /* PHY CR and SR registers read.*/
(void)mii_read(macp, MII_BMSR);
bmsr = mii_read(macp, MII_BMSR);
- if (!(bmsr & BMSR_LSTATUS))
- return macp->link_up = FALSE;
-
- maccr = ETH->MACCR;
bmcr = mii_read(macp, MII_BMCR);
/* Check on auto-negotiation mode.*/
if (bmcr & BMCR_ANENABLE) {
uint32_t lpa;
+ /* Auto-negotiation must be finished without faults and link established.*/
+ if ((bmsr & (BMSR_LSTATUS | BMSR_RFAULT | BMSR_ANEGCOMPLETE)) !=
+ (BMSR_LSTATUS | BMSR_ANEGCOMPLETE))
+ return macp->link_up = FALSE;
+
/* Auto-negotiation enabled, checks the LPA register.*/
lpa = mii_read(macp, MII_LPA);
@@ -614,7 +617,9 @@ bool_t mac_lld_poll_link_status(MACDriver *macp) { maccr &= ~ETH_MACCR_DM;
}
else {
- /* Auto-negotiation disabled, checks the current settings.*/
+ /* Link must be established.*/
+ if (!(bmsr & BMSR_LSTATUS))
+ return macp->link_up = FALSE;
/* Check on link speed.*/
if (bmcr & BMCR_SPEED100)
|