void Uart0_Exception(void) { #if KS_CRITICAL_METHOD == 3 // Allocate storage for CPU status register KS_CPU_SR cpu_sr; #endif char c ; static int i; KS_ENTER_CRITICAL(); ks_int_enter(); KS_EXIT_CRITICAL(); /*先禁止UART接收*/ rINTSUBMSK |= (1 << 0); if(rSUBSRCPND&BIT_SUB_RXD0){ while(rUTRSTAT0&1){ c = rURXH0; if(c !='\r'){ if(c=='\b'){ if(i > 0){ Uart_Printf("\b \b"); i--; } } else { recv_buf[i++] = c; Uart_SendByte(c); } } else{ recv_buf[i] ='\0'; i = 0; Uart_SendByte('\n'); ks_queue_sendmsg(uart_queue,recv_buf); } } } /*clear UART0 INT flag*/ rSUBSRCPND = rSUBSRCPND | (1 << 0); rSRCPND = rSRCPND|( 1 << 28); /*再使能UART0接收中断*/ rINTSUBMSK &= ~(1 << 0); rINTPND = rINTPND; ks_int_exit(); }
void Check_Sel(void) { char yn; do{ rINTMSK |=BIT_GLOBAL|BIT_EINT2; Uart_Printf("\n\r Touch Screen coordinate Rang in:\n"); Uart_Printf(" (Xmin,Ymin) is :(%04d,%04d)\n",Xmin,Ymin); Uart_Printf(" (Xmax,Ymax) is :(%04d,%04d)\n",Xmax,Ymax); Uart_Printf("\n To use current settings. Press N/n key. "); Uart_Printf("\n\n\r Want to Set Again(Y/N)? "); yn = Uart_Getch(); rI_ISPC = BIT_EINT2; // clear pending_bit rINTMSK =~(BIT_GLOBAL|BIT_EINT2); if((yn == 0x59)|(yn == 0x79)|(yn == 0x4E)|(yn == 0x6E)) Uart_SendByte(yn); if((yn == 0x59)|(yn == 0x79)) { Uart_Printf("\n\n Touch TSP's Cornor to ensure Xmax,Ymax,Xmax,Xmin"); //Init X Y rectangle Xmax = 750; Xmin = 200; Ymax = 620; Ymin = 120; oneTouch = 0; CheckTSP = 1; // mask to check while(CheckTSP); }else break; }while(1); }
void Uart_SendString(char *pt) { #ifdef UART_INT uart0TxStr = pt; // actualizar puntero al buffer rINTMSK &= ~(BIT_GLOBAL|BIT_UTXD0); // habilitar interrupcion UTXD0 while (uart0TxStr); // esperar a que se haya recorrido el buffer #else while (*pt) // mandar byte a byte hasta completar string Uart_SendByte(*pt++); #endif }
void Uart_GetString(char *string) { char *string2 = string; char c; while((c = Uart_Getch())!='\r') { if(c=='\b') { if( (int)string2 < (int)string ) { Uart_Printf("\b \b"); string--; } }else{ *string++ = c; Uart_SendByte(c); } } *string='\0'; Uart_SendByte('\n'); }
unsigned int get_hexnum(void) { unsigned int t = 0; int i=0; char c; while ( (c = fpga_uart0_getchar()) != 13){ Uart_SendByte(c); t = (t << 4) + (c - 0x30); i ++; } Uart_Printf("\n\r"); return t; }
void fpga_uart_test(void) { unsigned char c; // fpga_uart_init(UART0,38400); Uart_Printf("\n\r Enter test character :"); do { c = fpga_uart0_getchar(); Uart_SendByte(c); } while (c != 13); Uart_Printf("\r\n UART Test OK!! ") ; // udelay(10000); // *(volatile unsigned long *)FPGA_UART0_BASE_ADDR = 0x30; // udelay(10000); }
void ReadPage(unsigned int addr, unsigned char *buf) { unsigned short i; Uart_SendByte('R'); NFChipEn(); WrNFCmd(READCMD0); WrNFAddr(0); WrNFAddr(0); WrNFAddr(addr); WrNFAddr(addr>>8); if(NandAddr) WrNFAddr(addr>>16); WrNFCmd(READCMD1); InitEcc(); WaitNFBusy(); for(i=0; i<2048; i++) buf[i] = RdNFDat(); NFChipDs(); }
void nand_boot(void) { unsigned int i; #if NADN_BOOT_DEBUG unsigned char *ram_addr = 0x30000000; #else unsigned char *ram_addr = TEXT_BASE; #endif int iSize = 0x60000; int iStartPage = 0; Uart_SendByte('N'); Uart_SendByte('B'); InitNandCfg(); i = ReadChipId(); if(i == 0xecda){ NandAddr = 1; Uart_SendByte('I'); Uart_SendByte('D'); } for(i=0; iSize>0; ) { if(!(i&0x3f)) { if(CheckBadBlk(i+iStartPage)) { i += 64; //iSize -= 64<<11; Uart_SendByte('C'); Uart_SendByte('B'); continue; } } ReadPage((i+iStartPage), ram_addr); i++; iSize -= 2048; ram_addr += 2048; } DsNandFlash(); }
// Función ya implementada: envía una cadena de caracteres completa (hasta que encuentra \0) void Uart_SendString(char *pt) { // mandar byte a byte hasta completar string while (*pt) Uart_SendByte(*pt++); }
void Uart_SendString(char *pt) { while(*pt) Uart_SendByte(*pt++); }
void Uart_printf(char *pt) { while(*pt) Uart_SendByte(*pt++); }