From 02a30eeeaca3c2887cc674e54018a55fce53e6e2 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sat, 13 Jun 2015 17:49:39 +0000 Subject: [PATCH] Fixed bug #606. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8032 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/ports/STM32/LLD/mac_lld.c | 20 +++++++++----------- os/hal/ports/STM32/LLD/mac_lld.h | 11 +++++------ readme.txt | 1 + 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/os/hal/ports/STM32/LLD/mac_lld.c b/os/hal/ports/STM32/LLD/mac_lld.c index 73c699062..5142df163 100644 --- a/os/hal/ports/STM32/LLD/mac_lld.c +++ b/os/hal/ports/STM32/LLD/mac_lld.c @@ -123,22 +123,20 @@ static void mii_find_phy(MACDriver *macp) { uint32_t i; #if STM32_MAC_PHY_TIMEOUT > 0 - rtcnt_t start = chSysGetRealtimeCounterX(); - rtcnt_t timeout = start + MS2RTC(STM32_HCLK,STM32_MAC_PHY_TIMEOUT); - rtcnt_t time = start; - while (chSysIsCounterWithinX(time, start, timeout)) { + unsigned n = STM32_MAC_PHY_TIMEOUT; + do { #endif - for (i = 0; i < 31; i++) { - macp->phyaddr = i << 11; - ETH->MACMIIDR = (i << 6) | MACMIIDR_CR; - if ((mii_read(macp, MII_PHYSID1) == (BOARD_PHY_ID >> 16)) && - ((mii_read(macp, MII_PHYSID2) & 0xFFF0) == (BOARD_PHY_ID & 0xFFF0))) { + for (i = 0U; i < 31U; i++) { + macp->phyaddr = i << 11U; + ETH->MACMIIDR = (i << 6U) | MACMIIDR_CR; + if ((mii_read(macp, MII_PHYSID1) == (BOARD_PHY_ID >> 16U)) && + ((mii_read(macp, MII_PHYSID2) & 0xFFF0U) == (BOARD_PHY_ID & 0xFFF0U))) { return; } } #if STM32_MAC_PHY_TIMEOUT > 0 - time = chSysGetRealtimeCounterX(); - } + n--; + } while (n > 0U); #endif /* Wrong or defective board.*/ osalSysHalt("MAC failure"); diff --git a/os/hal/ports/STM32/LLD/mac_lld.h b/os/hal/ports/STM32/LLD/mac_lld.h index 96987cf95..8684192a5 100644 --- a/os/hal/ports/STM32/LLD/mac_lld.h +++ b/os/hal/ports/STM32/LLD/mac_lld.h @@ -144,12 +144,11 @@ /** * @brief PHY detection timeout. - * @details Timeout, in milliseconds, for PHY address detection, if a PHY - * is not detected within the timeout then the driver halts during - * initialization. This setting applies only if the PHY address is - * not explicitly set in the board header file using - * @p BOARD_PHY_ADDRESS. A zero value disables the timeout and a - * single search path is performed. + * @details Timeout for PHY address detection, the scan for a PHY is performed + * the specified number of times before invoking the failure handler. + * This setting applies only if the PHY address is not explicitly + * set in the board header file using @p BOARD_PHY_ADDRESS. A zero + * value disables the timeout and a single search is performed. */ #if !defined(STM32_MAC_PHY_TIMEOUT) || defined(__DOXYGEN__) #define STM32_MAC_PHY_TIMEOUT 100 diff --git a/readme.txt b/readme.txt index 5f25b8ef0..4cd7437cd 100644 --- a/readme.txt +++ b/readme.txt @@ -80,6 +80,7 @@ - NIL: Added INTC priorities check to the e200z port. - RT: Added INTC priorities check to the e200z port. - HAL: Added support for extra DMA channels in STM32F072 devices. +- HAL: Fixed dependency between STM32 MAC driver and RT (bug #606). - HAL: Fixed wrong macro names in STM32F0xx HAL driver (bug #605). - HAL: Fixed wrong check on ADC3 in STM32F3xx ADC driver (bug #604). - HAL: Fixed wrong macro names in STM32F3xx HAL driver (bug #603).