Files
STM32F4-Base/Drivers/BSP/NET/net_config.h
T
wandering1 bb76cfd779 修复规范矛盾并定案5项规则,保护宏统一XXX_H
规则定案:常量在右(a>5)、保护宏XXX_H(禁双下划线)、
头文件常量用#define、存储类前缀(g_/s_)优先、允许void返回值
全库32个.h头文件保护宏 __XXX_H → XXX_H 改名(字节级替换)
S1检查规则同步更新(拒绝双下划线),Inc/gpio.h 反向验证被正确拦截
规范示例矛盾修复:K&R括号、标准类型、变量初始化、命名常量、注释字段补全
2026-09-01 16:07:00 +08:00

105 lines
2.4 KiB
C
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.
/*
* 模块名称:Network Configuration
* 模块功能:网络子系统配置宏定义,包括最大Socket数量、缓冲区大小、
* 超时时间等参数配置
* 适用平台:STM32F4 系列(CH395F 以太网芯片)
* 作者:王建锋
* 创建日期:2026-07-18
* 修改记录:
*/
#ifndef NET_CONFIG_H
#define NET_CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
/*
* 最大支持的 Socket 数量(CH395F 支持 0~7)
*/
#ifndef NET_MAX_SOCKETS
#define NET_MAX_SOCKETS 8
#endif
/*
* TCP Server 多连接模式配置
* 监听 Socket 索引和数据 Socket 起始索引
*/
#ifndef NET_TCP_SERVER_LISTEN_SOCK
#define NET_TCP_SERVER_LISTEN_SOCK 0 /* 监听 Socket 索引 */
#endif
/*
* 缓冲区大小配置
*/
#ifndef NET_SEND_BUF_SIZE
#define NET_SEND_BUF_SIZE 4096 /* 发送缓冲区大小(字节) */
#endif
#ifndef NET_RECV_BUF_SIZE
#define NET_RECV_BUF_SIZE 4096 /* 接收缓冲区大小(字节) */
#endif
/*
* 超时时间配置(毫秒)
* 0 = 无限等待(阻塞模式)
*/
#ifndef NET_CONNECT_TIMEOUT_MS
#define NET_CONNECT_TIMEOUT_MS 5000 /* 连接超时 */
#endif
#ifndef NET_ACCEPT_TIMEOUT_MS
#define NET_ACCEPT_TIMEOUT_MS 0 /* 接受连接超时(0=无限等待) */
#endif
#ifndef NET_SEND_TIMEOUT_MS
#define NET_SEND_TIMEOUT_MS 1000 /* 发送超时 */
#endif
#ifndef NET_RECV_TIMEOUT_MS
#define NET_RECV_TIMEOUT_MS 30000 /* 接收超时(30秒,0=无限等待) */
#endif
/*
* TCP KeepAlive 配置
*/
#ifndef NET_KEEPALIVE_IDLE_MS
#define NET_KEEPALIVE_IDLE_MS 7200000 /* KeepAlive 空闲时间(默认2小时) */
#endif
#ifndef NET_KEEPALIVE_INTVL_MS
#define NET_KEEPALIVE_INTVL_MS 75000 /* KeepAlive 探测间隔(默认75秒) */
#endif
#ifndef NET_KEEPALIVE_CNT
#define NET_KEEPALIVE_CNT 9 /* KeepAlive 探测次数(默认9次) */
#endif
/*
* select/poll 最大 fd 数量
*/
#ifndef NET_SELECT_MAX_FDS
#define NET_SELECT_MAX_FDS NET_MAX_SOCKETS
#endif
/*
* 轮询延时配置(毫秒)
*/
#ifndef NET_POLL_DELAY_MS
#define NET_POLL_DELAY_MS 1 /* 非阻塞轮询延时 */
#endif
/*
* 消息队列配置
*/
#ifndef NET_MSG_QUEUE_LENGTH
#define NET_MSG_QUEUE_LENGTH 8 /* 消息队列深度 */
#endif
#ifdef __cplusplus
}
#endif
#endif /* NET_CONFIG_H */