#include <stdio.h>
void Uart_Init(void)
{
#define rULCON0 (*(volatile unsigned int*)0x50000000)
#define rUCON0 (*(volatile unsigned int*)0x50000004)
#define rUBRDIV0 (*(volatile unsigned int*)0x50000028)
#define PCLK 50000000
#define BUADRATE 115200
rULCON0 = 0x03; //No parity, One stop bit, 8-bits data
rUCON0 = 0x05; //Tx Enable, Rx Enable, PCLK as source clock
rUBRDIV0 = (int)(PCLK / (BUADRATE * 16)) - 1; //115200bps
}
void Uart_Putc(unsigned char c)
{
#define rUTRSTAT0 (*(volatile unsigned int*)0x50000010)
#define rUTXH0 (*(volatile unsigned int*)0x50000020)
#define BUFFER_EMPTY (1 << 1)
while(!(rUTRSTAT0 & BUFFER_EMPTY));
rUTXH0 = c;
}
unsigned char Uart_Getc(void)
{
#define rUTRSTAT0 (*(volatile unsigned int*)0x50000010)
#define rURXH0 (*(volatile unsigned int*)0x50000024)
#define BUFFER_READY (1 << 0)
while(!(rUTRSTAT0 & BUFFER_READY));
return rURXH0;
}
struct __FILE
{
int handle;
/* Whatever you require here. If the only file you are using is */
/* standard output using printf() for debugging, no file handling */
/* is required. */
};
/* FILE is typedef'd in stdio.h. */
FILE __stdout;
int fputc(int ch, FILE *f)
{
Uart_Putc(ch);
return ch;
}
int ferror(FILE *f) {
/* Your implementation of ferror */
return EOF;
}
没有合适的资源?快使用搜索试试~ 我知道了~
s3c2440 uart driver
共5个文件
c:2个
uvopt:1个
s:1个
需积分: 13 9 下载量 9 浏览量
2015-03-03
17:57:21
上传
评论
收藏 15KB ZIP 举报
温馨提示
基于s3c2440的串口驱动,代码简单易懂,硬件平台为友善mini2440,使用RealView MDK 4.22开发。
资源推荐
资源详情
资源评论
收起资源包目录
myuart.zip (5个子文件)
myuart
myuart.uvproj 15KB
inc
myuart.uvopt 8KB
src
main.c 1KB
uart.c 1KB
S3C2440.s 52KB
共 5 条
- 1
资源评论
何小龙
- 粉丝: 2717
- 资源: 11
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功