ethcat开发记录 一
一、方案
1、移植开源方案SOEM
2、专用芯片
二、SOEM移植
(一)硬件
stm32f407,168M
PHY:LAN8720A
(ii) Points to note
1, the PHY address of the LAN8720 problem.
2, the chip should operate on the reset pin after power on.
3、Enable the hybrid mode of LAN8720, in the new HAL library, this setting is contained in the ETH_MACFilterConfigTypeDef structure, configured by HAL_ETH_SetMACFilterConfig function.
Full code.
/* ETH init function */
void MX_ETH_Init(void)
{
/* USER CODE BEGIN ETH_Init 0 */
// Reset the chip
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_2,GPIO_PIN_RESET);
HAL_Delay(10);
HAL_GPIO_WritePin(GPIOB,GPIO_PIN_2,GPIO_PIN_SET);
/* USER CODE END ETH_Init 0 */
static uint8_t MACAddr[6];
/* USER CODE BEGIN ETH_Init 1 */
/* USER CODE END ETH_Init 1 */
heth.Instance = ETH;
MACAddr[0] = 0x00;
MACAddr[1] = 0x80;
MACAddr[2] = 0xE1;
MACAddr[3] = 0x00;
MACAddr[4] = 0x00;
MACAddr[5] = 0x00;
heth.Init.MACAddr = &MACAddr[0];
heth.Init.MediaInterface = HAL_ETH_RMII_MODE;
heth.Init.TxDesc = DMATxDscrTab;
heth.Init.RxDesc = DMARxDscrTab;
heth.Init.RxBuffLen = 1524;
/* USER CODE BEGIN MACADDRESS */
/* USER CODE END MACADDRESS */
if (HAL_ETH_Init(&heth) ! = HAL_OK)
{
Error_Handler();
}
memset(&TxConfig, 0 , sizeof(ETH_TxPacketConfig));
TxConfig.Attributes = ETH_TX_PACKETS_FEATURES_CSUM
引用请注明出处