@@ -67,6 +67,11 @@ extern "C" {
67
67
#define IFNAME0 ' s'
68
68
#define IFNAME1 ' t'
69
69
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
+
70
75
/* Private macro -------------------------------------------------------------*/
71
76
/* Private variables ---------------------------------------------------------*/
72
77
#if defined ( __ICCARM__ ) /* !< IAR Compiler */
@@ -530,32 +535,17 @@ void ethernetif_set_link(struct netif *netif)
530
535
*/
531
536
void ethernetif_update_config (struct netif *netif)
532
537
{
533
- __IO uint32_t tickstart = 0 ;
534
538
uint32_t regvalue = 0 ;
535
539
536
540
if (netif_is_link_up (netif)) {
537
541
/* Restart the auto-negotiation */
538
542
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
- }
554
543
555
- } while (((regvalue & PHY_AUTONEGO_COMPLETE) != PHY_AUTONEGO_COMPLETE));
556
-
557
- /* Read the result of the auto-negotiation */
544
+ /* Check Auto negotiation */
558
545
HAL_ETH_ReadPHYRegister (&EthHandle, PHY_SR, ®value);
546
+ if ((regvalue & PHY_SR_AUTODONE) != PHY_SR_AUTODONE) {
547
+ goto error;
548
+ }
559
549
560
550
/* Configure the MAC with the Duplex Mode fixed by the auto-negotiation process */
561
551
if ((regvalue & PHY_DUPLEX_STATUS) != (uint32_t )RESET) {
0 commit comments