源码地址:https://github.com/774639008/MyProject/commit/2129384d2e0004dc859caa4d8b81d8669ecf5850?diff=unified
这是uart.c文件
#include <stdio.h>
#include <S3C2440.h>
#include "lcd.h"
#include "irq.h"
#include "uart_cmd.h"
#include <string.h>
#include <stdlib.h>
#include "heap.h"
/*------------------------ Type Declarations ---------------------------------*/
//UART驱动由UART相关的IO口的配置,UART寄存器控制。UART中断处理三部分组成
#define FCLK (405000000) //405M
#define HCLK (101000000) //101M
#define PCLK (50000000) //50.5M
int UART0_init(int baudrate)
{
//设置波特率
int nUBRDIV = PCLK/16/baudrate - 1;
// 设置引脚,配置上拉模式
GPHCON = 0xA0;
GPHUP = 0x0C;
//设置数据传输格式:初始化UART线控制寄存器
//普通模式操作 无奇偶校验 1个停止位 8个字节长度
ULCON0 = (0x3);
// ULCON1 = (0<<6)|(0<<3)|(0<<2)|(3<<0);
// ULCON2 = (0<<6)|(0<<3)|(0<<2)|(3<<0);
//设置通道工作模式:设置UART控制寄存器
// [10] [9] [8] [7] [6] [5] [4] [3:2] [1:0]
// 时钟选择, Tx 中断, Rx 中