FRI-SMS rešitve Local Loopback
완료 조건
.global _main
/* main program */
_main:
.equ DBGU_BASE, 0xFFFFF200 /* Debug Unit Base Address */
.equ DBGU_CR, 0x00 /* DBGU Control Register */
.equ DBGU_MR, 0x04 /* DBGU Mode Register*/
.equ DBGU_IER, 0x08 /* DBGU Interrupt Enable Register*/
.equ DBGU_IDR, 0x0C /* DBGU Interrupt Disable Register */
.equ DBGU_IMR, 0x10 /* DBGU Interrupt Mask Register */
.equ DBGU_SR, 0x14 /* DBGU Status Register */
.equ DBGU_RHR, 0x18 /* DBGU Receive Holding Register */
.equ DBGU_THR, 0x1C /* DBGU Transmit Holding Register */
.equ DBGU_BRGR, 0x20 /* DBGU Baud Rate Generator Register */
/* user code here */
bl DEBUG_INIT
@ send test
@send1: mov r0,#'a'
@ bl SND_DEBUG
@ b send1
@ echo test
@ test2: bl RCV_DEBUG
@ bl SND_DEBUG
@ b test2
@ loopback test
mov r1,#'a'
test3: mov r0,r1
bl SND_DEBUG
bl RCV_DEBUG
add r1,r1,#1
b test3
@ LOOP: bl RCV_DEBUG
@ bl SND_DEBUG
@ b LOOP
/* end user code */
_wait_for_ever:
b _wait_for_ever
DEBUG_INIT:
stmfd r13!, {r0, r1, r14}
ldr r0, =DBGU_BASE
@ mov r1, #26 @ BR=115200
mov r1, #156 @ BR=19200
str r1, [r0, #DBGU_BRGR]
mov r1, #(1 << 11)
add r1, r1, #(0b10 << 14) @ Local Loopback Mode (instead of Normal)
str r1, [r0, #DBGU_MR]
mov r1, #0b1010000
str r1, [r0, #DBGU_CR]
ldmfd r13!, {r0, r1, pc}
RCV_DEBUG:
stmfd r13!, {r1, r14}
ldr r1, =DBGU_BASE
RCVD_LP:
ldr r0, [r1, #DBGU_SR]
tst r0, #1
beq RCVD_LP
ldr r0, [r1, #DBGU_RHR]
ldmfd r13!, {r1, pc}
SND_DEBUG:
stmfd r13!, {r1, r2, r14}
ldr r1, =DBGU_BASE
SNDD_LP:
ldr r2, [r1, #DBGU_SR]
tst r2, #(1 << 1)
beq SNDD_LP
str r0, [r1, #DBGU_THR]
ldmfd r13!, {r1, r2, pc}
.align
/* constants */
/* main program */
_main:
.equ DBGU_BASE, 0xFFFFF200 /* Debug Unit Base Address */
.equ DBGU_CR, 0x00 /* DBGU Control Register */
.equ DBGU_MR, 0x04 /* DBGU Mode Register*/
.equ DBGU_IER, 0x08 /* DBGU Interrupt Enable Register*/
.equ DBGU_IDR, 0x0C /* DBGU Interrupt Disable Register */
.equ DBGU_IMR, 0x10 /* DBGU Interrupt Mask Register */
.equ DBGU_SR, 0x14 /* DBGU Status Register */
.equ DBGU_RHR, 0x18 /* DBGU Receive Holding Register */
.equ DBGU_THR, 0x1C /* DBGU Transmit Holding Register */
.equ DBGU_BRGR, 0x20 /* DBGU Baud Rate Generator Register */
/* user code here */
bl DEBUG_INIT
@ send test
@send1: mov r0,#'a'
@ bl SND_DEBUG
@ b send1
@ echo test
@ test2: bl RCV_DEBUG
@ bl SND_DEBUG
@ b test2
@ loopback test
mov r1,#'a'
test3: mov r0,r1
bl SND_DEBUG
bl RCV_DEBUG
add r1,r1,#1
b test3
@ LOOP: bl RCV_DEBUG
@ bl SND_DEBUG
@ b LOOP
/* end user code */
_wait_for_ever:
b _wait_for_ever
DEBUG_INIT:
stmfd r13!, {r0, r1, r14}
ldr r0, =DBGU_BASE
@ mov r1, #26 @ BR=115200
mov r1, #156 @ BR=19200
str r1, [r0, #DBGU_BRGR]
mov r1, #(1 << 11)
add r1, r1, #(0b10 << 14) @ Local Loopback Mode (instead of Normal)
str r1, [r0, #DBGU_MR]
mov r1, #0b1010000
str r1, [r0, #DBGU_CR]
ldmfd r13!, {r0, r1, pc}
RCV_DEBUG:
stmfd r13!, {r1, r14}
ldr r1, =DBGU_BASE
RCVD_LP:
ldr r0, [r1, #DBGU_SR]
tst r0, #1
beq RCVD_LP
ldr r0, [r1, #DBGU_RHR]
ldmfd r13!, {r1, pc}
SND_DEBUG:
stmfd r13!, {r1, r2, r14}
ldr r1, =DBGU_BASE
SNDD_LP:
ldr r2, [r1, #DBGU_SR]
tst r2, #(1 << 1)
beq SNDD_LP
str r0, [r1, #DBGU_THR]
ldmfd r13!, {r1, r2, pc}
.align
/* constants */
마지막 수정됨: 화요일, 14 12월 2021, 6:32 PM