@@ -54,9 +54,9 @@ uint64_t last_tick;
5454/* Private variables ---------------------------------------------------------*/
5555/*
5656@Note: This interface is implemented to operate in zero-copy mode only:
57- - Rx buffers will be allocated from LwIP stack memory heap,
58- then passed to ETH HAL driver .
59- - Tx buffers will be allocated from LwIP stack memory heap,
57+ - Rx buffers are allocated statically and passed directly to the LwIP stack
58+ they will return back to ETH DMA after been processed by the stack .
59+ - Tx Buffers will be allocated from LwIP stack memory heap,
6060 then passed to ETH HAL driver.
6161
6262@Notes:
@@ -98,13 +98,13 @@ static uint8_t RxAllocStatus;
9898
9999#pragma location=0x30000000
100100ETH_DMADescTypeDef DMARxDscrTab [ETH_RX_DESC_CNT ]; /* Ethernet Rx DMA Descriptors */
101- #pragma location=0x30000060
101+ #pragma location=0x30000100
102102ETH_DMADescTypeDef DMATxDscrTab [ETH_TX_DESC_CNT ]; /* Ethernet Tx DMA Descriptors */
103103
104104#elif defined ( __CC_ARM ) /* MDK ARM Compiler */
105105
106106__attribute__((at (0x30000000 ))) ETH_DMADescTypeDef DMARxDscrTab [ETH_RX_DESC_CNT ]; /* Ethernet Rx DMA Descriptors */
107- __attribute__((at (0x30000060 ))) ETH_DMADescTypeDef DMATxDscrTab [ETH_TX_DESC_CNT ]; /* Ethernet Tx DMA Descriptors */
107+ __attribute__((at (0x30000100 ))) ETH_DMADescTypeDef DMATxDscrTab [ETH_TX_DESC_CNT ]; /* Ethernet Tx DMA Descriptors */
108108
109109#elif defined ( __GNUC__ ) /* GNU Compiler */
110110
@@ -183,7 +183,7 @@ static void low_level_init(struct netif *netif)
183183 heth .Init .MediaInterface = HAL_ETH_RMII_MODE ;
184184 heth .Init .TxDesc = DMATxDscrTab ;
185185 heth .Init .RxDesc = DMARxDscrTab ;
186- heth .Init .RxBuffLen = 1524 ;
186+ heth .Init .RxBuffLen = 1536 ;
187187
188188 /* USER CODE BEGIN MACADDRESS */
189189
@@ -271,7 +271,8 @@ static err_t low_level_output(struct netif *netif, struct pbuf *p)
271271{
272272 uint32_t i = 0U ;
273273 struct pbuf * q = NULL ;
274- ETH_BufferTypeDef Txbuffer [ETH_TX_DESC_CNT ] = {0 };
274+ err_t errval = ERR_OK ;
275+ ETH_BufferTypeDef Txbuffer [ETH_TX_DESC_CNT ];
275276
276277 memset (Txbuffer , 0 , ETH_TX_DESC_CNT * sizeof (ETH_BufferTypeDef ));
277278
@@ -300,12 +301,9 @@ static err_t low_level_output(struct netif *netif, struct pbuf *p)
300301 TxConfig .TxBuffer = Txbuffer ;
301302 TxConfig .pData = p ;
302303
303- SCB_CleanInvalidateDCache_by_Addr (p -> payload , p -> len );
304-
305- HAL_ETH_Transmit (& heth , & TxConfig , 0 );
306-
304+ HAL_ETH_Transmit (& heth , & TxConfig , ETH_DMA_TRANSMIT_TIMEOUT );
307305
308- return ERR_OK ;
306+ return errval ;
309307}
310308
311309/**
@@ -322,9 +320,7 @@ static struct pbuf * low_level_input(struct netif *netif)
322320
323321 if (RxAllocStatus == RX_ALLOC_OK )
324322 {
325- if (HAL_ETH_ReadData (& heth , (void * * )& p ) == HAL_ERROR && p != NULL && (p > (struct pbuf * )0x40000000 || p < (struct pbuf * )0x30000000 )){
326- SCB_CleanInvalidateDCache_by_Addr (p -> payload , p -> len );
327- }
323+ HAL_ETH_ReadData (& heth , (void * * )& p );
328324 }
329325
330326 return p ;
@@ -506,28 +502,28 @@ void HAL_ETH_MspInit(ETH_HandleTypeDef* ethHandle)
506502 GPIO_InitStruct .Pin = RMII_MDC_Pin |RMII_RXD0_Pin |RMII_RXD1_Pin ;
507503 GPIO_InitStruct .Mode = GPIO_MODE_AF_PP ;
508504 GPIO_InitStruct .Pull = GPIO_NOPULL ;
509- GPIO_InitStruct .Speed = GPIO_SPEED_FREQ_LOW ;
505+ GPIO_InitStruct .Speed = GPIO_SPEED_FREQ_VERY_HIGH ;
510506 GPIO_InitStruct .Alternate = GPIO_AF11_ETH ;
511507 HAL_GPIO_Init (GPIOC , & GPIO_InitStruct );
512508
513- GPIO_InitStruct .Pin = GPIO_PIN_1 |RMII_MDIO_Pin |GPIO_PIN_7 ;
509+ GPIO_InitStruct .Pin = RMII_REF_CLK_Pin |RMII_MDIO_Pin |RMII_CRS_DV_Pin ;
514510 GPIO_InitStruct .Mode = GPIO_MODE_AF_PP ;
515511 GPIO_InitStruct .Pull = GPIO_NOPULL ;
516- GPIO_InitStruct .Speed = GPIO_SPEED_FREQ_LOW ;
512+ GPIO_InitStruct .Speed = GPIO_SPEED_FREQ_VERY_HIGH ;
517513 GPIO_InitStruct .Alternate = GPIO_AF11_ETH ;
518514 HAL_GPIO_Init (GPIOA , & GPIO_InitStruct );
519515
520516 GPIO_InitStruct .Pin = RMII_TXD1_Pin ;
521517 GPIO_InitStruct .Mode = GPIO_MODE_AF_PP ;
522518 GPIO_InitStruct .Pull = GPIO_NOPULL ;
523- GPIO_InitStruct .Speed = GPIO_SPEED_FREQ_LOW ;
519+ GPIO_InitStruct .Speed = GPIO_SPEED_FREQ_VERY_HIGH ;
524520 GPIO_InitStruct .Alternate = GPIO_AF11_ETH ;
525521 HAL_GPIO_Init (RMII_TXD1_GPIO_Port , & GPIO_InitStruct );
526522
527523 GPIO_InitStruct .Pin = RMII_TX_EN_Pin |RMII_TXD0_Pin ;
528524 GPIO_InitStruct .Mode = GPIO_MODE_AF_PP ;
529525 GPIO_InitStruct .Pull = GPIO_NOPULL ;
530- GPIO_InitStruct .Speed = GPIO_SPEED_FREQ_LOW ;
526+ GPIO_InitStruct .Speed = GPIO_SPEED_FREQ_VERY_HIGH ;
531527 GPIO_InitStruct .Alternate = GPIO_AF11_ETH ;
532528 HAL_GPIO_Init (GPIOG , & GPIO_InitStruct );
533529
@@ -565,7 +561,7 @@ void HAL_ETH_MspDeInit(ETH_HandleTypeDef* ethHandle)
565561 */
566562 HAL_GPIO_DeInit (GPIOC , RMII_MDC_Pin |RMII_RXD0_Pin |RMII_RXD1_Pin );
567563
568- HAL_GPIO_DeInit (GPIOA , GPIO_PIN_1 |RMII_MDIO_Pin |GPIO_PIN_7 );
564+ HAL_GPIO_DeInit (GPIOA , RMII_REF_CLK_Pin |RMII_MDIO_Pin |RMII_CRS_DV_Pin );
569565
570566 HAL_GPIO_DeInit (RMII_TXD1_GPIO_Port , RMII_TXD1_Pin );
571567
0 commit comments