From d81f1bf31ac21ad1006b4af89cde0cb27d923047 Mon Sep 17 00:00:00 2001 From: "tomas.vrsansky" Date: Thu, 2 Nov 2023 15:23:05 +0100 Subject: [PATCH 1/2] hal_mac_lld.c - added support for fixed link connection --- os/hal/ports/STM32/LLD/MACv2/hal_mac_lld.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/os/hal/ports/STM32/LLD/MACv2/hal_mac_lld.c b/os/hal/ports/STM32/LLD/MACv2/hal_mac_lld.c index 0d07f056e..13e563c09 100644 --- a/os/hal/ports/STM32/LLD/MACv2/hal_mac_lld.c +++ b/os/hal/ports/STM32/LLD/MACv2/hal_mac_lld.c @@ -651,10 +651,12 @@ void mac_lld_release_receive_descriptor(MACReceiveDescriptor *rdp) { * @notapi */ bool mac_lld_poll_link_status(MACDriver *macp) { - uint32_t maccr, bmsr, bmcr; + uint32_t maccr; maccr = ETH->MACCR; - + /* Fixed link connection defined in board.h.*/ +#if !defined(BOARD_PHY_FIXED_LINK) + uint32_t bmsr, bmcr; /* PHY CR and SR registers read.*/ (void)mii_read(macp, MII_BMSR); bmsr = mii_read(macp, MII_BMSR); @@ -701,6 +703,14 @@ bool mac_lld_poll_link_status(MACDriver *macp) { else maccr &= ~ETH_MACCR_DM; } +/* Fixed link type defined in board.h.*/ +#elif defined(LINK_100_FULLDUPLEX) + maccr |= ETH_MACCR_FES; + maccr |= ETH_MACCR_DM; +#elif defined(LINK_10_FULLDUPLEX) + maccr &= ~ETH_MACCR_FES; + maccr |= ETH_MACCR_DM; +#endif /* Changes the mode in the MAC.*/ ETH->MACCR = maccr; From 20bcebc4a7db5dc6fb2f55c09e995e7f06842bc4 Mon Sep 17 00:00:00 2001 From: "tomas.vrsansky" Date: Fri, 3 Nov 2023 13:44:30 +0100 Subject: [PATCH 2/2] modified defines to match conventions --- os/hal/ports/STM32/LLD/MACv2/hal_mac_lld.c | 6 +++--- os/hal/ports/STM32/LLD/MACv2/hal_mac_lld.h | 22 ++++++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/os/hal/ports/STM32/LLD/MACv2/hal_mac_lld.c b/os/hal/ports/STM32/LLD/MACv2/hal_mac_lld.c index 13e563c09..9a2d22bb3 100644 --- a/os/hal/ports/STM32/LLD/MACv2/hal_mac_lld.c +++ b/os/hal/ports/STM32/LLD/MACv2/hal_mac_lld.c @@ -655,7 +655,7 @@ bool mac_lld_poll_link_status(MACDriver *macp) { maccr = ETH->MACCR; /* Fixed link connection defined in board.h.*/ -#if !defined(BOARD_PHY_FIXED_LINK) +#if (!STM32_MAC_PHY_FIXED_LINK) uint32_t bmsr, bmcr; /* PHY CR and SR registers read.*/ (void)mii_read(macp, MII_BMSR); @@ -704,10 +704,10 @@ bool mac_lld_poll_link_status(MACDriver *macp) { maccr &= ~ETH_MACCR_DM; } /* Fixed link type defined in board.h.*/ -#elif defined(LINK_100_FULLDUPLEX) +#elif STM32_MAC_PHY_FIXED_LINK_TYPE == LINK_100_FULLDUPLEX maccr |= ETH_MACCR_FES; maccr |= ETH_MACCR_DM; -#elif defined(LINK_10_FULLDUPLEX) +#elif STM32_MAC_PHY_FIXED_LINK_TYPE == LINK_10_FULLDUPLEX maccr &= ~ETH_MACCR_FES; maccr |= ETH_MACCR_DM; #endif diff --git a/os/hal/ports/STM32/LLD/MACv2/hal_mac_lld.h b/os/hal/ports/STM32/LLD/MACv2/hal_mac_lld.h index c7cb35eee..d7060ba45 100644 --- a/os/hal/ports/STM32/LLD/MACv2/hal_mac_lld.h +++ b/os/hal/ports/STM32/LLD/MACv2/hal_mac_lld.h @@ -129,6 +129,14 @@ #define STM32_TDES3_FL 0x00007FFF /** @} */ +/** + * @name Fixed link types + * @{ + */ +#define LINK_100_FULLDUPLEX 0x00 +#define LINK_10_FULLDUPLEX 0x01 +/** @} */ + /*===========================================================================*/ /* Driver pre-compile time settings. */ /*===========================================================================*/ @@ -200,6 +208,20 @@ #if !defined(STM32_MAC_IP_CHECKSUM_OFFLOAD) || defined(__DOXYGEN__) #define STM32_MAC_IP_CHECKSUM_OFFLOAD 0 #endif + +/** + * @brief Fixed link connection + */ +#if !defined(STM32_MAC_PHY_FIXED_LINK) || defined(__DOXYGEN__) +#define STM32_MAC_PHY_FIXED_LINK FALSE +#endif + +/** + * @brief Fixed link connection type + */ +#if !defined(STM32_MAC_PHY_FIXED_LINK_TYPE) || defined(__DOXYGEN__) +#define STM32_MAC_PHY_FIXED_LINK_TYPE LINK_100_FULLDUPLEX +#endif /** @} */ /*===========================================================================*/