Skip to content

Commit 04ef100

Browse files
committed
docs: Update CN translation for 2 files in IDF network
1 parent 2b6894e commit 04ef100

File tree

3 files changed

+69
-14
lines changed

3 files changed

+69
-14
lines changed

docs/en/api-reference/network/esp_eth.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,10 @@ The following functions should only be invoked after the Ethernet driver has bee
524524
EMAC Hardware Time Stamping
525525
---------------------------
526526

527-
Time stamping in EMAC allows precise tracking of when Ethernet frames are transmitted or received. Hardware time stamping is crucial for applications like Precision Time Protocol (PTP) because it minimizes jitter and inaccuracies that can occur when relying on software-based time stamps. By embedding time stamps directly in hardware, delays introduced by software layers or processing overhead are avoided, ensuring nanosecond-level precision.
527+
Time stamping in EMAC allows precise tracking of when Ethernet frames are transmitted or received. Hardware time stamping is crucial for applications like Precision Time Protocol (PTP) because it minimizes jitter and inaccuracies that can occur when relying on software time stamps. Embedded time stamps in hardware avoid delays introduced by software layers or processing overhead. Therefore, it ensures nanosecond-level precision.
528528

529529
.. warning::
530+
530531
Time stamp associated API is currently in **"Experimental Feature"** state so be aware it may change with future releases.
531532

532533
The basic way how to enable time stamping, get and set time in the EMAC is demonstrated below.

docs/zh_CN/api-reference/network/esp_eth.rst

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ SPI-Ethernet 模块
382382

383383
* :cpp:member:`esp_eth_config_t::check_link_period_ms`:以太网驱动程序会启用操作系统定时器来定期检查链接状态。该字段用于设置间隔时间,单位为毫秒。
384384

385-
* :cpp:member:`esp_eth_config_t::stack_input`:在大多数的以太网物联网应用中,驱动器接收的以太网帧会被传递到上层(如 TCP/IP 栈)。经配置,该字段为负责处理传入帧的函数。可以在安装驱动程序后,通过函数 :cpp:func:`esp_eth_update_input_path` 更新该字段。该字段支持在运行过程中进行更新。
385+
* :cpp:member:`esp_eth_config_t::stack_input`:cpp:member:`esp_eth_config_t::stack_input_info`:在大多数的以太网物联网应用中,驱动器接收的以太网帧会被传递到上层(如 TCP/IP 栈)。经配置,该字段为负责处理传入帧的函数。可以在安装驱动程序后,通过函数 :cpp:func:`esp_eth_update_input_path` 更新该字段。该字段支持在运行过程中进行更新。
386386

387387
* :cpp:member:`esp_eth_config_t::on_lowlevel_init_done` 和 :cpp:member:`esp_eth_config_t::on_lowlevel_deinit_done`:这两个字段用于指定钩子函数,当去初始化或初始化低级别硬件时,会调用钩子函数。
388388

@@ -517,6 +517,58 @@ ESP-IDF 在宏 :c:macro:`ETH_DEFAULT_CONFIG` 中为安装驱动程序提供了
517517
esp_eth_ioctl(eth_handle, ETH_CMD_G_PHY_ADDR, &phy_addr);
518518
ESP_LOGI(TAG, "Ethernet PHY Address: %d", phy_addr);
519519

520+
.. _time-stamping:
521+
522+
.. only:: SOC_EMAC_IEEE1588V2_SUPPORTED
523+
524+
EMAC 硬件时间戳
525+
-----------------
526+
527+
EMAC 时间戳功能可以精确记录以太网帧的发送和接收时间。硬件时间戳对于精确时间协议 (PTP) 等应用至关重要,因为它减少了依赖软件时间戳可能出现的抖动和不准确性。将时间戳直接嵌入硬件,避免了由软件层或处理开销引入的延迟,从而实现纳秒级精度。
528+
529+
.. 警告::
530+
531+
请注意:时间戳相关的 API 当前属于 **“实验特性”**,未来版本中可能会有所更改。
532+
533+
以下内容介绍如何在 EMAC 中启用时间戳、获取和设置时间。
534+
535+
.. highlight:: c
536+
537+
::
538+
539+
// 启用硬件时间戳
540+
bool ptp_enable = true;
541+
esp_eth_ioctl(eth_hndl, ETH_MAC_ESP_CMD_PTP_ENABLE, &ptp_enable);
542+
543+
// 获取当前 EMAC 时间
544+
eth_mac_time_t ptp_time;
545+
esp_eth_ioctl(eth_hndl, ETH_MAC_ESP_CMD_G_PTP_TIME, &ptp_time);
546+
547+
// 设置 EMAC 时间
548+
ptp_time = {
549+
.seconds = 42,
550+
.nanoseconds = 0
551+
};
552+
esp_eth_ioctl(eth_hndl, ETH_MAC_ESP_CMD_S_PTP_TIME, &ptp_time);
553+
554+
您可以通过注册回调函数和设置事件触发的目标时间,在精确的时间点调度事件。请注意,回调函数将在中断服务程序 (ISR) 上下文中调用,因此应尽量简洁。
555+
556+
.. highlight:: c
557+
558+
::
559+
560+
// 注册回调函数
561+
esp_eth_ioctl(eth_hndl, ETH_MAC_ESP_CMD_S_TARGET_CB, ts_callback);
562+
563+
// 设置事件的触发时间
564+
eth_mac_time_t mac_target_time = {
565+
.seconds = 42,
566+
.nanoseconds = 0
567+
};
568+
esp_eth_ioctl(s_eth_hndl, ETH_MAC_ESP_CMD_S_TARGET_TIME, &mac_target_time);
569+
570+
接收帧的时间戳可以通过注册的 :cpp:member:`esp_eth_config_t::stack_input_info` 函数的最后一个参数进行访问,传输帧的时间戳可以通过注册的 :cpp:func:`esp_eth_transmit_ctrl_vargs` 函数的 ``ctrl`` 参数进行访问。然而,对于用户获取时间戳信息,更简便的方式是利用 L2 TAP :ref:`扩展缓冲区 <esp_netif_l2tap_ext_buff>` 机制。
571+
520572
.. _flow-control:
521573

522574
数据流量控制
@@ -546,6 +598,8 @@ ESP-IDF 在宏 :c:macro:`ETH_DEFAULT_CONFIG` 中为安装驱动程序提供了
546598

547599
* :example:`ethernet/iperf` 演示了如何使用以太网功能,使用 iPerf 测量吞吐量/带宽。
548600

601+
* :example:`ethernet/ptp` 演示了如何在以太网上使用精确时间协议 (PTP) 同步时间。
602+
549603
* :example:`network/vlan_support` 演示了如何在以太网上创建虚拟网络接口,包括 VLAN 和非 VLAN 接口。
550604

551605
* :example:`network/sta2eth` 演示了如何使用 Wi-Fi station 和有线接口(如以太网或 USB)创建 1 对 1 的桥接。

docs/zh_CN/api-reference/network/esp_netif.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ ESP-NETIF 架构
147147
.. code-block:: text
148148
149149
150-
| (A) 用户代码 |
151-
| 应用程序 |
152-
.................| 初始化 设置 事件 |
150+
| (A) 用户代码 |
151+
| 应用程序 |
152+
.................| 初始化 设置 事件 |
153153
. +----------------------------------------+
154154
. . | *
155155
. . | *
@@ -174,15 +174,15 @@ ESP-NETIF 架构
174174
--------+ | | +===========================+ 网络堆栈
175175
网络 | | ESP-NETIF
176176
接口 | |
177-
驱动 | | +---------------------------+ +------------------+
178-
| | | |.........| 开启/关闭 |
179-
| | | | | |
180-
| -<--| l2tap_write |-----<---| 写入 |
181-
| | | | |
182-
---->--| esp_vfs_l2tap_eth_filter |----->---| 读取 |
183-
| | | (A) |
184-
| (E) | +------------------+
185-
+---------------------------+ 用户代码
177+
驱动 | | +--------------------------------+ +------------------+
178+
| | | |.........| 开启/关闭 |
179+
| | | | | |
180+
| -<--| l2tap_write |-----<---| 写入 |
181+
| | | | |
182+
---->--| esp_vfs_l2tap_eth_filter_frame |----->---| 读取 |
183+
| | | (A) |
184+
| (E) | +------------------+
185+
+--------------------------------+ 用户代码
186186
ESP-NETIF L2 TAP
187187
188188

0 commit comments

Comments
 (0)