UM1713 User manual Developing applications on STM32Cube with LwIP TCP/IP stack

Started by tha, February 09, 2023, 12:44:22 PM

Previous topic - Next topic

tha

2.1 Global Ethernet MAC/DMA functions

Table 16 จัดให้มีสรุปรวมของ the Global Ethernet MAC/DMA functions ที่ใช้สำหรับการกำหนดค่าของ the media access control (MAC) และ direct memory access (DMA) features.



tha

2.1.1 Ethernet MAC/DMA configuration parameters

The configuration structure สำหรับ an Ethernet MAC/DMA คือ ETH_InitTypeDef. structure นี้ประกอบด้วย the following MAC and DMA configuration parameters.









tha

2.2 DMA descriptor handling

2.2.1 DMA descriptors

การส่งถ่ายของ Ethernet packets ระหว่าง Transmit/Receive FIFOs และ memory ถูกดำเนินการโดย direct memory access (DMA) โดยใช้ transfer descriptors.

Figure 3 แสดงรูปแบบของ an Ethernet DMA descriptor.

Note:  The following description ไม่นำมาใช้กับ enhanced DMA descriptors.



ดังแสดงในรูปที่ 3, the DMA descriptor สามารถมีสองรูปแบบ:
•   The descriptor ชี้ไปยัง one data buffer เท่านั้นและ the Next Descriptor field ชี้บน next DMA descriptor สำหรับอนุญาต
     ให้ descriptors chaining mechanism
•   The descriptor สามารถชี้ไปยัง two data buffers, Buffer1 and Buffer2


tha

ใน the STM32F4x7 Ethernet driver, the selected DMA descriptor format คือ the one allowing descriptor chaining ดังแสดงในรูปที่ 4.



Note:  1   An Ethernet packet สามารถทอดข้ามครอบคลุมหนึ่งหรือหลาย DMA descriptors.
           2   One DMA descriptor สามารถถูกใช้สำหรับ one Ethernet packet เท่านั้น.
           3   The last descriptor ใน the chain จะชี้ไปยัง the first descriptor เพื่อสร้างวงแหวนของ descriptors.

tha

Figure 5 แสดง the buffer and descriptor allocation model ใน memory สำหรับ the STM32F4x7 Ethernet driver.



ดังแสดงใน Figure 5, the following arrays ถูกจัดสรรอย่างคงที่ใน the STM32F4x7 Ethernet driver:
•    Two arrays สำหรับ the DMA descriptors, อาเรย์หนึ่งสำหรับ DMA Rx และอีกอาเรย์หนึ่งสำหรับ DMA Tx:
          ETH_DMADESCTypeDef DMARxDscrTab[ETH_RXBUFNB],
          DMATxDscrTab[ETH_TXBUFNB];
•    Two arrays ของ driver buffers, array หนึ่งสำหรับ receive buffers และอีก array หนึ่งสำหรับ transmit buffers:
          uint8_t Rx_Buff[ETH_RXBUFNB][ETH_RX_BUF_SIZE];
          uint8_t Tx_Buff[ETH_TXBUFNB][ETH_TX_BUF_SIZE];
     โดยที่:
     –   ETH_RXBUFNB: จำนวนของ driver receive buffers
     –   ETH_TXBUFNB: จำนวนของ driver transmit buffers
     –   ETH_RX_BUF_SIZE: ขนาดเป็นไบต์ของ a receive buffer
     –   ETH_TX_BUF_SIZE: ขนาดเป็นไบต์ของ a transmit buffer
     ค่าโดยเริ่มต้นสำหรับ parameters เหล่านี้ดังที่กำหนดใน file stm32f4x7_eth.h คือ:
     –   ETH_RXBUFNB = 4
     –   ETH_TXBUFNB = 2
     –   ETH_RX_BUF_SIZE = 1524 (max size of Ethernet packet (1522) + 2 bytes for 32-bit alignment)
     –   ETH_TX_BUF_SIZE = 1524 (max size of Ethernet packet (1522) + 2 bytes for 32-bit alignment)

     The above parameter values สามารถถูกเปลี่ยนขึ้นอยู่กับ user specific application needs. นี้สามารถถูกทำโดยการเปิดใช้งาน
     CUSTOM_DRIVER_BUFFERS_CONFIG และเขียนค่าที่กำหนดเองใน the stm32f4x7_eth_conf.h configuration file.

Note: The Ethernet driver อนุญาตให้มี a buffer size (ETH_RX_BUF_SIZE หรือ ETH_TX_BUF_SIZE) ที่ไม่เกิน the
          maximum Ethernet packet size (1522 bytes). Ethernet packets (ที่รับหรือที่จะถูกส่ง) ที่เกิน the configured buffer
          size จะทอดข้ามครอบคลุมไปหลาย buffers (หรือ descriptors).

tha

2.2.2 DMA descriptor handling functions

Table 11 จัดให้มีสรุปรวมของ the main driver functions ที่ใช้สำหรับการจัดการ DMA descriptors.




Note: The Ethernet driver จะรักษา two global pointers สำหรับr Rx/Tx DMA descriptor tracking, สำหรับ the next packet
          ที่จะถูกรับหรือที่จะถูกส่ง:

                         __IO ETH_DMADESCTypeDef *DMATxDescToSet;
                         __IO ETH_DMADESCTypeDef *DMARxDescToGet;


tha

2.3 PHY control functions

Table 12 จัดให้มีสรุปรวมของ the functions จัดให้มีใช้สำหรับ PHY control โดย the STM32F4x7 Ethernet driver.

Note: The PHY configuration options (Reset delay, Configuration delay, Status register Speed and Duplex mask
          values) ถูกกำหนดใน the stm32f4x7_eth_conf.h configuration file. ค่าเหล่านี้เปลี่ยนจาก a PHY ไปเป็นค่าอื่น, ดังนั้นผู้ใช้
          จึงต้องอัปเดตค่านี้ขึ้นอยู่กับ the external PHY ที่ใช้.




The PHY ถูกเข้าถึงในระหว่าง the initialization time (โดย ETH_Init driver function) หลักๆเพื่อ:
•   รีเซ็ต the PHY.
•   เปิดใช้งาน the PHY auto-negotiation mode หรือเลือกโหมดการทำงานแบบด้วยมือ (Fullspeed/Low-speed, Half-
     duplex/Full-duplex).
•   ถ้า the PHY auto-negotiation mode ถูกเลือก, the application จำเป็นต้องวนตรวจ the PHY หรือใช้ a PHY interrupt เพื่อให้
     ได้รับผลลัพธ์ของ auto-negotiation (speed, duplex mode).

tha

2.4 Hardware checksum

The STM32F4x7 Ethernet controller มี an embedded hardware checksum accelerator เพื่อลดโหลด the CPU จากการสร้าง การแทรก และการตรวจสอบผลรวมการตรวจสอบความถูกต้องของ the IP, UDP, TCP and ICMP protocols.

ผลรวมการตรวจสอบความถูกต้องสำหรับ TCP, UDP or ICMP จะถูกคำนวณครอบคลุม a complete frame, และจากนั้นใส่ลงใน corresponding header field ของมัน. เนื่องจากข้อกำหนดนี้ ฟังก์ชันนี้จึงถูกเปิดใช้งานเฉพาะเมื่อ the Transmit FIFO ถูกกำหนดค่าสำหรับ Store-and-Forward mode.

Note: โดยค่าเริ่มต้น, the hardware checksum ถูกเปิดใช้งาน. เพื่อปิดใช้งานคุณลักษณะนี้, "คอมเมนต์ออก" the specific
           CHECKSUM_BY_HARDWARE ที่กำหนดใน the LwIPopts.h file ภายใต้ the \inc project folder.