📄 print.c
字号:
/*================================================================== * * This file is part of a small Nand flash bootloader designed to * be loaded via EP93xx SPI boot. * * Copyright Cirrus Logic Corporation, 2007. All rights reserved * ==================================================================*/#include <io.h>#include <boot.h>#define BDIV(baud) (((SYSTEM_CLOCK / 16)/(baud))-1)void uart_setup(void){ u32 tmp; //run at UART0 on extclk rather than extclk/2 tmp = IN32(PWRCNT); tmp |= (1<<29); OUT32(tmp, PWRCNT); //enable uart0 OUT32(0xaa, SWLOCK); tmp=IN32(DEVCFG); tmp |= SYSCON_DEVCFG_U0EN; OUT32(0xaa, SWLOCK); OUT32(tmp, DEVCFG);//uart0 OUT32( BDIV(BOOT_BAUDRATE),UART0LINCTRLLOW ); OUT32( 0,UART0LINCTRLMID ); //8n1, tx fifo on OUT32( ((3<<5) | (1<<4)), UART0LINCTRLHIGH ); //enable uart0 OUT32( 1, UART0CTRL);}int putchar(int c){ // while tx fifo full while( (IN32(UART0FLAG)) & (1<<5) ) { } OUT32( c, UART0DR ); if(c=='\n') { c='\r'; // while tx fifo full while( (IN32(UART0FLAG)) & (1<<5) ) { } OUT32( c, UART0DR ); } // while UART is busy while( (IN32(UART0FLAG)) & (1<<3) ) { } return 0;}int puts(const char *s){ while(*s) { putchar(*s++); } putchar('\n'); return 0;}void puthex(u32 val){ char hextab[]={"0123456789ABCDEF"}; int i; for(i=28; i>=0; i-=4) { putchar( hextab[ ((val >> i) & 0xf) ] ); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -