注意: 自 FreeRTOS V4.0.0 起,这些堆栈初始化 API 已被弃用
。请参阅
初始化 TCP/IP 堆栈
了解支持 IPv6、多个端点和多个接口的新 API。如需使用已弃用的 API ,请将
FreeRTOSIPConfig.h 头文件中的 ipconfigIPv4_BACKWARD_COMPATIBLE 设置为 1。
此页详细描述了
FreeRTOS_IPInit()
以及当“网络启用”和“网络关闭”事件发生时被调用的
回调函数
。
FreeRTOS_IPInit()
必须是第一个被调用的 FreeRTOS-Plus-TCP 函数。 FreeRTOS_IPInit() 可在
RTOS 调度器启动之前或之后调用。
FreeRTOS_IPInit () 会创建 FreeRTOS-Plus-TCP RTOS 任务。 FreeRTOS-Plus-TCP 任务
会配置和初始化网络接口。 如果 ipconfigUSE_NETWORK_EVENT_HOOK
在 FreeRTOSIPConfig.h 中设置为 1,
当网络准备就绪时,TCP/IP 堆栈
vIPNetworkEventHook()
将调用回调函数。
以下为两个示例。 第一个示例演示了 FreeRTOS_IPInit()。
第二个示例演示了 vIPNetworkEventHook()。
static uint8_t ucMACAddress[ 6 ] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };
static const uint8_t ucIPAddress[ 4 ] = { 10, 10, 10, 200 };
static const uint8_t ucNetMask[ 4 ] = { 255, 0, 0, 0 };
static const uint8_t ucGatewayAddress[ 4 ] = { 10, 10, 10, 1 };
static const uint8_t ucDNSServerAddress[ 4 ] = { 208, 67, 222, 222 };
int main( void )
{
FreeRTOS_IPInit( ucIPAddress,
ucNetMask,
ucGatewayAddress,
ucDNSServerAddress,
ucMACAddress );
vTaskStartScheduler();
for( ;; );
}
Example use of the FreeRTOS_IPInit() API function
void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
{
static BaseType_t xTasksAlreadyCreated = pdFALSE;
if( eNetworkEvent == eNetworkUp )
{
if( xTasksAlreadyCreated == pdFALSE )
{
xTasksAlreadyCreated = pdTRUE;
}
}
}
Example vApplicationIPNetworkEventHook() definition
<<
返回 RTOS TCP 网络教程索引
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.