4.3519v101的串口的初始化

00011: @ void uart_early_init(void);
00012: @
00013: .text
00014: .align 2
00015: .global uart_early_init
00016: .type uart_early_init, %function
00017: uart_early_init:
00018: /* Pull up the UART0_RXD pin */
00019: ldr a2, =IO_CONFIG_REG_BASE

#define IO_CONFIG_REG_BASE     0x12040000
00020: ldr a3, [a2, #PAD_CTRL_REG35]    

#define PAD_CTRL_REG35      0x088c
00021: orr a3, a3, #UART0_RXD_PULL_MASK    //将pin脚上拉

#define UART0_RXD_PULL_MASK    (0x1 << 9)
00022: str a3, [a2, #PAD_CTRL_REG35]     //将设置的值写入寄存器中
00023: /* Disable UART */
00024: ldr a4, uart_base_addr_L0       //使用的是串口0

#define UART4_REG_BASE      0x12104000

#define UART3_REG_BASE      0x12103000

#define UART2_REG_BASE      0x12102000

#define UART1_REG_BASE      0x12101000

#define UART0_REG_BASE      0x12100000
00025: mov a3, #0
00026: str a3, [a4, #48]
00027: /* Set baud rate to 115200, uart clock:24M */
00028: add a3, a3, #13
00029: str a3, [a4, #36] //设置波特率整数寄存器
00030: mov a3, #1
00031: str a3, [a4, #40] //设置波特率小数寄存器
00032: /*
00032: Set the UART to be 8 bits, 1 stop bit, no parity, fifo enabled.
00033: ldr a3, =112
00034: str a3, [a4, #44] //线控寄存器
00035: /* Enable UART */
00036: ldr a3, =769
00037: str a3, [a4, #48] //控制寄存器
00038: bx lr

00044: @ void uart_early_puts(const char *ss);
00045: @
00046: .align 2
00047: .global uart_early_puts
00048: .type uart_early_puts, %function
00049: uart_early_puts:
00050: #if !defined(CONFIG_SUPPORT_CA_RELEASE)
00051: ldr a2, uart_base_addr_L1 //最后使用的还是uart0
00052: b next_char
00053: output:
00054: ldr a4, [a2, #24] //将标志寄存器读出来
00055: tst a4, #32     //检测第六位是否为0
00056: bne output    //不为0则循环
00057: str a3, [a2, #0]   //将a3寄存器的值写入uart的数据寄存器
00058: add a1, a1, #1     //a1寄存器中的数值加1
00059: next_char:
00060: ldrb a3, [a1] //将存储器地址为a1的字数据读入寄存器a3。
00061: cmp a3, #0    //a3的数据与0比较
00062: bne output    //不相等就跳转
00063: #endif /* CONFIG_SUPPORT_CA_RELEASE */
00064: bx lr
00065: uart_base_addr_L1:
00066: .word CONFIG_CUR_UART_BASE

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值