新聞中心

stm32 移植uip

作者: 時間:2016-11-13 來源:網(wǎng)絡(luò) 收藏

1stm32定義常量不要code關(guān)鍵字

//定義全1地址常量

本文引用地址:http://butianyuan.cn/article/201611/316361.htm

staticconstuip_ipaddr_tcodeall_ones_addr=

#ifUIP_CONF_IPV6

{0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff};

#else/*UIP_CONF_IPV6*/

{0xffff,0xffff};

#endif/*UIP_CONF_IPV6*/

//定義全0地址常量

staticconstuip_ipaddr_tcodeall_zeroes_addr=

#ifUIP_CONF_IPV6

{0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000};

#else/*UIP_CONF_IPV6*/

{0x0000,0x0000};

#endif/*UIP_CONF_IPV6*/

2為兩個回調(diào)函數(shù)定義函數(shù)實(shí)體

#defineUIP_APPCALL()uip_appcall() //宏定義注冊回調(diào)函數(shù)

#defineUIP_UDP_APPCALL()uip_udp_appcall()//宏定義注冊回調(diào)函數(shù)

voiduip_appcall(void)

{

}

voiduip_udp_appcall(void)

{

}

3MDK環(huán)境下空指令函數(shù)修改

并且不要#include

//_nop_();

__nop();//在MDK環(huán)境下是__nop();

4為uip提供周期時鐘

5修改大小端配置

51是大端,stm32是小端

#defineUIP_CONF_BYTE_ORDERUIP_LITTLE_ENDIAN//51是大端,stm32是小端

在uip_conf.h文件中

6修改類型定義

typedefunsignedshortintu16_t;//和C51有點(diǎn)差別也是在uip_conf.h文件中

7初始化TCP/IP通信必須用到的參數(shù)

uip在運(yùn)行過程中不會再去查詢網(wǎng)卡的mac地址,

所以開始就要初始化mac地址

uip_ipaddr(uip_hostaddr,192,168,1,198);

uip_ipaddr(uip_draddr,192,168,1,100);

uip_ipaddr(uip_netmask,255,255,255,0);

uip_ethaddr.addr[0]=0x00;

uip_ethaddr.addr[1]=0x0C;

uip_ethaddr.addr[2]=0x29;

uip_ethaddr.addr[3]=0xD2;

uip_ethaddr.addr[4]=0x58;

uip_ethaddr.addr[5]=0x6B;



關(guān)鍵詞: stm32移植ui

評論


技術(shù)專區(qū)

關(guān)閉