Skip to content

Commit

Permalink
stm32cube: stm32h7: use transmit timestamp status flag.
Browse files Browse the repository at this point in the history
Read timestamp only when status flag is set in Tx descriptor.
Fire transmit timestamp callbacks only when there is a valid
non-zero timestamp.

Co-authored-by: Naeem Bacha <[email protected]>
Signed-off-by: Chamira Perera <[email protected]>
  • Loading branch information
2 people authored and erwango committed Jul 25, 2023
1 parent 1bc72c2 commit d466dc8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
8 changes: 8 additions & 0 deletions stm32cube/stm32h7xx/README
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,12 @@ Patch List:
drivers/include/stm32h7xx_hal_def.h
ST Internal Reference: 136825

*Fix to use transmit timestamp when it is valid
Read timestamp only when status flag is set in Tx descriptor.
Fire transmit timestamp callbacks only when there is a valid
non-zero timestamp.
Impacted files:
drivers/src/stm32h7xx_hal_eth.c
ST Internal Reference: 157129

See release_note.html from STM32Cube
27 changes: 21 additions & 6 deletions stm32cube/stm32h7xx/drivers/src/stm32h7xx_hal_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -1432,25 +1432,40 @@ HAL_StatusTypeDef HAL_ETH_ReleaseTxPacket(ETH_HandleTypeDef *heth)
/* Disable Ptp transmission */
CLEAR_BIT(heth->Init.TxDesc[idx].DESC3, (0x40000000U));

/* Get timestamp low */
timestamp->TimeStampLow = heth->Init.TxDesc[idx].DESC0;
/* Get timestamp high */
timestamp->TimeStampHigh = heth->Init.TxDesc[idx].DESC1;
if ((heth->Init.TxDesc[idx].DESC3 & ETH_DMATXNDESCWBF_LD )
&& (heth->Init.TxDesc[idx].DESC3 & ETH_DMATXNDESCWBF_TTSS))
{
/* Get timestamp low */
timestamp->TimeStampLow = heth->Init.TxDesc[idx].DESC0;
/* Get timestamp high */
timestamp->TimeStampHigh = heth->Init.TxDesc[idx].DESC1;
}
else
{
timestamp->TimeStampHigh = timestamp->TimeStampLow = UINT32_MAX;
}

#endif /* HAL_ETH_USE_PTP */

#if (USE_HAL_ETH_REGISTER_CALLBACKS == 1)
/*Call registered callbacks*/
#ifdef HAL_ETH_USE_PTP
/* Handle Ptp */
heth->txPtpCallback(dmatxdesclist->PacketAddress[idx], timestamp);
if (timestamp->TimeStampHigh != UINT32_MAX && timestamp->TimeStampLow != UINT32_MAX)
{
heth->txPtpCallback(dmatxdesclist->PacketAddress[idx], timestamp);
}
#endif /* HAL_ETH_USE_PTP */
/* Release the packet. */
heth->txFreeCallback(dmatxdesclist->PacketAddress[idx]);
#else
/* Call callbacks */
#ifdef HAL_ETH_USE_PTP
/* Handle Ptp */
HAL_ETH_TxPtpCallback(dmatxdesclist->PacketAddress[idx], timestamp);
if (timestamp->TimeStampHigh != UINT32_MAX && timestamp->TimeStampLow != UINT32_MAX)
{
HAL_ETH_TxPtpCallback(dmatxdesclist->PacketAddress[idx], timestamp);
}
#endif /* HAL_ETH_USE_PTP */
/* Release the packet. */
HAL_ETH_TxFreeCallback(dmatxdesclist->PacketAddress[idx]);
Expand Down

0 comments on commit d466dc8

Please sign in to comment.