Example #1
0
void Psysinit(void){
	InitPicture();
	InitSound();

	Psys_CSRX=0;
	Psys_CSRY=0;
	Psys_FREEMEM=1024;
	Psys_ERR=0;
	Psys_ERL=0;
	Psys_RESULT=0;
	Psys_TCHX=0;
	Psys_TCHY=0;
	Psys_TCHST=0;
	Psys_TCHTIME=0;
	Psys_MAINCNTL=0;
	Psys_MAINCNTH=0;
	Psys_TABSTEP=0;
	Psys_ICONPUSE=0;
	Psys_ICONPAGE=0;
	Psys_ICONPMAX=0;
	Psys_FUNCNO=0;
	Psys_FREEVAR=VAR_MAX;
	Psys_SYSBEEP=1;
	memset(Psys_TIME,0x00,sizeof(Psys_TIME));
	memset(Psys_DATE,0x00,sizeof(Psys_DATE));
	memset(Psys_MEM,0x00,sizeof(Psys_MEM));

	consolecolor=0;
	panelmode=PNLMD_KYA;
	runmode=RMD_STOP;
	memset(keybuffer,0x00,sizeof(keybuffer));
	kbd_shift_flag=0;
	keybuffer_qhead=0;
	keybuffer_qtail=0;
	memset(BGData,0x00,sizeof(BGData));
	bgpage=0;
	bgclip_x_begin[0]=0;bgclip_x_begin[1]=0;
	bgclip_x_end[0]=31;bgclip_x_end[1]=31;
	bgclip_y_begin[0]=0;bgclip_y_begin[1]=0;
	bgclip_y_end[0]=23;bgclip_y_end[1]=23;
	memset(bgofs_nowx,0x00,sizeof(bgofs_nowx));
	memset(bgofs_nowy,0x00,sizeof(bgofs_nowy));
	memset(bgofs_destx,0x00,sizeof(bgofs_destx));
	memset(bgofs_desty,0x00,sizeof(bgofs_desty));
	memset(bgofs_time,0x00,sizeof(bgofs_time));
	memset(ForGosub_s,0x00,sizeof(ForGosub_s));
	ForGosub_sl=0;
	error_occured_token=0;
	memset(srcline_begin_token_pos,0x0000,sizeof(srcline_begin_token_pos));
	memset(srcline_token_count,0x0000,sizeof(srcline_token_count));
	srclinecount=0;
	source_ptr=(unsigned char *)malloc(sizeof(unsigned char)*100);//とりあえずmalloc
    if((source_ptr==NULL)){printf("Can't malloc(init)");return ;}
	memset(source_ptr,0x00,sizeof(source_ptr));
	memset(labellist_name,0x00,sizeof(labellist_name));
	memset(labellist_line,0x00,sizeof(labellist_line));
	data_read_ptr=0;
	labelcount=0;
	keyboard_special=0;
	ClearDim();
	return;
}
Example #2
0
/*************************************************************
*函数名称:void I2cFramePro(I2CRcvFrame *frame)
*函数功能:接收帧处理
*参    数:数据帧
*返    回:null
*************************************************************/
void I2cFramePro ( void )
{
    unsigned char MODUDATACS = 0;
    ModuLenNumStruct *p_modu;
    unsigned char i = 0;
    p_modu = &ModuTemp;

    /*检查是否是升级命令*/

    if ( I2Cuse[0] == 0x55 && I2Cuse[2] == 0x04 && I2Cuse[5] == 0xaa )
        {
            I2Csend[0] = 0x55;
            I2Csend[1] = 0x00;
            I2Csend[2] = 0x06;
            I2Csend[3] = 0x40;
            I2Csend[4] = 0x13;
            I2Csend[5] = 0xaa;
            ClearDim ( I2Cuse, sizeof ( I2Cuse ) / sizeof ( char ) );
            return;
        }

    if ( I2Cuse[0] == 0x55 && I2Cuse[5] == 0xAA && I2Cuse[2] == 0x00 )
        {
            SYS_UnlockReg();
            FMC->ISPCON = FMC_ISPCON_BS_LDROM;
            _SYS_RESET_CPU();//从LD 启动
        }

    if ( I2Cuse[0] != FRAME_HEAD1 || I2Cuse[I2Cuse[2] - 1] != FRAME_REAR ) //针头和针尾
        {
            g_I2Cupdate = 0;
            return;
        }

    I2Cchkxor = 0;

    for ( i = 0; i < I2Cuse[2] - 2; i++ )			//cs 为针头到CS前的异或校验
        {
            I2Cchkxor ^= I2Cuse[i];
        }

    if ( I2Cchkxor != I2Cuse[I2Cuse[2] - 2] )
        {
            I2Cchkxor = 0;
            return;
        }

    I2Cchksum = 0;

    for ( i = 0; i < I2Cuse[2] - 2; i++ )			//cs 为针头到CS前的异或校验
        {
            I2Cchksum += I2Cuse[i];
        }

    if ( I2Cuse[2] != 0x05 )			//设置模块任务
        {
            I2Cuse[I2Cuse[2] - 2] = I2Cchksum;
            RS485_Send ( I2Cuse, I2Cuse[2] );
            DelayMs ( 10 );
            Inquire ( I2Cuse[1] );
            DelayMs ( 10 );
            ClearDim ( I2Cuse, ( sizeof ( I2Cuse ) / sizeof ( char ) ) );
        }

    else if ( I2Cuse[2]  == 5 ) //选择模块(0-10)
        {
            I2Cchoosed_M = I2Cuse[1];
            *p_modu = I2cSwitchModu ( I2Cchoosed_M );

            if ( I2Cchoosed_M != 0x00 )
                {
                    I2Csend[0] = 0xf5;
                    I2Csend[1] = I2Cchoosed_M;
                    I2Csend[2] = 6 + p_modu ->DataLen;
                    I2Csend[3] = p_modu->ModuType;

                    for ( i = 0; i < p_modu->DataLen; i++ )
                        {
                            I2Csend[4 + i] = p_modu->ModuData[i];
                        }

                    I2Csend[4 + p_modu->DataLen] = 0;

                    for ( i = 0; i < 4 + p_modu->DataLen; i++ )
                        {
                            MODUDATACS ^= I2Csend[i];
                        }

                    I2Csend[4 + p_modu->DataLen] = MODUDATACS;
                    I2Csend[5 + p_modu->DataLen] = 0XAA;
                }

            else
                {
                    I2Csend[0] = 0xf5; //主模块
                    I2Csend[1] = 0x00;
                    I2Csend[2] = 11;
                    MainModu.POWERA = ADC_CH ( FourDataAdc ( ADCtempA ) );
                    MainModu.POWERB = ADC_CH ( FourDataAdc ( ADCtempB ) );
                    I2Csend[5] = MainModu.POWERA >> 8;
                    I2Csend[6] = MainModu.POWERA;
                    I2Csend[3] = MainModu.POWERB >> 8;
                    I2Csend[4] = MainModu.POWERB;
                    I2Csend[7] = MainModu.Inserted >> 8;
                    I2Csend[8] = MainModu.Inserted;
                    I2Csend[9] = 0;

                    for ( i = 0; i < 9; i++ )
                        {
                            I2Csend[9] ^= I2Csend[i];
                        }

                    I2Csend[10] = 0xAA;
                }

            ClearDim ( I2Cuse, ( sizeof ( I2Cuse ) / sizeof ( char ) ) );
        }