void set_default(void) // ÉèÖÃĬÈÏMAC¡¢IP¡¢GW¡¢SUB¡¢DNS
{
uint8 mac[6]={0x00,0x08,0xdc,0x11,0x11,0x11}; //Íø¿ÚÎïÀíµØÖ·
//uint8 lip[4]={192,168,1,112};
uint8 lip[4]={192,168,222,23}; //stm32×÷Ϊ·þÎñÆ÷IPµØÖ·
//--------20220411 gxs add IPµØÖ·¿ÉÑ¡-----------
//uint8 lip[4]={192,168,222,temp_address1}; //ÉèÖÃеÄIPµØÖ·
//----------------------------------------------
uint8 sub[4]={255,255,255,0}; //stm32×÷Ϊ·þÎñÆ÷×ÓÍøÑÚÂë
//uint8 gw[4]={192,168,1,1};
uint8 gw[4]={192,168,222,254}; //stm32×÷Ϊ·þÎñÆ÷ĬÈÏÍø¹Ø
//uint8 dns[4]={114,114,114,114};
uint8 dns[4]={8,8,8,8}; //DNS
//--------20220411 gxs add IPµØÖ·¿ÉÑ¡-----------
alt_u16 temp_address;
alt_u16 temp_address0;
alt_u8 temp_address1;
alt_u8 temp_address2;
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB , ENABLE);
//ʹÄÜPORTA,PORTCʱÖÓ
GPIO_InitStructure.GPIO_Pin =GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_9; //Ñ¡ÔñÒª¿ØÖƵÄGPIOÒý½Å
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //ÉèÖÃÒý½ÅËÙÂÊΪ50MHz
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; //ÉèÖÃÒý½ÅģʽΪÉÏÀÊäÈë
GPIO_Init(GPIOB, &GPIO_InitStructure); //µ÷Óÿ⺯Êý£¬³õʼ»¯GPIO
//read PB6,PB7 PB9
temp_address = GPIO_ReadInputData(GPIOB);
temp_address0 = temp_address & 0x02C0; //0x02C0 = 0000 0010 1100 0000
temp_address0 = temp_address0 >> 6;
temp_address1 = (alt_u8) temp_address0; //ת»»Îª8bit
if(b_CheckBit(temp_address1, 3))
{
b_SetBit(temp_address1,2);
b_ClearBit(temp_address1,3);
}
else
{
b_ClearBit(temp_address1,2);
b_ClearBit(temp_address1,3);
}
temp_address1 = temp_address1 + 16;
lip[3]=temp_address1; //stm32×÷Ϊ·þÎñÆ÷еÄIPµØÖ·
//----------------------------------------------
memcpy(ConfigMsg.lip, lip, 4);
memcpy(ConfigMsg.sub, sub, 4);
memcpy(ConfigMsg.gw, gw, 4);
memcpy(ConfigMsg.mac, mac,6);
memcpy(ConfigMsg.dns,dns,4);
ConfigMsg.dhcp=0;
ConfigMsg.debug=1;
ConfigMsg.fw_len=0;
ConfigMsg.state=NORMAL_STATE;
ConfigMsg.sw_ver[0]=FW_VER_HIGH;
ConfigMsg.sw_ver[1]=FW_VER_LOW;
}
|