This commit is contained in:
qiyongshuang
2024-02-26 13:22:09 +08:00
parent 0ad592325e
commit 9596a13c17
573 changed files with 36301 additions and 23003 deletions
-1
View File
@@ -243,5 +243,4 @@
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
<storageModule moduleId="refreshScope"/>
</cproject>
+26 -4
View File
@@ -2339,6 +2339,28 @@ char * DataLocate(char *buf, char *name)
return p;
}
/*********************************************************************
* @fn atoh
*
* @brief Converting character to hexadecimal number
*
* @param src - character
*
* @return hexadecimal number
*/
uint8_t atoh(uint8_t *src)
{
uint8_t desc;
if((*src >= '0') && (*src <= '9'))
desc = *src - 0x30;
else if((*src >= 'a') && (*src <= 'f'))
desc = *src - 0x57;
else if((*src >= 'A') && (*src <= 'F'))
desc = *src - 0x37;
return desc;
}
/*********************************************************************
* @fn Refresh_Basic
*
@@ -2368,10 +2390,10 @@ void Refresh_Basic(u8 *buf)
if(q == NULL) return;
memcpy(temp, p, (q - p));
p = strtok(temp, ".");
BasicCfg.mac[0] = atoi(p);
(strlen(p) == 1) ? (BasicCfg.mac[0] = atoh(p)) : (BasicCfg.mac[0] = atoh(p) << 4 | atoh(p + 1));
for (i = 1; i < 6; i++) {
p = strtok(NULL, ".");
BasicCfg.mac[i] = atoi(p);
(strlen(p) == 1) ? (BasicCfg.mac[i] = atoh(p)) : (BasicCfg.mac[i] = atoh(p) << 4 | atoh(p + 1));
}
}
else return;
@@ -2790,11 +2812,11 @@ void Init_Para_Tab(void)
Para_Basic[0].para = "__AMAC";
memset(s, 0, 30);
snprintf(s, 30, "%d.%d.%d.%d.%d.%d", Basic_CfgBuf.mac[0], Basic_CfgBuf.mac[1],
snprintf(s, 30, "%x.%x.%x.%x.%x.%x", Basic_CfgBuf.mac[0], Basic_CfgBuf.mac[1],
Basic_CfgBuf.mac[2], Basic_CfgBuf.mac[3], Basic_CfgBuf.mac[4],
Basic_CfgBuf.mac[5]);
strcpy(Para_Basic[0].value, s);
printf("__ASIP = %s\n", Para_Basic[0].value);
printf("__ASMAC = %s\n", Para_Basic[0].value);
Para_Basic[1].para = "__ASIP";
memset(s, 0, 30);
+6 -10
View File
@@ -150,6 +150,7 @@ void WCHNET_CreateCfgSocket(u8 mode, u8 *Desip, u16 Desport, u16 Srcport)
*/
void WCHNET_RestoreDefaults(void) /*WCHNET restore default settings*/
{
WCHNET_GetMacAddr(&Basic_Default[2]);
WEB_ERASE( PAGE_WRITE_START_ADDR, FLASH_PAGE_SIZE * 3);
WEB_WRITE( BASIC_CFG_ADDR, Basic_Default, BASIC_CFG_LEN);
WEB_WRITE( PORT_CFG_ADDR, Port_Default, PORT_CFG_LEN);
@@ -287,18 +288,13 @@ int main(void)
WEB_READ( BASIC_CFG_ADDR, (u8 *)&Basic_CfgBuf, BASIC_CFG_LEN ); //Read configuration information
WEB_READ( PORT_CFG_ADDR, (u8 *)&Port_CfgBuf, PORT_CFG_LEN );
WEB_READ( LOGIN_CFG_ADDR, (u8 *)&Login_CfgBuf, LOGIN_CFG_LEN );
if((Basic_CfgBuf.flag[0] != 0x57) || (Basic_CfgBuf.flag[1] != 0xAB)){ //Determine network configuration information flags
/*Determine configuration information*/
if(((Basic_CfgBuf.flag[0] != 0x57) || (Basic_CfgBuf.flag[1] != 0xAB)) ||\
((Port_CfgBuf.flag[0] != 0x57) || (Port_CfgBuf.flag[1] != 0xAB)) ||\
((Login_CfgBuf.flag[0] != 0x57) || (Login_CfgBuf.flag[1] != 0xAB)))
{
WCHNET_RestoreDefaults();
}
else {
if((Port_CfgBuf.flag[0] != 0x57) || (Port_CfgBuf.flag[1] != 0xAB)){ //Determine password configuration information
WCHNET_RestoreDefaults();
}
else {
if((Login_CfgBuf.flag[0] != 0x57) || (Login_CfgBuf.flag[1] != 0xAB)) //Determine password configuration information
WCHNET_RestoreDefaults();
}
}
memcpy(MACAddr, Basic_CfgBuf.mac, 6);
memcpy(IPAddr, Basic_CfgBuf.ip, 4);
memcpy(IPMask, Basic_CfgBuf.mask, 4);
@@ -111,10 +111,10 @@ static void SetSysClockTo144_HSI( void );
void SystemInit (void)
{
RCC->CTLR |= (uint32_t)0x00000001;
RCC->CFGR0 &= (uint32_t)0xF8FF0000;
RCC->CFGR0 &= (uint32_t)0xF0FF0000;
RCC->CTLR &= (uint32_t)0xFEF6FFFF;
RCC->CTLR &= (uint32_t)0xFFFBFFFF;
RCC->CFGR0 &= (uint32_t)0xFF80FFFF;
RCC->CFGR0 &= (uint32_t)0xFF00FFFF;
RCC->INTR = 0x009F0000;
SetSysClock();
}