46 lines
853 B
C
46 lines
853 B
C
/*
|
|
* sys_arch.c - STM32F407VET6 平台的 LwIP 系统移植层
|
|
*
|
|
* 实现无操作系统版本的 LwIP 系统接口
|
|
*/
|
|
|
|
#include "lwip/opt.h"
|
|
#include "lwip/sys.h"
|
|
#include "lwip/debug.h"
|
|
#include "stm32f4xx_hal.h"
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
/* 系统错误处理 */
|
|
void sys_assert(const char *msg)
|
|
{
|
|
/* 打印错误信息并停机 */
|
|
printf("Assertion failed: %s\n", msg);
|
|
while (1);
|
|
}
|
|
|
|
/* 获取当前系统时间(毫秒) */
|
|
u32_t sys_now(void)
|
|
{
|
|
return HAL_GetTick();
|
|
}
|
|
|
|
/* 内存分配函数 */
|
|
void *sys_malloc(size_t size)
|
|
{
|
|
return malloc(size);
|
|
}
|
|
|
|
/* 内存释放函数 */
|
|
void sys_free(void *mem)
|
|
{
|
|
free(mem);
|
|
}
|
|
|
|
/* 初始化系统接口 */
|
|
void sys_init(void)
|
|
{
|
|
/* 系统时间已经由 HAL_Init() 初始化 */
|
|
LWIP_DEBUGF(SYS_DEBUG, ("sys_init: STM32F407VET6 sys_arch initialized\n"));
|
|
}
|