参考:

1)《USER'S MANUAL-S3C6410X》第31章 UART

2)u-boot uart初始化及读写:u-boot-x.x.x/board/samsumg/smdk6410/lowlevel_init.S

             u-boot-x.x.x/cpu/s3c64xx/serial.c

3) 内核串口驱动:linux-x.x.x/driver/tty/serial/s3c6400.c samsung.c serial_core.c

代码:
uart.c
 #include "uart.h"

 #define GPACON        (*((volatile unsigned long *)0x7f008000))

 #define ULCON0        (*((volatile unsigned long *)0x7f005000))
#define UCON0 (*((volatile unsigned long *)0x7f005004))
#define UFCON0 (*((volatile unsigned long *)0x7f005008))
#define UMCON0 (*((volatile unsigned long *)0x7f00500c))
#define UTRSTAT0 (*((volatile unsigned long *)0x7f005010))
#define UERSTAT0 (*((volatile unsigned long *)0x7f005014))
#define UFSTAT0 (*((volatile unsigned long *)0x7f005018))
#define UMSTAT0 (*((volatile unsigned long *)0x7f00501c))
#define UTXH0 (*((volatile unsigned long *)0x7f005020))
#define URXH0 (*((volatile unsigned long *)0x7f005024))
#define UBRDIV0 (*((volatile unsigned long *)0x7f005028))
#define UDIVSLOT0 (*((volatile unsigned long *)0x7f00502c))
#define UINTP0 (*((volatile unsigned long *)0x7f005030))
#define UINTSP0 (*((volatile unsigned long *)0x7f005034))
#define UINTM0 (*((volatile unsigned long *)0x7f005038)) void uart0_init(void)
{
GPACON &= ~0xff;
GPACON |= 0X22; ULCON0 = 0x03; //data frame: 8n1
/*
clk: pclk
tx int type: level
rx int type: pulse
rx err int enable
tx/rx mode: interrupt or polling
*/
UCON0 = 0x245;
UFCON0 = 0x00; //disable fifo;
UMCON0 = 0X00; //disable auto flow control(AFC)
/*
DIV_VAL = UBRDIV + (num of 1's in UDIVSLOT)/16
DIV_VAL = (PCLK/(bps*16))-1 = (66000000/115200)-1=34.8
UBRDIV = 34;
num of 1's in UDIVSLOT = 13;
*/
UBRDIV0 = 0x22;
UDIVSLOT0 = 0x1fff;
} int uart0_getc(void)
{
while (!(UTRSTAT0 & 0x1));
return (URXH0 & 0xff);
} void uart0_putc(const char c)
{
while (!(UTRSTAT0 & 0x2));
UTXH0 = c;
if (c == '\n')
{
uart0_putc('\r');
}
} void uart0_puts(const char *s)
{
while (*s)
{
uart0_putc(*s++);
}
}

s3c6410_uart初始化及读写的更多相关文章

  1. SD/MMC卡初始化及读写流程

    二.MMC/SD卡的模型和工作原理 PIN脚.SD卡总线.SD卡结构.SD卡寄存器.上电过程 SD卡寄存器:  OCR:操作电压寄存器: 只读,32位 第31位: 表示卡上电的状态位   CID: 卡 ...

  2. 【雕爷学编程】Arduino动手做(52)---MicroSD卡读写模块

    37款传感器与模块的提法,在网络上广泛流传,其实Arduino能够兼容的传感器模块肯定是不止37种 的.鉴于本人手头积累了一些传感器和模块,依照实践(动手试试)出真知的理念,以学习和交流为目的,这里准 ...

  3. Keil MDK STM32系列(九) 基于HAL和FatFs的FAT格式SD卡TF卡读写

    Keil MDK STM32系列 Keil MDK STM32系列(一) 基于标准外设库SPL的STM32F103开发 Keil MDK STM32系列(二) 基于标准外设库SPL的STM32F401 ...

  4. string黑科技

    1. string对象的定义和初始化以及读写 string s1; 默认构造函数,s1为空串string s2(s1); 将s2初始化为s1的一个副本string s3("valuee&qu ...

  5. STM32启动文件详细解析(V3.5.0) 以:startup_stm32f10x_hd.s为例

    我用的是IAR,这个貌似是MDK的,不过很有用,大家可以看一下 ;* 文件名 : startup_stm32f10x_hd.s ;* 库版本 : V3.5.0 ;* 说明: 此文件为STM32F10x ...

  6. objective-c常用方法列表(总结)

    第1章 Objective-C学习环境准备 1.1 Objective-C基础 1.1.1 Objective-C的发展历程 1.1.2 Objective-C语言的特点 1.1.3 技术架构 1.2 ...

  7. libevent源码分析:bufferevent

    struct bufferevent定义在文件bufferevent_struct.h中. /** Shared implementation of a bufferevent. This type ...

  8. stm32f系列单片机startup_stm32fxxx.s文件说明(转)

    * 文件名          : startup_stm32f10x_hd.s;* 库版本           : V3.5.0;* 说明:             此文件为STM32F10x高密度设 ...

  9. API分析——Jquery UI Dialog

    1.阅读API文档的一般方法? 通常地, API由三部分构成:属性.方法.事件. 属性表示参数配置,作为一个组件的微调,或者功能的开启与关闭: 方法表示组件能够发生的动作,或者组件的状态监测: 事件表 ...

随机推荐

  1. Bugtags 那些事儿

  2. ubuntu vnc install

    windows & ubuntu http://www.jb51.net/os/Ubuntu/104948.html ubuntu & ubuntu https://www.digit ...

  3. Replace JSON.NET with Jil JSON serializer in ASP.NET Web API

    I have recently come across a comparison of fast JSON serializers in .NET, which shows that Jil JSON ...

  4. java 、android 知识图谱

    java知识图谱: android知识图谱: 照此图练习,神功自成.....

  5. 软件开发过程文档-cgaowei

    鸡肋——食之无味,弃之可惜”,软件开发过程文档遭遇了鸡肋一样的境遇. 目前敏捷软件开发过程非常流行.相对于软件开发过程文档,敏捷软件开发过程更加重视可运行的程序.关于软件开发过程文档,两个极端都是不可 ...

  6. 中文系统下,UTF-8编码文本文件读取导致的错误

    一.UTF-8编码文件读取导致的错误 有个txt文件,里面内容为: aaa bbb ccc 以UTF-8编码方式打开txt文件,顺序读取,将里面的值放到一个hashset中,并判断aaa是否在在has ...

  7. 线程间操作无效: 从不是创建控件“”的线程访问它~~~的解决方法~ 线程间操作无效: 从不是创建控件“Control Name'”的线程访问它问题的解决方案及原理分析

    看两个例子,一个是在一个进程里设置另外一个进程中控件的属性.另外一个是在一个进程里获取另外一个进程中控件的属性. 第一个例子 最近,在做一个使用线程控制下载文件的小程序(使用进度条控件显示下载进度)时 ...

  8. mac下配置eclipse的hadoop环境

    下载eclipse-jee-mars-1-macosx-cocoa-x86_64.tar 右键显示包内容,将hadoop-eclipse-plugin-2.6.0.jar拷入到刚显示的包的plugin ...

  9. The Ninth Hunan Collegiate Programming Contest (2013) Problem F

    Problem F Funny Car Racing There is a funny car racing in a city with n junctions and m directed roa ...

  10. 从AlphaGo谈通用型人工智能设计

    最近赢了人机大战的AlphaGo火了,火得一塌糊涂,圈里圈外,是人都在谈AlphaGo.但是AlphaGo毕竟是为特定场景特定应用设计的特定型人工智能,和通用型人工智能还是有很大差别,离人工智能普及更 ...