Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hal_mac_lld.c - added support for fixed link connection #83

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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 !defined(BOARD_PHY_FIXED_LINK)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I think what you need to do is add a config item to hal_mmc_lld.h, something like:

/**
 * @brief   <docs in here>
 */
#if !defined(STM32_MAC_PHY_FIXED_LINK) || defined(__DOXYGEN__)
#define STM32_MAC_PHY_FIXED_LINK FALSE
#endif
/**
 * @brief   <docs in here>
 */
#if !defined(STM32_MAC_PHY_FIXED_LINK_TYPE) || defined(__DOXYGEN__)
#define STM32_MAC_PHY_FIXED_LINK_TYPE LINK_100_FULLDUPLEX
#endif

and then adjust the source appropriately for these

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changes made accordingly

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks - I will ping the ChibiOS guys

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks !

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 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;
Expand Down