Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions os/hal/ports/STM32/LLD/MACv2/hal_mac_lld.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 (!STM32_MAC_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);
Expand Down Expand Up @@ -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 STM32_MAC_PHY_FIXED_LINK_TYPE == LINK_100_FULLDUPLEX
maccr |= ETH_MACCR_FES;
maccr |= ETH_MACCR_DM;
#elif STM32_MAC_PHY_FIXED_LINK_TYPE == LINK_10_FULLDUPLEX
maccr &= ~ETH_MACCR_FES;
maccr |= ETH_MACCR_DM;
#endif

/* Changes the mode in the MAC.*/
ETH->MACCR = maccr;
Expand Down
22 changes: 22 additions & 0 deletions os/hal/ports/STM32/LLD/MACv2/hal_mac_lld.h
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
/*===========================================================================*/
Expand Down Expand Up @@ -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
/** @} */

/*===========================================================================*/
Expand Down