.../stm32f7xx/drivers/src/stm32f7xx_hal_eth.c | 34 +++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/stm32cube/stm32f7xx/drivers/src/stm32f7xx_hal_eth.c b/stm32cube/stm32f7xx/drivers/src/stm32f7xx_hal_eth.c index 2b9039a..23640ec 100644 --- a/stm32cube/stm32f7xx/drivers/src/stm32f7xx_hal_eth.c +++ b/stm32cube/stm32f7xx/drivers/src/stm32f7xx_hal_eth.c @@ -409,7 +409,8 @@ HAL_StatusTypeDef HAL_ETH_Init(ETH_HandleTypeDef *heth) } while (((phyreg & PHY_AUTONEGO_COMPLETE) != PHY_AUTONEGO_COMPLETE)); /* Read the result of the auto-negotiation */ - if((HAL_ETH_ReadPHYRegister(heth, PHY_SR, &phyreg)) != HAL_OK) + /* BWASIM: Changed the Register to 31 per the manual. */ + if((HAL_ETH_ReadPHYRegister(heth, 31, &phyreg)) != HAL_OK) { /* In case of write timeout */ err = ETH_ERROR; @@ -424,6 +425,32 @@ HAL_StatusTypeDef HAL_ETH_Init(ETH_HandleTypeDef *heth) return HAL_ERROR; } + /* BWASIM: Changed this logic to work with register 31. */ + phyreg >>= 1; phyreg &= 0xF; + + /* BWASIM: This logic can be improved A LOT but it is OKAY for now to get auto-neg working. */ + if (phyreg == 0x1) { + /* 001 = 10BASE-T half-duplex */ + (heth->Init).DuplexMode = ETH_MODE_HALFDUPLEX; + (heth->Init).Speed = ETH_SPEED_10M; + } + else if (phyreg == 0x5) { + /* 101 = 10BASE-T full-duplex */ + (heth->Init).DuplexMode = ETH_MODE_FULLDUPLEX; + (heth->Init).Speed = ETH_SPEED_10M; + } + else if (phyreg == 2) { + /* 010 = 100BASE-TX half-duplex */ + (heth->Init).DuplexMode = ETH_MODE_HALFDUPLEX; + (heth->Init).Speed = ETH_SPEED_100M; + } + else + { + (heth->Init).DuplexMode = ETH_MODE_FULLDUPLEX; + (heth->Init).Speed = ETH_SPEED_100M; + } + +#if 0 /* Configure the MAC with the Duplex Mode fixed by the auto-negotiation process */ if((phyreg & PHY_DUPLEX_STATUS) != (uint32_t)RESET) { @@ -446,7 +473,9 @@ HAL_StatusTypeDef HAL_ETH_Init(ETH_HandleTypeDef *heth) /* Set Ethernet speed to 100M following the auto-negotiation */ (heth->Init).Speed = ETH_SPEED_100M; } +#endif } + else /* AutoNegotiation Disable */ { /* Check parameters */ @@ -552,6 +581,9 @@ HAL_StatusTypeDef HAL_ETH_DMATxDescListInit(ETH_HandleTypeDef *heth, ETH_DMADesc /* Set Buffer1 address pointer */ dmatxdesc->Buffer1Addr = (uint32_t)(&TxBuff[i*ETH_TX_BUF_SIZE]); + /* Clean up the length field. */ + dmatxdesc->ControlBufferSize = 0; + if ((heth->Init).ChecksumMode == ETH_CHECKSUM_BY_HARDWARE) { /* Set the DMA Tx descriptors checksum insertion */