Added timeout on PHY detection setting.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4105 35acf78f-673a-0410-8e92-d51de3d6d3f4master
parent
82d784f498
commit
c53f702381
|
@ -118,6 +118,11 @@ static uint32_t mii_read(MACDriver *macp, uint32_t reg) {
|
||||||
static void mii_find_phy(MACDriver *macp) {
|
static void mii_find_phy(MACDriver *macp) {
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
|
|
||||||
|
#if STM32_MAC_PHY_TIMEOUT > 0
|
||||||
|
halrtcnt_t start = halGetCounterValue();
|
||||||
|
halrtcnt_t timeout = start + MS2RTT(STM32_MAC_PHY_TIMEOUT);
|
||||||
|
while (halIsCounterWithin(start, timeout)) {
|
||||||
|
#endif
|
||||||
for (i = 0; i < 31; i++) {
|
for (i = 0; i < 31; i++) {
|
||||||
macp->phyaddr = i << 11;
|
macp->phyaddr = i << 11;
|
||||||
ETH->MACMIIDR = (i << 6) | MACMIIDR_CR;
|
ETH->MACMIIDR = (i << 6) | MACMIIDR_CR;
|
||||||
|
@ -126,6 +131,9 @@ static void mii_find_phy(MACDriver *macp) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if STM32_MAC_PHY_TIMEOUT > 0
|
||||||
|
}
|
||||||
|
#endif
|
||||||
/* Wrong or defective board.*/
|
/* Wrong or defective board.*/
|
||||||
chSysHalt();
|
chSysHalt();
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,6 +141,19 @@
|
||||||
#define STM32_MAC_BUFFERS_SIZE 1518
|
#define STM32_MAC_BUFFERS_SIZE 1518
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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.
|
||||||
|
*/
|
||||||
|
#if !defined(STM32_MAC_PHY_TIMEOUT) || defined(__DOXYGEN__)
|
||||||
|
#define STM32_MAC_PHY_TIMEOUT 100
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief ETHD1 interrupt priority level setting.
|
* @brief ETHD1 interrupt priority level setting.
|
||||||
*/
|
*/
|
||||||
|
@ -170,6 +183,10 @@
|
||||||
/* Derived constants and error checks. */
|
/* Derived constants and error checks. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
#if (STM32_MAC_PHY_TIMEOUT > 0) && !HAL_IMPLEMENTS_COUNTERS
|
||||||
|
#error "STM32_MAC_PHY_TIMEOUT requires the realtime counter service"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver data structures and types. */
|
/* Driver data structures and types. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
Loading…
Reference in New Issue