@@ -67,6 +67,11 @@ extern "C" {
6767#define IFNAME0 ' s'
6868#define IFNAME1 ' t'
6969
70+ /* Definition of PHY SPECIAL CONTROL/STATUS REGISTER bitfield Auto-negotiation done indication */
71+ /* Placed in STM32Ethernet library instead of HAL conf to avoid compatibility dependence with Arduino_Core_STM32 */
72+ /* Could be moved from this file once Generic PHY is implemented */
73+ #define PHY_SR_AUTODONE ((uint16_t )0x1000 )
74+
7075/* Private macro -------------------------------------------------------------*/
7176/* Private variables ---------------------------------------------------------*/
7277#if defined ( __ICCARM__ ) /* !< IAR Compiler */
@@ -530,32 +535,17 @@ void ethernetif_set_link(struct netif *netif)
530535 */
531536void ethernetif_update_config (struct netif *netif)
532537{
533- __IO uint32_t tickstart = 0 ;
534538 uint32_t regvalue = 0 ;
535539
536540 if (netif_is_link_up (netif)) {
537541 /* Restart the auto-negotiation */
538542 if (EthHandle.Init .AutoNegotiation != ETH_AUTONEGOTIATION_DISABLE) {
539- /* Enable Auto-Negotiation */
540- HAL_ETH_WritePHYRegister (&EthHandle, PHY_BCR, PHY_AUTONEGOTIATION);
541-
542- /* Get tick */
543- tickstart = HAL_GetTick ();
544-
545- /* Wait until the auto-negotiation will be completed */
546- do {
547- HAL_ETH_ReadPHYRegister (&EthHandle, PHY_BSR, ®value);
548-
549- /* Check for the Timeout ( 1s ) */
550- if ((HAL_GetTick () - tickstart) > 1000 ) {
551- /* In case of timeout */
552- goto error;
553- }
554543
555- } while (((regvalue & PHY_AUTONEGO_COMPLETE) != PHY_AUTONEGO_COMPLETE));
556-
557- /* Read the result of the auto-negotiation */
544+ /* Check Auto negotiation */
558545 HAL_ETH_ReadPHYRegister (&EthHandle, PHY_SR, ®value);
546+ if ((regvalue & PHY_SR_AUTODONE) != PHY_SR_AUTODONE) {
547+ goto error;
548+ }
559549
560550 /* Configure the MAC with the Duplex Mode fixed by the auto-negotiation process */
561551 if ((regvalue & PHY_DUPLEX_STATUS) != (uint32_t )RESET) {
0 commit comments