📄 main.c
字号:
//------------------------------------------------------------------------------
//
// filename : initmcu.c
// funcation : initialize the resoucre of hardware
// designer : lrx
// time : 2005-5-11 10:35
// All right are reserved
//
//------------------------------------------------------------------------------
#define MAIN_GLOBAL 1
#include "includes.h"
void main(void)
{
InitMcu();
clr_watchdog();
Init_Flash();
#ifdef DEBUG_SYS
u1tb = Read_All_Para();
#endif
clr_watchdog();
Init_Timer();
clr_watchdog();
Init_Systask();
clr_watchdog();
#ifdef DEBUG_AT
Uart1Send("0001");
#endif
AlarmTaskid = Create_Task(Init_Alarm,AlarmTaskEntry);
HandsetTaskid = Create_Task(Init_Handset,HandsetTaskEntry);
GprsTaskid = Create_Task(Init_Gprs,GprsTaskEntry);
#ifdef DEBUG_AT //added lxo 122931 for reset test
Uart1Send("ResetMemory is");
Uart1Word(ResetMemory);
if(ResetMemory==0x5a)
Uart1Send("Warm reset!");
#endif
ResetMemory=0x5a;
Task_Schedule();
}
uchar SoftwareCrcCheck(void)
{
WORD m;
WORD crc;
UCHAR ch;
UCHAR txt[4];
DWORD offset;
m = 0;
crc = FCS_START;
for(m=0; m<0x8000; m++)
{
ch = Read_Sector_Byte(UPDATESECTOR,m);
crc = FCS(crc,ch);
clr_watchdog();
}
crc ^= FCS_START;
if(crc != soft.crc1)
{
#ifdef DEBUG_AT
Uart1Word(crc);
Uart1Word(soft.crc1);
Uart1Send("ERR IN CRC1");
#endif
return FALSE;
}
m = 0;
crc = FCS_START;
for(m=0; m<0x8000; m++)
{
ch = Read_Sector_Byte(UPDATESECTOR+8,m);
crc = FCS(crc,ch);
clr_watchdog();
}
crc ^= FCS_START;
if(crc != soft.crc2)
{
#ifdef DEBUG_AT
Uart1Word(crc);
Uart1Word(soft.crc2);
Uart1Send("ERR IN CRC2");
#endif
return FALSE;
}
m = 0;
crc = FCS_START;
for(m=0; m<0x8000; m++)
{
ch = Read_Sector_Byte(UPDATESECTOR+16,m);
crc = FCS(crc,ch);
clr_watchdog();
}
crc ^= FCS_START;
if(crc != soft.crc3)
{
#ifdef DEBUG_AT
Uart1Word(crc);
Uart1Word(soft.crc3);
Uart1Send("ERR IN CRC3");
#endif
return FALSE;
}
m = 0;
crc = FCS_START;
for(m=0; m<0x8000; m++)
{
ch = Read_Sector_Byte(UPDATESECTOR+24,m);
crc = FCS(crc,ch);
clr_watchdog();
}
crc ^= FCS_START;
if(crc != soft.crc4)
{
#ifdef DEBUG_AT
Uart1Word(crc);
Uart1Word(soft.crc4);
Uart1Send("ERR IN CRC4");
#endif
return FALSE;
}
return TRUE;
}
void UpdateNewCode(void)
{
UCHAR *ptest;
ptest = (UCHAR *)(0x2800);
asm("FCLR I");
_Memcpy(ptest, (UCHAR FAR *)(0xfe000), 0x300);
asm("JMP.A 2880H");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -