Skip to content

Commit

Permalink
drivers: ethernet: eth_stm32_hal: Configurable speed and duplex
Browse files Browse the repository at this point in the history
Make it possible to be able to change speed and duplex for the
STM32H7xx and API_V2 from the configuration settings.

This exists for the non-STM32H7x already today, so this is basically
copying the code for the other STM32's.

Please note that ST has a series incompability. For F1 and F2,
the duplex settings are named ETH_MODE_FULLDUPLEX respective
ETH_MODE_HALFDUPLEX. For F4, H7 and F7 the duplex settings are named
ETH_FULLDUPLEX_MODE respective ETG_HALFDUPLEX_MODE.

This should really be queried from the PHY (as previous programmer have
written in the code). But while waiting for a proper PHY solution,
this is intended as a stop-gap solution.

Signed-off-by: Stefan Petersen <[email protected]>
  • Loading branch information
spe-ciellt authored and carlescufi committed May 23, 2023
1 parent 4b0d691 commit 945d074
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/ethernet/eth_stm32_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1226,8 +1226,10 @@ static int eth_initialize(const struct device *dev)
ETH_MACConfigTypeDef mac_config;

HAL_ETH_GetMACConfig(heth, &mac_config);
mac_config.DuplexMode = ETH_FULLDUPLEX_MODE;
mac_config.Speed = ETH_SPEED_100M;
mac_config.DuplexMode = IS_ENABLED(CONFIG_ETH_STM32_MODE_HALFDUPLEX) ?
ETH_HALFDUPLEX_MODE : ETH_FULLDUPLEX_MODE;
mac_config.Speed = IS_ENABLED(CONFIG_ETH_STM32_SPEED_10M) ?
ETH_SPEED_10M : ETH_SPEED_100M;
hal_ret = HAL_ETH_SetMACConfig(heth, &mac_config);
if (hal_ret != HAL_OK) {
LOG_ERR("HAL_ETH_SetMACConfig: failed: %d", hal_ret);
Expand Down

0 comments on commit 945d074

Please sign in to comment.