diff --git a/stm32cube/stm32h5xx/README b/stm32cube/stm32h5xx/README index a1a47da7e..2ef3741a1 100755 --- a/stm32cube/stm32h5xx/README +++ b/stm32cube/stm32h5xx/README @@ -54,4 +54,13 @@ Patch List: drivers/include/stm32h5xx_ll_spi.h ST internal bug : 147754 + *fix to the V2 HAL API to get PTP to work + impacted file : stm32h5xx_hal_eth.c + In the HAL_ETH_ReadData function where it checks for the last descriptor, + we added a checked if the TSA bit was set in DESC1 + If the TSA bit is set then have a peak at the context descriptor which should be the one + after the last descriptor + If the CTXT bit is set in the context descriptor then extract the timestamps + ST internal bug : 161504 + See release_note.html from STM32Cube diff --git a/stm32cube/stm32h5xx/drivers/src/stm32h5xx_hal_eth.c b/stm32cube/stm32h5xx/drivers/src/stm32h5xx_hal_eth.c index 85f3177e7..8f8d4ccbc 100755 --- a/stm32cube/stm32h5xx/drivers/src/stm32h5xx_hal_eth.c +++ b/stm32cube/stm32h5xx/drivers/src/stm32h5xx_hal_eth.c @@ -1036,8 +1036,8 @@ HAL_StatusTypeDef HAL_ETH_Transmit_IT(ETH_HandleTypeDef *heth, ETH_TxPacketConfi */ HAL_StatusTypeDef HAL_ETH_ReadData(ETH_HandleTypeDef *heth, void **pAppBuff) { - uint32_t descidx; - ETH_DMADescTypeDef *dmarxdesc; + uint32_t descidx, descidx_temp; + ETH_DMADescTypeDef *dmarxdesc, *dmarxdesc_temp; uint32_t desccnt = 0U; uint32_t desccntmax; uint32_t bufflength; @@ -1063,13 +1063,6 @@ HAL_StatusTypeDef HAL_ETH_ReadData(ETH_HandleTypeDef *heth, void **pAppBuff) while ((READ_BIT(dmarxdesc->DESC3, ETH_DMARXNDESCWBF_OWN) == (uint32_t)RESET) && (desccnt < desccntmax) && (rxdataready == 0U)) { - if (READ_BIT(dmarxdesc->DESC3, ETH_DMARXNDESCWBF_CTXT) != (uint32_t)RESET) - { - /* Get timestamp high */ - heth->RxDescList.TimeStamp.TimeStampHigh = dmarxdesc->DESC1; - /* Get timestamp low */ - heth->RxDescList.TimeStamp.TimeStampLow = dmarxdesc->DESC0; - } if ((READ_BIT(dmarxdesc->DESC3, ETH_DMARXNDESCWBF_FD) != (uint32_t)RESET) || (heth->RxDescList.pRxStart != NULL)) { /* Check if first descriptor */ @@ -1090,6 +1083,22 @@ HAL_StatusTypeDef HAL_ETH_ReadData(ETH_HandleTypeDef *heth, void **pAppBuff) /* Packet ready */ rxdataready = 1; + + if (READ_BIT(dmarxdesc->DESC1, ETH_DMARXNDESCWBF_TSA) != (uint32_t)RESET) + { + descidx_temp = descidx; + INCR_RX_DESC_INDEX(descidx_temp, 1U); + + dmarxdesc_temp = (ETH_DMADescTypeDef *)heth->RxDescList.RxDesc[descidx_temp]; + + if (READ_BIT(dmarxdesc_temp->DESC3, ETH_DMARXNDESCWBF_CTXT) != (uint32_t)RESET) + { + /* Get timestamp high */ + heth->RxDescList.TimeStamp.TimeStampHigh = dmarxdesc_temp->DESC1; + /* Get timestamp low */ + heth->RxDescList.TimeStamp.TimeStampLow = dmarxdesc_temp->DESC0; + } + } } /* Link data */