OpenCores
URL https://opencores.org/ocsvn/amber/amber/trunk

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [tests/] [uart_tx.S] - Blame information for rev 66

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 csantifort
/*****************************************************************
2
//                                                              //
3
//  Amber 2 System UART Test                                    //
4
//                                                              //
5
//  This file is part of the Amber project                      //
6
//  http://www.opencores.org/project,amber                      //
7
//                                                              //
8
//  Description                                                 //
9
//  Uses the tb_uart in loopback mode to verify the transmitted //
10
//  data.                                                       //
11
//                                                              //
12
//  Author(s):                                                  //
13
//      - Conor Santifort, csantifort.amber@gmail.com           //
14
//                                                              //
15
//////////////////////////////////////////////////////////////////
16
//                                                              //
17
// Copyright (C) 2010 Authors and OPENCORES.ORG                 //
18
//                                                              //
19
// This source file may be used and distributed without         //
20
// restriction provided that this copyright statement is not    //
21
// removed from the file and that any derivative work contains  //
22
// the original copyright notice and the associated disclaimer. //
23
//                                                              //
24
// This source file is free software; you can redistribute it   //
25
// and/or modify it under the terms of the GNU Lesser General   //
26
// Public License as published by the Free Software Foundation; //
27
// either version 2.1 of the License, or (at your option) any   //
28
// later version.                                               //
29
//                                                              //
30
// This source is distributed in the hope that it will be       //
31
// useful, but WITHOUT ANY WARRANTY; without even the implied   //
32
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
33
// PURPOSE.  See the GNU Lesser General Public License for more //
34
// details.                                                     //
35
//                                                              //
36
// You should have received a copy of the GNU Lesser General    //
37
// Public License along with this source; if not, download it   //
38
// from http://www.opencores.org/lgpl.shtml                     //
39
//                                                              //
40
*****************************************************************/
41
 
42
#include "amber_registers.h"
43
 
44
        .section .text
45
        .globl  main
46
main:
47
 
48
        @ Put test_uart into loopback mode, and enable transmit
49
        ldr     r0, AdrTEST_UART_CONTROL
50
        mov     r1, #0x3
51
        str     r1, [r0]
52
 
53
        @ Write to and read back from UART0 registers
54
        ldr     r4, AdrUART0DR
55
        ldr     r5, =Message
56
        ldr     r9, =Message
57
        ldr     r7, =EndMessage
58
 
59
1:      bl      wait_tx_full
60
        ldrb    r6, [r5], #1
61
        @ transmit byte from test_uart
62
        str     r6, [r4]
63 15 csantifort
        bl      uart_rx_check
64
        @ keep doing this until get to the end of the message
65 2 csantifort
        cmp     r5, r7
66
        bne     1b
67
 
68 15 csantifort
        @ The complete message has now been transmitted
69
        @ but some bytes are still en route
70 2 csantifort
        @ check the last few bytes received
71
        bl      uart_rx_check
72
 
73
        @ check that all bytes were received
74
        add     r9, r9, #2
75
        cmp     r9, r7
76
        movne   r10, #100
77
        bne     testfail
78
 
79
        b       testpass
80
 
81
        @ -------------------------------------------
82
 
83
 
84
wait_tx_full:
85
        @ with timeout loop of 0x400
86
        ldr     r0, AdrUART0FR
87
        mov     r2, #0x400
88
1:      subs    r2, r2, #1
89
        moveq   r10, #100
90
        beq     testfail
91
        ldr     r1, [r0]
92
        ands    r1, r1, #0x20
93
        bne     1b
94
        mov     pc, lr
95
 
96
 
97
uart_rx_check:
98
        ldr     r2, AdrUART0DR @ rx/tx byte
99
        ldr     r3, AdrUART0FR @ flags
100
 
101
        @ if rx fifo empty flag == 1, return without doing anything
102
1:      ldr     r0, [r3]
103
        ands    r0, r0, #0x10
104
        movne   pc, lr
105
 
106
        ldrb    r0, [r2]        @ uart rx byte
107
        ldrb    r1, [r9], #1    @ transmitted text
108
        cmp     r0, r1
109
        movne   r10, #20
110
        bne     testfail
111
 
112
        @ check if there are more bytes in rx buffer
113
        b       1b
114
 
115
 
116
testfail:
117
        ldr     r11, AdrTestStatus
118
        str     r10, [r11]
119
        b       testfail
120
 
121
testpass:
122
        ldr     r11, AdrTestStatus
123
        mov     r10, #17
124
        str     r10, [r11]
125
        b       testpass
126
 
127
 
128
@ ------------------------------------------
129
@ ------------------------------------------
130
 
131
/* Write 17 to this address to generate a Test Passed message */
132
AdrTestStatus:          .word  ADR_AMBER_TEST_STATUS
133
 
134
AdrTEST_UART_CONTROL:   .word  ADR_AMBER_TEST_UART_CONTROL
135
AdrUART0DR:             .word  ADR_AMBER_UART0_DR
136
AdrUART0FR:             .word  ADR_AMBER_UART0_FR
137
Message:                .ascii "\nThis message is brought to you by UART0\nThats all folks\n"
138
EndMessage:             .word  0

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.