📄 configcbk.c
字号:
/****************************************************************************
*
* Name: VLANCbk.c
*
* Description: Call Back Function
*
* Copyright: ASEC
* All rights reserved.
*
****************************************************************************/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "tfTypes.h"
#include "fs.h"
#include "httpd.h"
#include "html.h"
#include "config.h"
#include "ip113f.h"
#include "eeprom.h"
static char httpbuf[50]=" ";
extern struct httpd_state *hs;
extern variable_t var_list[];
extern int statusData;
int controlData;
extern int sign;
extern int stNo;
u8_t ssiModuleConfig(u8_t varid, value_t *vp)
{
u8_t *sel;
switch (varid)
{
case TGI_CONFIG_NO:
sprintf(httpbuf,"%d module",stNo);
vp->value.string = httpbuf;
vp->type = string;
break;
case TGI_SPEED_100M:
if(controlData&0x0008)
vp->value.string = "CHECKED";
else
vp->value.string = "";
vp->type = string;
break;
case TGI_SPEED_10M:
if(controlData&0x0008)
vp->value.string = "";
else
vp->value.string = "CHECKED";
vp->type = string;
break;
case TGI_DUPLEX_FULL:
if(controlData&0x0010)
vp->value.string = "CHECKED";
else
vp->value.string = "";
vp->type = string;
break;
case TGI_DUPLEX_HALF:
if(controlData&0x0010)
vp->value.string = "";
else
vp->value.string = "CHECKED";
vp->type = string;
break;
case TGI_AN_EN:
if(controlData&0x0004)
vp->value.string = "CHECKED";
else
vp->value.string = "";
vp->type = string;
break;
case TGI_AN_DIS:
if(controlData&0x0004)
vp->value.string = "";
else
vp->value.string = "CHECKED";
vp->type = string;
break;
case TGI_FC_EN:
vp->value.string = "CHECKED";
vp->type = string;
break;
/* case TGI_FC_DIS:
vp->value.string = "";
vp->type = string;
break;
*/
case TGI_LLFP_ENABLE:
if(DATA_GETBIT(controlData, 15)==1)
vp->value.string = "CHECKED";
else
vp->value.string = "";
vp->type = string;
break;
case TGI_LLFP_DISABLE:
if(DATA_GETBIT(controlData, 15)==1)
vp->value.string = "";
else
vp->value.string = "CHECKED";
vp->type = string;
break;
default:
vp->value.string = NULL;
vp->type = string;
break;
}
return OK;
}
u8_t tgiModuleConfig(u8_t cnt, value_t *vp1)
{
unsigned char sendbuf[9];
unsigned int c;
unsigned char up1;
unsigned char low1;
if ((strncmp(var_list[7].value, "Apply", 5)==0)||(strncmp(var_list[5].value, "Apply", 5)==0)||(strncmp(var_list[6].value, "Apply", 5)==0) )
{
controlData=statusData;
if(stNo<10)
{
sendbuf[1]='0';
sendbuf[2]=stNo+'0';
}
else
{
sendbuf[1]='1';
sendbuf[2]=stNo-10+'0';
}
//write to w78e58b
sendbuf[0]='w';//select func number
sendbuf[3]='2';
sendbuf[4]='2';
if (strncmp(var_list[0].value, "100M", 4)==0)
{
controlData |=0x0008;// Set Speed 100M
}
else if (strncmp(var_list[0].value, "10M", 4)==0)
{
controlData &=0xfff7; // Set Speed 10M
}
// Duplex - bit4
if (strncmp(var_list[1].value, "Full", 4)==0)
{
controlData |=0x0010;// Set Duplex Full
}
else if (strncmp(var_list[1].value, "Half", 3)==0)
{
controlData &=0xffef; // Set Duplex Half
}
// Auto-Negotitation - bit2
if (strncmp(var_list[2].value, "Enable", 6)==0)
{
controlData |=0x0004;// Set AN Enable
}
else if (strncmp(var_list[2].value, "Disable", 7)==0)
{
controlData &=0xfffb; // Set AN Disable
}
// Flow Control - bit5
if (strncmp(var_list[3].value, "Enable", 6)==0)
{
controlData |=0x0020;// Set Flow control enable
}
if (strncmp(var_list[4].value, "Enable", 6)==0)
{
controlData |=0x8000;// Set LFP Enable
}
else if (strncmp(var_list[4].value, "Disable", 7)==0)
{
controlData &=0x7fff; // Set LFP Disable
}
c=(controlData>>12)&0x0f;
if((c>=0)&&(c<=9))
sendbuf[5]=c+'0';
else if((c>=0xa)&&(c<=0xf))
sendbuf[5]=c-10+'a';
c=(controlData>>8)&0x0f;
if((c>=0)&&(c<=9))
sendbuf[6]=c+'0';
else if((c>=0xa)&&(c<=0xf))
sendbuf[6]=c-10+'a';
c=(controlData>>4)&0x0f;
if((c>=0)&&(c<=9))
sendbuf[7]=c+'0';
else if((c>=0xa)&&(c<=0xf))
sendbuf[7]=c-10+'a';
c=controlData&0x0f;
if((c>=0)&&(c<=9))
sendbuf[8]=c+'0';
else if((c>=0xa)&&(c<=0xf))
sendbuf[8]=c-10+'a';
putstr(sendbuf); //设置ip113F
Delay(500);
up1=(unsigned char)((controlData>>8)&0xff);
low1=(unsigned char)(controlData&0xff);
// write93c66_word(stNo,controlData);
_24c16_eeprom_word_write(256+2*stNo, up1);
Delay(100);
_24c16_eeprom_word_write(256+2*stNo+1, low1);
Delay(500);
httpd_send_file(fs_open3("config.htm"));
}
// httpd_send_file(fs_open3("config.htm"));
// <script language=javalanguage>parent.main.location.reload();</script>
return OK;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -