ARM的串口配置

本文档提供了ARM Cortex-M3处理器中UART(通用异步收发传输器)的初始化函数和相关通信函数的代码实现,包括设置数据位、停止位、校验位、波特率以及中断处理等。UART_INIT函数用于初始化UART,uart_send函数用于发送单个字符,uart_recv用于接收字符,uart_sendbuf和uart_sendstring分别用于发送缓冲区和字符串。
摘要由CSDN通过智能技术生成

“uart.c”:

#include "s2351_uart.h"
#include "string.h"
#include "stdarg.h"
#include "stdio.h"
#include "s3c2451_vector.h"
UART_Memptr constUART_BASE_PTR[4]={UART0_BASE_PTR,UART1_BASE_PTR,UART2_BASE_PTR,UART3_BASE_PTR};

void UART_INIT(UART_typedef uartx,UART_init_typedef uart_init_typedef)   //初始化函数数据位,停止位,校验位
{

UART_BASE_PTR[uartx]->ULCON &= ~(0x7f);           //0~6位初始化为0,0x7f为0111 1111
UART_BASE_PTR[uartx]->ULCON |=uart_init_typedef.wordwith;   //数据位
UART_BASE_PTR[uartx]->ULCON |=(uart_init_typedef.stop<<2);  //停止位
UART_BASE_PTR[uartx]->ULCON |=(uart_init_typedef.parity<<3);  //校验位

//波特率的选择
  if(uart_init_typedef.bobit == 115200)
{
UART_BASE_PTR[uartx]->UBRDIV = 34;
UART_BASE_PTR[uartx]->UDIVSLOT = 0xDFDD;
  }
if(uart_init_typedef.bobit == 9600)
{
UART_BASE_PTR[uartx]->UBRDIV = 428;
<

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值