void RXLCD_clear (unsigned char Color) { Active_Window(0,479,0,271);//设置区域显示窗口 Text_Foreground_Color1(0xffff);//前景颜色设定 Text_Background_Color1(0xffff);//背景颜色设定 Write_Dir(0X8E,0X80);//开始清屏(显示窗口) Delay10ms(5); }
void key(void) { unsigned char i; if(K2==0) //¼ì²â°´¼üK1ÊÇ·ñ°´Ï { Delay10ms(); //Ïû³ý¶¶¶¯ if(K2==0) { keyvalue +=1; if(keyvalue==11) { keyvalue=0; } while((i<50)&&(K2==0)) //¼ì²â°´¼üÊÇ·ñËÉ¿ª { Delay10ms(); i++; } i=0; } } if(K3==0) //¼ì²â°´¼üK1ÊÇ·ñ°´Ï { Delay10ms(); //Ïû³ý¶¶¶¯ if(K3==0) { keyvalue -=1; if(keyvalue==0) { keyvalue=11; } while((i<50)&&(K3==0)) //¼ì²â°´¼üÊÇ·ñËÉ¿ª { Delay10ms(); i++; } i=0; } } expect_V =(1.938+0.19624*keyvalue)*1000; }
void key(void) { unsigned char i; if(K2==0) //¼ì²â°´¼üK1ÊÇ·ñ°´Ï { Delay10ms(); //Ïû³ý¶¶¶¯ if(K2==0) { HIHGDUTY += 10; LOWDUTY -= 10; if(HIHGDUTY==1700) { HIHGDUTY=300; LOWDUTY=1700; } while((i<50)&&(K2==0)) //¼ì²â°´¼üÊÇ·ñËÉ¿ª { Delay10ms(); i++; } i=0; } } if(K1==0) { Delay10ms(); //Ïû³ý¶¶¶¯ if(K1==0) { HIHGDUTY -= 10; LOWDUTY += 10; if(HIHGDUTY==300) { HIHGDUTY=1700; LOWDUTY=300; } while((i<50)&&(K1==0)) //¼ì²â°´¼üÊÇ·ñËÉ¿ª { Delay10ms(); i++; } i=0; } } }
/* *函数名:I2C_ByteWrite *函数功能:向设备dadr的addr地址处写入byte *输入:dadr,addr,byte *输出:-- */ void I2C_ByteWrite(unsigned char dadr,addr,byte) { I2C_Start(); I2C_SendByte(dadr); I2C_SendByte(addr); I2C_SendByte(byte); I2C_Stop(); Delay10ms(); //延时等待写入,Write Cycle Time=10ms }
main() {//定義pp為無正負字元變數其值為0x1 unsigned char pp=0x8 ; int Step ; //定義Step為整數變數 for(Step=0;Step<(n+1);Step++) {//若Step<n+1,則繼續執行迴圈 P0=pp ; //推動步進馬達 pp>>=1 ; //向左旋一位 if(pp==0x00) //若pp=0x10則 pp=0x8 ; //還原資料 Delay10ms() ; //呼叫延遲10毫秒 } }
void Hub_ClearFeature(unsigned char feature,unsigned char port) { Chirp(); if(feature == 0x10) { port_change[port - 1] &= ~C_PORT_CONN; if(Disconnecting) { switch(Disconnecting) { case 1: Connect = 6; OnDongleOK(); Delay10ms(20); break; case 2: Connect = 4; Delay10ms(15); break; case 3: Disconnect = 5; Delay10ms(20); break; case 4: Disconnect = 1; Delay10ms(20); break; case 5: Disconnect = 4; Delay10ms(20); break; } Disconnecting = 0; } } else if(feature == 0x14) { port_change[port - 1] &= ~C_PORT_RESET; Address = 0; } }
void Layers_Progressive(void) { unsigned char temp; Write_Command(0x52);//LTPR0 temp = Read_Data(); temp&=0xf8; temp|=0x02; Write_Data(temp); Write_Command(0x53);//LTPR1 for(temp=0;temp<9;temp++) { Write_Data(temp); Delay10ms(100); } }
void KeyDown(void) { char a=0; GPIO_KEY=0x0f; if(GPIO_KEY!=0x0f)//╤ах║╟╢╪Эйг╥Я╟╢об { Delay10ms();//ясй╠10ms╫ЬппоШ╤╤ if(GPIO_KEY!=0x0f)//ты╢н╪Л╡Б╪Эелйг╥Я╟╢об { //╡Бйтап GPIO_KEY=0X0F; switch(GPIO_KEY) { case(0X07): KeyValue=0;break; case(0X0b): KeyValue=1;break; case(0X0d): KeyValue=2;break; case(0X0e): KeyValue=3;break; } //╡Бйтпп GPIO_KEY=0XF0; switch(GPIO_KEY) { case(0X70): KeyValue=KeyValue;break; case(0Xb0): KeyValue=KeyValue+4;break; case(0Xd0): KeyValue=KeyValue+8;break; case(0Xe0): KeyValue=KeyValue+12;break; } while((a<50)&&(GPIO_KEY!=0xf0)) //╪Л╡Б╟╢╪Экийж╪Л╡Б { Delay10ms(); a++; } } } }
void Hub_SetFeature(unsigned char feature,unsigned char port) { Chirp(); switch(feature) { case 4: port_change[port - 1] |= C_PORT_RESET; Reset = port; Delay10ms(2); break; case 8: HubAddress = UADDR; if(port == 6) { Connect = 1; } break; } }
unsigned char PCF8591_Read(unsigned char channel) { unsigned char dat; IIC_Start_PCF8591(); //向PCF8591的IIC总线发送通信起始信号 IIC_Write_PCF8591(0x90); //向PCF8591的IIC总线发送一位数据:地址控制字(可能需要根据实际情况更改),并选择写操作 if(PCF8591_DA_Flag) //向PCF8591的IIC总线发送一位数据:要读取的频道(加入DA功能是否打开的判断,防止误操作) IIC_Write_PCF8591(channel + 0x40); else IIC_Write_PCF8591(channel); IIC_Stop_PCF8591(); //向PCF8591的IIC总线发送通信结束信号 Delay10ms(); IIC_Start_PCF8591(); //向PCF8591的IIC总线发送通信起始信号 IIC_Write_PCF8591(0x91); //向PCF8591的IIC总线发送一位数据:地址控制字(可能需要根据实际情况更改),并选择读操作 IIC_Read_PCF8591(0); dat = IIC_Read_PCF8591(1); //从PCF8591的IIC总线读取一位数据,并发送NAK IIC_Stop_PCF8591(); //向PCF8591的IIC总线发送通信结束信号 return dat; }
//***************Timer3A_Handler**************** //Plays the Tetris Sound onces at the beginning of each round //Then it deactivates itself until the next round begins //Input: none //Output: none void Timer3A_Handler(void){ TIMER3_ICR_R = 0x01; TIMER3_CTL_R = 0x0000000; //disable TIMER0 // TIMER1_CTL_R = 0x0000000; //disable TIMER1 // TIMER2_CTL_R = 0x0000000; //disable TIMER2 for(int num =0; num < 133; num++){//133 if(TETRIS[num] == Z1) i=5;else i =150; //check if Z1 change the period to 5 Sound_Play2(TETRIS[num]); //play the note Delay10ms(i); //delay after each note usign the value of i } NVIC_ST_CTRL_R =0; //disable SysTick after the song has been played // TIMER0_CTL_R = 0x0000001; //enable TIMER0 // TIMER2_CTL_R = 0x0000001; //enable TIMER2 DisableInterrupts(); Timer0_Init(70000000); //1000000 Timer1_Init(7255); Timer2_Init(30000000); EnableInterrupts(); TIMER3_CTL_R = 0x0000000; //disable TIMER1A }
int16 GetConfigPointer(unsigned char nConfig,char shortConfig) { Chirp(); switch(DevicePort) { case 0: BlinkMode = 2; return HUB_CONFIG_OFFSET; case 1: if(shortConfig) { return PORT1_SHORT_CONFIG_OFFSET; } else { if(nConfig == 3 && !shortConfig) { Delay10ms(10); Connect = 2; } return PORT1_CONFIG_OFFSET; } case 2: if(!shortConfig) { Delay10ms(15); Connect = 3; } return PORT2_CONFIG_OFFSET; case 3: if(!shortConfig) { Delay10ms(10); Disconnect = 2; } return PORT3_CONFIG_OFFSET; case 4: switch(nConfig) { case 0: return PORT4_CONFIG_1_OFFSET; case 1: if(shortConfig) { return PORT4_SHORT_CONFIG_2_OFFSET; } else { return PORT4_CONFIG_2_OFFSET; } case 2: if(!shortConfig) { Delay10ms(20); Connect = 5; Force0DTS = 1; } return PORT4_CONFIG_3_OFFSET; } case 5: WaitJIG = 1; nJigs = 0; return PORT5_CONFIG_OFFSET; } }
//***************************************************************************** // Function : DownloadFtp // Description : App download over FTP. // Input : N/A // Return : N/A // Note : N/A // Globals Changed : N/A //***************************************************************************** BOOLEAN DownloadFtp(void) { int i, wr_ok=0, gf=0; //BYTE lon=0,IP[4]; char filename[32]/*,*tem*/; struct MW_TCP_PORT port2; struct FTPPARAM ftpparam; BYTE ipHost[4]; BYTE puerto[6+7]; BYTE usuario[21]; BYTE clave[21]; // memset(Toptgral.downloadIP,0x00,sizeof(Toptgral.downloadIP)); // strcpy(Toptgral.downloadIP,"174.142.211.61"); //printf("paso 1");getch(0); // strcpy(Toptgral.downloadIP,"210.3.29.84"); // download auth if (DownloadAuth() < 0) { graphicWindow("FALLA auth"); // centerS(3,1,21,"Proceso de"); // centerS(4,1,21,"Autenticacion"); // centerS(6,1,21,"Fallo !!!"); printf("\nAUTH ERR"); // getch(0); Delay10ms(500); return TRUE; } //GetFtpParam(&ftpparam); /*printf("\fIPftp:|%d %d %d %d|", ftpparam.ipHost[0], ftpparam.ipHost[1], ftpparam.ipHost[2], ftpparam.ipHost[3]); GetChar(); printf("\fPtoftp:|%d|", ftpparam.portFtp); GetChar(); printf("\fUsuftp:|%s|", ftpparam.gUsername); GetChar(); printf("\fPassftp:|%s|", ftpparam.gPassword); GetChar();*/ memset(usuario,0x00,sizeof(usuario)); memcpy(&usuario[1], gFtpParam.userID , strlen(gFtpParam.userID)); usuario[0] = strlen(gFtpParam.userID); memset(clave,0x00,sizeof(clave)); split(&clave[1], gtoken_97.worKeyPin, 2); clave[0] = 4; memset(puerto,0x00,sizeof(puerto)); sprintf(puerto, "%d", gFtpParam.portFtp); memset(ipHost,0x00,sizeof(ipHost)); memcpy(ipHost, gFtpParam.ipHost, 4); if( flagFtpManual == TRUE ) { setApn( ); //OJO NOHORA 13 - MAR 2013// printf("\f"); DispLineMW("INFORMACION", MW_LINE1, MW_CENTER|MW_SMFONT); DispLineMW("IP:",MW_LINE2,MW_CENTER|MW_SMFONT); EditIp(ipHost, MW_LINE3); //DispLineMW(buf, MW_LINE3, MW_CENTER|MW_SPFONT); //printf("\f"); DispLineMW("Puerto:", MW_LINE4, MW_CENTER|MW_SMFONT); GetString(puerto, MW_LINE5, 5); //DispLineMW(puerto, MW_LINE5, MW_CENTER|MW_SPFONT); //printf("\f"); DispLineMW("Usuario:", MW_LINE6, MW_CENTER|MW_SMFONT); //memcpy(&usuario[1], gUsername, ); APM_GetKbdSpectra(ALPHA_INPUT_NEW + MW_SPFONT + MW_LINE7 + ECHO, IMIN(1) + IMAX(16), usuario); //DispLineMW(gUsername, MW_LINE7, MW_CENTER|MW_SPFONT); //printf("\f"); DispLineMW("Clave:", MW_LINE8, MW_CENTER|MW_SMFONT); APM_GetKbdSpectra(ALPHA_INPUT_NEW + MW_SPFONT + MW_LINE9 + ECHO, IMIN(1) + IMAX(16), clave); //DispLineMW(gPassword, MW_LINE9, MW_CENTER|MW_SPFONT); //WaitKey(1000, 0); DispLineMW( "REALMENTE", MW_LINE3, MW_CENTER|MW_SMFONT|MW_CLRDISP ); DispLineMW( "DESEA EJECUTAR", MW_LINE4, MW_CENTER|MW_SMFONT ); DispLineMW( "LA DESCARGA FTP ?", MW_LINE5, MW_CENTER|MW_SMFONT ); if( SiNo() != 2 ) // 2 = Press Enter return FALSE; AcceptBeep(); memset(&ftpparam, 0, sizeof(struct FTPPARAM)); memcpy(ftpparam.ipHost, ipHost, 4); ftpparam.portFtp = atoi(puerto); memcpy(ftpparam.userID, &usuario[1], usuario[0]); memcpy(ftpparam.Password, &clave[1],clave[0]); } else{ memset(&ftpparam, 0, sizeof(struct FTPPARAM)); memcpy(ftpparam.ipHost, gToken_96.ipTeleCarga, 4); memset(puerto, 0x00, sizeof(puerto)); memcpy(puerto, gToken_96.puertoTeleCarga, 5); ftpparam.portFtp = atoi(puerto); memcpy(ftpparam.userID, "CNB", 3); split(ftpparam.Password, gtoken_97.worKeyPin, 2); } memcpy(&gFtpParam, &ftpparam, sizeof(struct FTPPARAM)); SaveFtpParam(&gFtpParam); /*printf("\fIPftp2:|%d %d %d %d|", ftpparam.ipHost[0], ftpparam.ipHost[1], ftpparam.ipHost[2], ftpparam.ipHost[3]); GetChar(); printf("\fPtoftp2:|%d|", ftpparam.portFtp); GetChar(); printf("\fUsuftp2:|%s|", ftpparam.gUsername); GetChar(); printf("\fPassftp2:|%s|", ftpparam.gPassword); GetChar();*/ // printf("\fusuario: %s",gUsername);WaitKey(5000,0); // printf("\fpass: %s",gPassword);WaitKey(5000,0); /* DispPutStr("\x12\x1B\x05\x01""Username:\x5\n"); GetString(gUsername, MW_LLINE6, MW_LCOL1, 15); DispPutStr("\x12\x1B\x05\x01Pwd:\x5\n"); GetString(gPassword, MW_LLINE6, MW_LCOL1, 15); */ // memset(gUsername,0x00,sizeof(gUsername)); // strcpy(gUsername,"wwtest"); // strcpy(gUsername,"t800"); // memset(gPassword,0x00,sizeof(gPassword)); // strcpy(gPassword,"1234"); // strcpy(gPassword,"HasFTP.."); // IP[0]=67;IP[1]=210;IP[2]=244;IP[3]=44; /* */ /* IP[0]=200; IP[1]=26; IP[2]=147; IP[3]=234; memcpy(&port2.d_ip, IP, 4); port2.w_port = 21;*/ // port.w_port = Toptgral.downloadPort; ////////////////// /*IP[0]=210; IP[1]=3; IP[2]=29; IP[3]=84;*/ //memcpy(&port2.d_ip, IP, 4); memcpy(&port2.d_ip, gFtpParam.ipHost, 4); port2.w_port = gFtpParam.portFtp; //dumpMemory((BYTE *)&port2,100,1); //printf("\f%s y %s",gUsername,gPassword);getch(0); //////////////// port2.b_sslidx = 0; port2.b_option = 0; // if (GetPPPStatus() != MW_PPP_PHASE_READY){ // PPPSetup(); // PPPConnect(); // } printf("\f"); APM_ConnectPPP(TRUE); // // if (GetPPPStatus() != MW_PPP_PHASE_READY) // return; port2.b_option |= MW_TCP_PPP_MODE; //port2.b_option |= 0x13; /* if (GetPPPStatus() == MW_PPP_PHASE_READY) { int option = 1; PutCharMW(MW_LPUSH_CURSOR); ClrBelow(MW_LLINE2); option = ToggleOption("\x11\x1B\x05\x01Use PPP Channel?", KTrueFalse, option); if (option == -1) return; if (option == 1) { port.b_option |= MW_TCP_PPP_MODE; } PutCharMW(MW_LPOP_CURSOR); } */ /* if ((port.b_option & MW_TCP_PPP_MODE) == 0) { // enable LAN interface if needed if ((bs_lan_status(K_BsLanStatus) & 0x02) == 0) { bs_lan_open(); while ((bs_lan_status(K_BsLanStatus) & 0x02) != 1) { ShowStatus("Enabling LAN...\x05", STS_ERROR); SleepMW(); } } // check LAN cable if (!LanCableInsertedMW()) { ShowStatus("Check Lan Cable!\x05", STS_ERROR); WaitKey(); return; } } */ strcpy(filename, DEV_FTP1); gFtpHandle = OpenMW(filename, 0); if (gFtpHandle==-1) { graphicWindow("FALLA serv"); // centerS(4,1,21,"No se pudo"); // centerS(5,1,21,"Abrir servidor"); //DispPutStr("\x12\x1B\x08\x01\x1C""FTP:Open Fail!\x05\x1D"); CloseAll (); CloseMW(gFtpHandle); // getch(1000); Delay10ms(1000); return TRUE; } memset(gFileList, 0, sizeof(gFileList)); gNumOfFiles = 0; //port2.b_option |= MW_TCP_NO_CLOSE_WAIT; port2.b_option |= 0x13; //ClrBelow(MW_LLINE5); do { // Open FTP if ( FtpOpen(&port2, gFtpParam.userID, gFtpParam.Password ) < 0 ) break; // Get list file if (GetListFile() < 0) break; // Download files for (i=0; i<gNumOfFiles; i++) { gf=GetFile(i); //printf("\f%d\n %d", gf, i);APM_WaitKey(3000,0); if (gf < 0) break; if(gf == 1) continue; if (WriteFileToApp(i) == K_APPDL_RESULT_OKAY) wr_ok = 1; // reboot even have 1 app written } } while (0); // DispPutStr("\x1B\x08\x01\x1C""Closing...\x05\x1D"); CloseAll (); CloseMW(gFtpHandle); // os_disp_putc(MW_LSEL_SMFONT); // os_disp_putc(MW_LREV_ON); //centerS( 8, 1,16, " " ); //printf(" Fin de Proceso \n" ); // os_disp_putc(MW_LSEL_SPFONT); // os_disp_putc(MW_LREV_OFF); //ShowMsgWait("All done.", TRUE); /*if (wr_ok) { // clear_area_screen(3,3,7,20,FALSE,FALSE); //printf( " Reseteando " ); //ResetMW(); }*/ return TRUE; }
//***************************************************************************** // Function : FtpOpen // Description : Open & Login // Input : aCfg; // TCP port info. // aLoginName; // Login name // aLoginPassword; // password. // Return : 0/-1; // 0 => Success // // -1 => Error // Note : N/A // Globals Changed : N/A //***************************************************************************** static int FtpOpen(struct MW_TCP_PORT *aCfg, char *aLoginName, char *aLoginPassword) { int i; // Close all CloseAll(); TBuffers.gRxBuf = MallocMW(COMM_BUFF_SIZE); // buffer de recepcion de datos TBuffers.gTxBuf = MallocMW(COMM_BUFF_SIZE); // buffer de recepcion de datos memset(TBuffers.gRxBuf,0x00,COMM_BUFF_SIZE); memset(TBuffers.gTxBuf,0x00,COMM_BUFF_SIZE); // Open Port graphicWindow("CONEXION FTP"); DispLineMW("Conectando...",MW_LINE3,MW_CLRDISP|MW_CENTER|MW_BIGFONT); FlushAll (); if (IOCtlMW(gFtpHandle, IO_FTP_CONNECT, aCfg) == FALSE) { graphicWindow("ERROR"); //centerS(3,1,21,"Fallo al intentar"); DispLineMW("Fallo al intentar",MW_LINE4,MW_CLRDISP|MW_CENTER|MW_SMFONT); DispLineMW("Abrir!!",MW_LINE5,MW_CLRDISP|MW_CENTER|MW_SMFONT); // centerS(4,1,21,"Abrir!!"); Delay10ms(300); FreeMW(TBuffers.gRxBuf); FreeMW(TBuffers.gTxBuf); return -1; } i = WaitCmdResp(TIMEOUT_RESP); if (i < 0) { graphicWindow("ERROR"); // centerS(3,1,21,"El tiempo de espera"); // centerS(4,1,21,"se agoto al"); // centerS(5,1,21,"intentat abrir!!"); DispLineMW("El tiempo de espera",MW_LINE3,MW_CLRDISP|MW_CENTER|MW_SMFONT); DispLineMW("se agoto al",MW_LINE4,MW_CLRDISP|MW_CENTER|MW_SMFONT); DispLineMW("intentat abrir!!",MW_LINE5,MW_CLRDISP|MW_CENTER|MW_SMFONT); // getch(300); Delay10ms(300); FreeMW(TBuffers.gTxBuf); FreeMW(TBuffers.gRxBuf); return -1; } if (i >= 400) { PrintfMW("\x1B\xE0""Open:%d\x05\x1D", i); FreeMW(TBuffers.gRxBuf); return -1; } if (WaitStatus(MW_FTP_STAT_CONNECTED, TIMEOUT_STATUS)<0) { graphicWindow("ERROR"); // centerS(3,1,21,"Fallo al intentar"); // centerS(4,1,21,"Abrir!!"); // getch(300); DispLineMW("Fallo al intentar",MW_LINE4,MW_CLRDISP|MW_CENTER|MW_SMFONT); DispLineMW("Abrir 2!!",MW_LINE5,MW_CLRDISP|MW_CENTER|MW_SMFONT); Delay10ms(300); FreeMW(TBuffers.gRxBuf);FreeMW(TBuffers.gTxBuf); return -1; } // Login DispLineMW("Negociando...",MW_LINE4,MW_CLRDISP|MW_CENTER|MW_SMFONT); //centerS(4,1,21,"Negociando..."); FlushAll(); SprintfMW ((char *)TBuffers.gTxBuf, "LOGIN %s %s", aLoginName, aLoginPassword); if (IOCtlMW(gFtpHandle, IO_FTP_CMD_SEND, TBuffers.gTxBuf) == FALSE) { graphicWindow("ERROR"); DispLineMW("Fallo al intentar",MW_LINE3,MW_CLRDISP|MW_CENTER|MW_SMFONT); DispLineMW("Login",MW_LINE4,MW_CLRDISP|MW_CENTER|MW_SMFONT); // centerS(3,1,21,"Fallo al intentar"); // centerS(4,1,21,"login!!"); // getch(300); Delay10ms(300); FreeMW(TBuffers.gRxBuf);FreeMW(TBuffers.gTxBuf); return -1; } i = WaitCmdResp(TIMEOUT_RESP); if (i < 0) { graphicWindow("ERROR"); // centerS(3,1,21,"El tiempo de espera"); // centerS(4,1,21,"se agoto al"); // centerS(5,1,21,"intentat login!!"); DispLineMW("El tiempo de espera",MW_LINE3,MW_CLRDISP|MW_CENTER|MW_SMFONT); DispLineMW("se agoto al",MW_LINE4,MW_CLRDISP|MW_CENTER|MW_SMFONT); DispLineMW("intentat login!!",MW_LINE5,MW_CLRDISP|MW_CENTER|MW_SMFONT); // getch(300); Delay10ms(300); FreeMW(TBuffers.gRxBuf);FreeMW(TBuffers.gTxBuf); return -1; } if (i >= 400) { graphicWindow("ERROR"); // centerS(3,1,21,"Fallo al intentar"); // centerS(4,1,21,"login!!"); // getch(300); DispLineMW("Fallo al intentar",MW_LINE3,MW_CLRDISP|MW_CENTER|MW_SMFONT); DispLineMW("login!!",MW_LINE4,MW_CLRDISP|MW_CENTER|MW_SMFONT); Delay10ms(300); FreeMW(TBuffers.gRxBuf);FreeMW(TBuffers.gTxBuf); return -1; } if (WaitStatus(MW_FTP_STAT_OPENED, TIMEOUT_STATUS) < 0) { graphicWindow("ERROR"); // centerS(3,1,21,"Fallo al intentar"); // centerS(4,1,21,"login!!"); // getch(300); DispLineMW("Fallo al intentar",MW_LINE3,MW_CLRDISP|MW_CENTER|MW_SMFONT); DispLineMW("login!!",MW_LINE4,MW_CLRDISP|MW_CENTER|MW_SMFONT); Delay10ms(300); FreeMW(TBuffers.gRxBuf);FreeMW(TBuffers.gTxBuf); return -1; } return 0; }
void delay20ms() { //延遲 20 毫秒之副程式 Delay10ms() ; //呼叫延遲 10 毫秒副程式 Delay10ms() ; //呼叫延遲 10 毫秒副程式 }
void NextStep(void) { Delay10ms(2); }
//-----模块初始化代码----------建议客户直接移植---------------------------// void RXLCD_init(void) { Reset(); Delay10ms(5); RA8870_PLL_ini(); Write_Command(0x10); //SYSR bit[4:3]=00 256 color bit[2:1]= 00 8bit MPU interface Write_Data(0x0f); // 1x 64k color 1x 16bit Write_Command(0x04); //PCLK Write_Data(0x03); // Delay10ms(1); //Horizontal set Write_Command(0x14); //HDWR//Horizontal Display Width Setting Bit[6:0] Write_Data(0x3b); //Horizontal display width(pixels) = (HDWR + 1)*8 0x27 Write_Command(0x15); //HNDFCR//Horizontal Non-Display Period fine tune Bit[3:0] Write_Data(0x02); //(HNDR + 1)*8 +HNDFCR Write_Command(0x16); //HNDR//Horizontal Non-Display Period Bit[4:0] Write_Data(0x03); //Horizontal Non-Display Period (pixels) = (HNDR + 1)*8 Write_Command(0x17); //HSTR//HSYNC Start Position[4:0] Write_Data(0x01); //HSYNC Start Position(PCLK) = (HSTR + 1)*8 Write_Command(0x18); //HPWR//HSYNC Polarity ,The period width of HSYNC. Write_Data(0x03); //HSYNC Width [4:0] HSYNC Pulse width(PCLK) = (HPWR + 1)*8 //Vertical set Write_Command(0x19); //VDHR0 //Vertical Display Height Bit [7:0] Write_Data(0x0f); //Vertical pixels = VDHR + 1 0xef Write_Command(0x1a); //VDHR1 //Vertical Display Height Bit [8] Write_Data(0x01); //Vertical pixels = VDHR + 1 0x00 Write_Command(0x1b); //VNDR0 //Vertical Non-Display Period Bit [7:0] Write_Data(0x0f); //Vertical Non-Display area = (VNDR + 1) Write_Command(0x1c); //VNDR1 //Vertical Non-Display Period Bit [8] Write_Data(0x00); //Vertical Non-Display area = (VNDR + 1) Write_Command(0x1d); //VSTR0 //VSYNC Start Position[7:0] Write_Data(0x0e); //VSYNC Start Position(PCLK) = (VSTR + 1) Write_Command(0x1e); //VSTR1 //VSYNC Start Position[8] Write_Data(0x06); //VSYNC Start Position(PCLK) = (VSTR + 1) Write_Command(0x1f); //VPWR //VSYNC Polarity ,VSYNC Pulse Width[6:0] Write_Data(0x01); //VSYNC Pulse Width(PCLK) = (VPWR + 1) Write_Command(0x20); Write_Data(0x80); Write_Dir(0x52,0xc1);//设置为缓冲卷动模式 Write_Dir(0x40,0x80);//设置为文字模式 Write_Dir(0x41,0x01); Layer1_Visible(); Write_Dir(0xf0,0x04);//开启中断 Write_Dir(0x71,0x04);//设置为4线触摸屏 Write_Dir(0x70,0xB2);//开启触摸功能,设置触摸参数 Write_Dir(0xf1,0x04);//clear INT state 確保上次觸碰後 TP_interrupt 清除 Write_Command(0x8c);//PWM控制设置 Write_Data(0x80);//开启PWM Write_Command(0x8c);//PWM控制设置 Write_Data(0x81);//开启PWM Write_Command(0x8d);//背光亮度 Write_Data(0x80);//亮度参数0xff-0x00 Active_Window(0,479,0,271);//设置区域显示窗口 Text_Foreground_Color1(0x0000);//前景颜色设定 Text_Background_Color1(0xffff);//背景颜色设定 Write_Dir(0X8E,0X80);//开始清屏(显示窗口) Delay10ms(1); Write_Dir(0X01,0X80);//开启显示 }
void main() { // mod, added to patch config bits patch_config(); output_high(LEDR); output_low(LEDG); usb_init(); setup_timer_0(RTCC_INTERNAL|RTCC_DIV_4); set_timer0(0x8ad0); enable_interrupts(GLOBAL); enable_interrupts(INT_TIMER0); while(1) { #if defined (BOARD_AVRUSB12_32) //Mod here we check pin status to see if we must reset device if(!input(PIN_B7)) { delay_ms(25); //debounce if(!input(PIN_B7)) { //its a press output_bit(LEDG,1); delay_ms(500); //for long press detection, if(!input(PIN_B7)) { //its still a press after 1 sec PINRST_BTL(); //reset device } output_bit(LEDG,0); } } #endif usb_task(); usb_isr(); if(DelayCount) continue; if(Connect) { if(UADDR != HubAddress) { usb_set_address(HubAddress); } DevicePort = Connect; port_status[Connect - 1] = PORT_FULL; port_change[Connect - 1] = C_PORT_CONN; TxBuf[0] = 1 << Connect; if(Force0DTS) usb_put_packet(1, TxBuf, 1, 0); else usb_put_packet(1, TxBuf, 1, USB_DTS_TOGGLE); Connect = 0; Force0DTS = 0; } if(Reset) { TxBuf[0] = 1 << Reset; usb_put_packet(1, TxBuf, 1, USB_DTS_TOGGLE); Reset = 0; } if(Disconnect) { if(UADDR != HubAddress) usb_set_address(HubAddress); DevicePort = Disconnect; port_status[Disconnect - 1] = PORT_EMPTY; port_change[Disconnect - 1] = C_PORT_CONN; TxBuf[0] = 1 << Disconnect; usb_put_packet(1, TxBuf, 1, USB_DTS_TOGGLE); Disconnecting = Disconnect; Disconnect = 0; } if(WaitJig) { if(WaitJig == 1) { if(usb_kbhit(2)) { unsigned char c; Chirp(); c = usb_get_packet(2, TxBuf, 8); nJigs++; EP_BDxST_I(1) = 0x40; //Clear IN endpoint if(nJigs == 8) { nJigs = 0; WaitJig = 2; Delay10ms(50); } } } else { int n = 0; for(n = 0; n < 8; ++n) { TxBuf[n] = jig_response[8 * nJigs + n]; } if(usb_put_packet(1, TxBuf, 8, nJigs == 0 ? 0 : USB_DTS_TOGGLE)) { Delay10ms(1); nJigs++; Chirp(); if(nJigs == 8) { nJigs = 0; WaitJig = 0; Delay10ms(15); Disconnect = 3; } } } } if(Address != -1) { delay_ms(1); usb_set_address(Address); Address = -1; } } }