void key_s3c(void) { int which_key,i; while((rPDATG & 0xf0)==0xf0); which_key=rPDATG&0xf0; switch(which_key) { case 0xe0: Led_Display(0x1); point.y_point-=20; if(point.y_point<20) point.y_point=200; break; case 0xd0: Led_Display(0x2); point.x_point-=20; if(point.x_point<20) point.x_point=200; break; case 0xb0: Led_Display(0x4); if( map[point.y_map][point.x_map]==0 ) { change_color(); map[point.y_map][point.x_map]=point.color; draw_map(); if( if_won(point.y_map,point.x_map,point.color) ) { GUI_SetTextMode(GUI_DM_TRANS); //设置为透明 GUI_SetFont(&GUI_Font8x16x1x2); GUI_DispStringAt("win!",250,90); for(i=0;i<20;i++) GUI_Delay(1000); map_initial(); GUI_SetDrawMode(GUI_DM_NORMAL); GUI_SetColor(GUI_GREEN); GUI_FillRect(0,0,320,240); draw_net(); draw_point(); } } break; case 0x70: Led_Display(0x7); /* point.x_point+=20; if(point.x_point>200) point.x_point-=20;*/ break; default : break; } }
static ssize_t led_write(struct file *filp,const char __user *buf, size_t count, loff_t *f_pos) { int i; char *k_buf; k_buf = kmalloc(count, GFP_KERNEL); if(copy_from_user(k_buf, buf, count)) { return -EFAULT; } char number = *k_buf; int mode = 0; switch(number) { case '1': mode = 1; break; case '2': mode = 2; break; case '3': mode = 4; break; case '4': mode = 8; break; default: break; } Led_Display(mode); return (0); }
void Test_SlowMode(void) { int i; unsigned int saveREFRESH; slowExit=0; rGPFCON=rGPFCON & ~(3<<0)|(2<<0); //PF0=EINT0 rEXTINT0=rEXTINT0&(7<<0)|(0x2<<0); //EINT0=falling edge triggered pISR_EINT0=(U32)SlowEint0Int; rINTMSK=~BIT_EINT0; Uart_Printf("[ SLOW MODE TEST ]\n"); Uart_Printf("1)Entering SLOW mode.\n"); Uart_Printf(" LEDs are flickered by 200ms period at %dMhz 20 times.\n",FCLK/1000000); Uart_Printf(" But, The period will be about %lfms.\n",200*FCLK/12000000.); Uart_Printf(" Press EINT0 key to exit SLOW mode\n"); Uart_TxEmpty(0); //To avoid being crushed the character for(i=0;i<20;i++) { Led_Display(0xf); Delay(1000); Led_Display(0x0); Delay(1000); } rCLKSLOW=0|(1<<4)|(1<<5)|(1<<7); //FCLK=FIN/1,SLOW mode,MPLL=off,UPLL=off saveREFRESH=rREFRESH; rREFRESH=(1<<23)|(U32)(2048+1-12*15.6); //Trp=2clk,Trc=4clk //The other memory control register should be optimized for SLOW mode. while(!slowExit) { Led_Display(0xf); DoQsort(); Led_Display(0x0); DoQsort(); } rINTMSK=BIT_ALLMSK; rCLKSLOW=0|(1<<4)|(0<<5);//PLL on,MPLL=on for(i=0;i<2048;i++); //S/W MPLL lock-time rCLKSLOW=0|(0<<4)|(0<<5);//NORMAL mode,PLL on,MPLL=on }
static ssize_t led_write(struct file *filp,const char __user *buf, size_t count, loff_t *f_pos) { int i; printk("led_write is invoked\n"); for (i=0; i<100; i++) { Led_Display(i); mdelay(250); } return (0); }
void sys_init()// Interrupt,Port and UART { /* enable interrupt */ rINTMOD=0x0; rINTCON=0x1; rI_ISPC = 0xffffffff; /* clear all interrupt pend */ rEXTINTPND = 0xf; // clear EXTINTPND reg Port_Init(); /* Initial 44B0X's I/O port */ LED8ADDR = 0 ; Led_Display(0xf); Delay(0); /* delay time */ Uart_Init(0,115200); /* Initial Serial port 1 */ }
void sys_init()// Interrupt,Port and UART { Port_Init(); /* Initial 44B0X's I/O port */ /* enable interrupt */ rINTMOD=0x0; rINTCON=0x1; rEXTINT = 0x22222222; // level mode rI_ISPC = 0xffffffff; /* clear all interrupt pend */ rEXTINTPND = 0xf; // clear EXTINTPND reg LED8ADDR = 0 ; Delay(0); Led_Display(0xf); Uart_Init(0,115200); /* Initial Serial port 1 */ }
void leds_switch () { led_state ^= 0x03; Led_Display(led_state); }
void led2_off() { led_state = led_state & 0xfd; Led_Display(led_state); }
void led2_on() { led_state = led_state | 0x2; Led_Display(led_state); }
void led1_off() { led_state = led_state & 0xfe; Led_Display(led_state); }
void led1_on() { led_state = led_state | 0x1; Led_Display(led_state); }
void leds_off() { Led_Display(0x0); }
/*--- codigo de las funciones ---*/ void leds_on() { Led_Display(0x3); }
void Dvs_Test(void) { volatile int i, n; Uart_Printf("Dvs test.\n"); rGPGCON = (rGPGCON & ~(3<<22)) | (1<<22); // set GPG11 output for idle state. rBANKSIZE = (rBANKSIZE & ~(3<<4)) | (0<<4) | (1<<7); //SCKE_EN, SCLK_EN = disable. Uart_Printf("Change core speed to 266MHz.\n"); #if FIN==12000000 ChangeClockDivider(13, 12); // 1:3:6 #if CPU2440A==1 ChangeMPllValue(127,2,1); // 406MHz #else // 2440X ChangeMPllValue(127,2,0); // 406MHz #endif #else // 16.9344Mhz ChangeClockDivider(13, 12); #if CPU2440A==1 ChangeMPllValue(110,3,1); // 400MHz #else // 2440X ChangeMPllValue(110,3,0); // 400MHz #endif #endif Calc_Clock(1); UPDATE_REFRESH(Hclk); Uart_Init(Pclk, 115200); Uart_Printf("Check Clkout0:FCLK, Clkout1:HCLK.\n"); // Clkout0: FCLK. Clk0_Enable(2); // Clkout1: HCLK. Clk1_Enable(3); #if ADS10==TRUE srand(0); #endif Led_Display(0); // clear all leds. Timer_Setting(); Set_Lcd_Tft_16Bit_240320_Dvs(); Uart_Printf("Tcnt, Vcnt, Idle_flag.\n"); Uart_Printf("%8d,%8d,%1d\n", Timer_cnt0, Vcount, Idle_flag); while(1) { //Uart_Printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"); Uart_Printf("%8d,%8d,%1d\n", Timer_cnt0, Vcount, Idle_flag); for(i=0; i<1024*32; i+=4) { //*(U32 *)(XADDR+i) = i; //*(U32 *)(XADDR+i); } if(Uart_GetKey()==ESC_KEY) break; } rINTMSK = BIT_ALLMSK; }
void comdownload(void) { ULONG size; UCHAR *buf; USHORT checksum; puts("\nNow download file from uart0...\n"); downloadAddress = _NONCACHE_STARTADDRESS; buf = (UCHAR *)downloadAddress; temp = buf-4; Uart_GetKey(); #ifdef USE_UART_INT pISR_UART0 = (ULONG)Uart0RxInt; //串口接收数据中断 ClearSubPending(BIT_SUB_RXD0); ClearPending(BIT_UART0); EnableSubIrq(BIT_SUB_RXD0); EnableIrq(BIT_UART0); #endif while((ULONG)temp<(ULONG)buf) { #ifdef USE_UART_INT Led_Display(0); Delay(1000); Led_Display(15); Delay(1000); #else *temp++ = Uart_Getch(); #endif } //接收文件长度,4 bytes size = *(ULONG *)(buf-4); downloadFileSize = size-6; #ifdef USE_UART_INT printf("Download File Size = %d\n", size); #endif while(((ULONG)temp-(ULONG)buf)<(size-4)) { #ifdef USE_UART_INT Led_Display(0); Delay(1000); Led_Display(15); Delay(1000); #else *temp++ = Uart_Getch(); #endif } #ifdef USE_UART_INT DisableSubIrq(BIT_SUB_RXD0); DisableIrq(BIT_UART0); #endif #ifndef USE_UART_INT printf("Download File Size = %d\n", size); #endif checksum = 0; for(size=0; size<downloadFileSize; size++) checksum += buf[size]; if(checksum!=(buf[size]|(buf[size+1]<<8))) { puts("Checksum fail!\n"); return; } puts("Are you sure to run? [y/n]\n"); while(1) { UCHAR key = getch(); if(key=='n') return; if(key=='y') break; } call_linux(0, 193, downloadAddress); }
void main(void) { register nPage; unsigned char *pBuf; unsigned char ucDID, ucHID; unsigned char nCnt; unsigned char uNumOfLoadPage = LOAD_PAGE_SIZE; BOOL b4KPage = FALSE; // Set up copy section (initialized globals). // // NOTE: after this call, globals become valid. // // SetupCopySection(pTOC); // Enable the ICache. // MMU_EnableICache(); // Set up all GPIO ports. Port_Init(); #ifdef DEBUGUART // UART initialize Uart_Init(); //Uart_SendString("\r\n\r\nWince 5.0 1st NAND Bootloader (NBL1) for SMDK2443\r\n"); // Initialize the NAND flash interface. Uart_SendString("NAND Initialize\r\n"); #endif NAND_Init(); Read_DeviceID(0, &ucDID, &ucHID); #ifdef DEBUGUART Uart_SendString("Device ID : 0x"); Uart_SendBYTE(ucDID, 1); Uart_SendString("Hidden ID : 0x"); Uart_SendBYTE(ucHID, 1); #endif if ( (ucDID == 0xd5 && ucHID == 0x14) || (ucDID == 0xd5 && ucHID == 0x94) || (ucDID == 0xd7 && ucHID == 0x55) || (ucDID == 0xd7 && ucHID == 0xD5) // for MLC || (ucDID == 0xd3 && ucHID == 0x10)) // for SLC { b4KPage = TRUE; uNumOfLoadPage = LOAD_PAGE_SIZE/2; } // Turn the LEDs off. Led_Display(0x0); pBuf = (unsigned char *)LOAD_ADDRESS_PHYSICAL; // MLC // Page 0, 1 : Steploader // Page 2 ~ 5 : empty page // Page 6 ~ PAGES_PER_BLOCK-3 : effective page // read pages with 0, 1 and 6 to PAGES_PER_BLOCK-3 nPage = 10; for (nCnt = 0; nCnt < uNumOfLoadPage; nCnt++) { #ifdef OMNIBOOK_VER Led_Display(0x1); #else //!OMNIBOOK_VER Led_Display(0x2); #endif OMNIBOOK_VER if (nPage >= (NAND_PAGE_PER_BLOCK-2) || (NAND_Read(0, nPage, pBuf, b4KPage) == FALSE)) { #ifdef DEBUGUART // Uncorrectable ECC Error Uart_SendString("ECC Error @ Page 0x"); Uart_SendBYTE(nPage, 1); #endif #ifdef OMNIBOOK_VER Led_Display(0x0); #else //!OMNIBOOK_VER Led_Display(0x9); #endif OMNIBOOK_VER while(1); } nPage++; if (b4KPage == TRUE) pBuf += NAND_BYTE_PER_PAGE*2; else pBuf += NAND_BYTE_PER_PAGE; #ifdef OMNIBOOK_VER Led_Display(0x2); #else //!OMNIBOOK_VER Led_Display(0x4); #endif OMNIBOOK_VER } //Uart_SendString("Jump to 2nd Bootloader...\r\n"); // Uart_SendDWORD(LOAD_ADDRESS_PHYSICAL, 1); // Turn the LEDs on. // #ifdef OMNIBOOK_VER Led_Display(0x3); #else //!OMNIBOOK_VER Led_Display(0x5); #endif OMNIBOOK_VER #ifdef DEBUGUART Uart_SendString("Jump to 2nd Bootloader...\r\n"); #endif ((PFN_IMAGE_LAUNCH)(LOAD_ADDRESS_PHYSICAL))(); }