Files
STM32F4-Base/docs/images/BSD网络栈分层.svg
T

67 lines
7.3 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<svg xmlns="http://www.w3.org/2000/svg" width="1200" height="1096" viewBox="0 0 1200 1096" font-family="Microsoft YaHei, Segoe UI, PingFang SC, sans-serif">
<rect x="0" y="0" width="1200" height="1096" fill="#ffffff"/>
<text x="26" y="40" font-size="20" font-weight="700" fill="#0f172a">BSD Socket API 分层架构(NET 网络栈)</text>
<text x="26" y="62" font-size="13" fill="#64748b">CH395F 以太网协议栈芯片 · 消息队列串行化全部网络操作至 netTask · FreeRTOS V10.3.1</text>
<rect x="26" y="78" width="1148" height="140" rx="12" fill="#eff6ff" stroke="#2563eb" stroke-opacity="0.45"/>
<text x="44" y="104" font-size="17" font-weight="700" fill="#2563eb">应用层任务</text>
<text x="141" y="104" font-size="12" fill="#64748b">任意 FreeRTOS 任务可调用公共 API(线程安全)</text>
<rect x="44" y="116" width="414" height="38" rx="8" fill="#ffffff" stroke="#2563eb" stroke-opacity="0.55"/>
<text x="251" y="139" font-size="13" fill="#1e293b" text-anchor="middle">net_send() / net_recv() / net_close()(线程安全封装)</text>
<rect x="468" y="116" width="431" height="38" rx="8" fill="#ffffff" stroke="#2563eb" stroke-opacity="0.55"/>
<text x="684" y="139" font-size="13" fill="#1e293b" text-anchor="middle">net_select() / net_poll_events() / net_set_event_cb()</text>
<rect x="44" y="164" width="601" height="38" rx="8" fill="#ffffff" stroke="#2563eb" stroke-opacity="0.55"/>
<text x="344" y="187" font-size="13" fill="#1e293b" text-anchor="middle">消费方:lftpd(FTP :21)· time_sync(对时 :8888)· ui_net_sink(远程显示 :7003)</text>
<rect x="26" y="262" width="1148" height="140" rx="12" fill="#f5f3ff" stroke="#7c3aed" stroke-opacity="0.45"/>
<text x="44" y="288" font-size="17" font-weight="700" fill="#7c3aed">消息队列</text>
<text x="124" y="288" font-size="12" fill="#64748b">osMessageQueue · CubeMX 生成,在 MX_FREERTOS_Init() 中创建</text>
<rect x="44" y="300" width="383" height="38" rx="8" fill="#ffffff" stroke="#7c3aed" stroke-opacity="0.55"/>
<text x="235" y="323" font-size="13" fill="#1e293b" text-anchor="middle">net_msg_t:send / recv / close / listen 四类请求</text>
<rect x="437" y="300" width="383" height="38" rx="8" fill="#ffffff" stroke="#7c3aed" stroke-opacity="0.55"/>
<text x="629" y="323" font-size="13" fill="#1e293b" text-anchor="middle">调用方:入队请求 → 阻塞等待结果(ulTaskNotifyTake)</text>
<rect x="44" y="348" width="423" height="38" rx="8" fill="#ffffff" stroke="#7c3aed" stroke-opacity="0.55"/>
<text x="255" y="371" font-size="13" fill="#1e293b" text-anchor="middle">netTask 侧:出队 → 执行 → 写结果 → xTaskNotifyGive 通知</text>
<rect x="26" y="446" width="1148" height="140" rx="12" fill="#f0fdfa" stroke="#0d9488" stroke-opacity="0.45"/>
<text x="44" y="472" font-size="17" font-weight="700" fill="#0d9488">netTask(网络任务)</text>
<text x="227" y="472" font-size="12" fill="#64748b">1ms 周期 · 所有 CH395F 操作在此串行执行</text>
<rect x="44" y="484" width="423" height="38" rx="8" fill="#ffffff" stroke="#0d9488" stroke-opacity="0.55"/>
<text x="255" y="507" font-size="13" fill="#1e293b" text-anchor="middle">net_poll() — CH395F 中断轮询 + Socket 状态机 + 事件回调</text>
<rect x="477" y="484" width="324" height="38" rx="8" fill="#ffffff" stroke="#0d9488" stroke-opacity="0.55"/>
<text x="640" y="507" font-size="13" fill="#1e293b" text-anchor="middle">net_process_messages() — 消费消息队列请求</text>
<rect x="44" y="532" width="667" height="38" rx="8" fill="#ffffff" stroke="#0d9488" stroke-opacity="0.55"/>
<text x="377" y="555" font-size="13" fill="#1e293b" text-anchor="middle">net_send_sock() / net_recv_sock() / net_close_sock() / net_listen_locked()(内部版本)</text>
<rect x="26" y="630" width="1148" height="140" rx="12" fill="#f0fdf4" stroke="#16a34a" stroke-opacity="0.45"/>
<text x="44" y="656" font-size="17" font-weight="700" fill="#16a34a">net_socket.c(BSD Socket API 核心)</text>
<text x="390" y="656" font-size="12" fill="#64748b">Socket 状态机 + CH395F 命令封装</text>
<rect x="44" y="668" width="368" height="38" rx="8" fill="#ffffff" stroke="#16a34a" stroke-opacity="0.55"/>
<text x="228" y="691" font-size="13" fill="#1e293b" text-anchor="middle">8 个 Socket 控制块 s_net_socks[](状态机,无锁)</text>
<rect x="422" y="668" width="475" height="38" rx="8" fill="#ffffff" stroke="#16a34a" stroke-opacity="0.55"/>
<text x="660" y="691" font-size="13" fill="#1e293b" text-anchor="middle">CH395F 命令序列封装(OPEN / TCP_LISTEN / CONNECT / SEND ...)</text>
<rect x="44" y="716" width="482" height="38" rx="8" fill="#ffffff" stroke="#16a34a" stroke-opacity="0.55"/>
<text x="285" y="739" font-size="13" fill="#1e293b" text-anchor="middle">网络代次号(net_get_generation / net_generation_inc,服务自愈)</text>
<rect x="26" y="814" width="1148" height="92" rx="12" fill="#fffbeb" stroke="#d97706" stroke-opacity="0.45"/>
<text x="44" y="840" font-size="17" font-weight="700" fill="#d97706">ch395f.c/h(底层 SPI 驱动)</text>
<text x="306" y="840" font-size="12" fill="#64748b">SPI2 · 不可重入</text>
<rect x="44" y="852" width="449" height="38" rx="8" fill="#ffffff" stroke="#d97706" stroke-opacity="0.55"/>
<text x="268" y="875" font-size="13" fill="#1e293b" text-anchor="middle">ch395f_spi_begin() / ch395f_spi_end() — 包裹每次 SPI 事务</text>
<rect x="503" y="852" width="358" height="38" rx="8" fill="#ffffff" stroke="#d97706" stroke-opacity="0.55"/>
<text x="682" y="875" font-size="13" fill="#1e293b" text-anchor="middle">所有 SPI 事务仅能由 netTask 发起(独占,无重入)</text>
<rect x="26" y="950" width="1148" height="92" rx="12" fill="#fff1f2" stroke="#e11d48" stroke-opacity="0.45"/>
<text x="44" y="976" font-size="17" font-weight="700" fill="#e11d48">CH395F 硬件</text>
<text x="159" y="976" font-size="12" fill="#64748b">以太网协议栈芯片</text>
<rect x="44" y="988" width="448" height="38" rx="8" fill="#ffffff" stroke="#e11d48" stroke-opacity="0.55"/>
<text x="268" y="1011" font-size="13" fill="#1e293b" text-anchor="middle">CH395F(SPI2:PB12 CS / PB13 SCK / PB14 SDO / PB15 SDI)</text>
<rect x="502" y="988" width="362" height="38" rx="8" fill="#ffffff" stroke="#e11d48" stroke-opacity="0.55"/>
<text x="683" y="1011" font-size="13" fill="#1e293b" text-anchor="middle">INT# 中断输出(低电平有效 · GPIO 轮询,无 EXTI)</text>
<line x1="600.0" y1="224.0" x2="600.0" y2="247.0" stroke="#94a3b8" stroke-width="2.5"/>
<path d="M 600.0 254.0 l -6 -9 h 12 z" fill="#94a3b8"/>
<line x1="600.0" y1="408.0" x2="600.0" y2="431.0" stroke="#94a3b8" stroke-width="2.5"/>
<path d="M 600.0 438.0 l -6 -9 h 12 z" fill="#94a3b8"/>
<line x1="600.0" y1="592.0" x2="600.0" y2="615.0" stroke="#94a3b8" stroke-width="2.5"/>
<path d="M 600.0 622.0 l -6 -9 h 12 z" fill="#94a3b8"/>
<line x1="600.0" y1="776.0" x2="600.0" y2="799.0" stroke="#94a3b8" stroke-width="2.5"/>
<path d="M 600.0 806.0 l -6 -9 h 12 z" fill="#94a3b8"/>
<line x1="600.0" y1="912.0" x2="600.0" y2="935.0" stroke="#94a3b8" stroke-width="2.5"/>
<path d="M 600.0 942.0 l -6 -9 h 12 z" fill="#94a3b8"/>
<text x="26" y="1078" font-size="12" fill="#94a3b8">上层只依赖相邻下层(单向);消息队列 + netTask 串行化全部 CH395F 操作;模拟器端定义 NET_NO_OS 裁掉队列/回调(Winsock 后端)</text>
</svg>