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