⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 serial.c

📁 在主机上编译后
💻 C
字号:
#include "s3c2410.h"#include "serial.h" #define	TXD0READY	(1<<2)#define	RXD0READY	(1)void init_uart( ){//初始化UART	GPHCON |= 0xa0;		//GPH2,GPH3 used as TXD0,RXD0	GPHUP	 = 0x0c;		//GPH2,GPH3内部上拉	ULCON0	 = 0x03;		//8N1		UCON0	 = 0x05;		//查询方式	UFCON0 = 0x00;		//不使用FIFO	UMCON0 = 0x00;		//不使用流控	UBRDIV0 = 12;		//波特率为57600}void putc(unsigned char c){	while( ! (UTRSTAT0 & TXD0READY) );	UTXH0 = c;}unsigned char getc( ){	while( ! (UTRSTAT0 & RXD0READY) );	return URXH0;}void printk(unsigned char* str){	int i = 0;	while( str[i] ){		putc( (unsigned char) str[i++] );	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -