9ceb218f80
Co-authored-by: Cursor <cursoragent@cursor.com>
40 lines
977 B
C
40 lines
977 B
C
/*!
|
|
\file net_init.c
|
|
\brief deferred Ethernet + lwIP bring-up (FreeRTOS task)
|
|
*/
|
|
|
|
#include "net_init.h"
|
|
#include "enet_PHY.h"
|
|
#include "netconf.h"
|
|
|
|
/* Match app_init.h: TASK_SIZE_SIZE_2048 == configMINIMAL_STACK_SIZE * 16 */
|
|
#ifndef NET_INIT_TASK_STACK_WORDS
|
|
#define NET_INIT_TASK_STACK_WORDS ((uint16_t)((configMINIMAL_STACK_SIZE * 16U) / sizeof(StackType_t)))
|
|
#endif
|
|
|
|
static void v_net_init_task(void *arg)
|
|
{
|
|
(void)arg;
|
|
|
|
/* 等待系统其余任务先进入稳定运行态,再启动网络 */
|
|
vTaskDelay(pdMS_TO_TICKS(NET_INIT_DELAY_MS));
|
|
|
|
enet_system_setup();
|
|
|
|
if (enet_hw_is_ready() != 0U) {
|
|
lwip_stack_init();
|
|
}
|
|
|
|
vTaskDelete(NULL);
|
|
}
|
|
|
|
BaseType_t net_init_task_create(void)
|
|
{
|
|
return xTaskCreate(v_net_init_task,
|
|
"NetInit",
|
|
NET_INIT_TASK_STACK_WORDS,
|
|
NULL,
|
|
(UBaseType_t)(tskIDLE_PRIORITY + 1U),
|
|
NULL);
|
|
}
|