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

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [tests/] [uart_rx.S] - Blame information for rev 20

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
//  Tests the UART receive function.                            //
10
//                                                              //
11
//  Author(s):                                                  //
12
//      - Conor Santifort, csantifort.amber@gmail.com           //
13
//                                                              //
14
//////////////////////////////////////////////////////////////////
15
//                                                              //
16
// Copyright (C) 2010 Authors and OPENCORES.ORG                 //
17
//                                                              //
18
// This source file may be used and distributed without         //
19
// restriction provided that this copyright statement is not    //
20
// removed from the file and that any derivative work contains  //
21
// the original copyright notice and the associated disclaimer. //
22
//                                                              //
23
// This source file is free software; you can redistribute it   //
24
// and/or modify it under the terms of the GNU Lesser General   //
25
// Public License as published by the Free Software Foundation; //
26
// either version 2.1 of the License, or (at your option) any   //
27
// later version.                                               //
28
//                                                              //
29
// This source is distributed in the hope that it will be       //
30
// useful, but WITHOUT ANY WARRANTY; without even the implied   //
31
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
32
// PURPOSE.  See the GNU Lesser General Public License for more //
33
// details.                                                     //
34
//                                                              //
35
// You should have received a copy of the GNU Lesser General    //
36
// Public License along with this source; if not, download it   //
37
// from http://www.opencores.org/lgpl.shtml                     //
38
//                                                              //
39
*****************************************************************/
40
 
41
#include "amber_registers.h"
42
 
43
        .section .text
44
        .globl  main
45
main:
46
 
47
        @ Configure the Amber UART to use the FIFO to receive
48
        ldr     r4, AdrUART0LCRH
49
        mov     r5, #0x10
50
        str     r5, [r4]
51
 
52
 
53
        @ Load some bytes into the testbench uart
54
        @ so it can transmit them to the Amber UART
55
        ldr     r4, AdrTEST_UART_TXD
56
        ldr     r5, =Message
57
        ldr     r9, =Message
58
        ldr     r7, =EndMessage
59
        ldr     r8, AdrTEST_UART_STATUS
60
 
61
        @ transmit a byte from test uart
62
        ldrb    r6, [r5], #1
63
        str     r6, [r4]
64
 
65
        @ test_uart transmit enable
66
        ldr     r0, AdrTEST_UART_CONTROL
67
        mov     r1, #1
68
        str     r1, [r0]
69
 
70
main_loop:
71
        @ wait if test_uart tx fifo full
72
1:      ldr     r0, [r8]
73
        ands    r0, r0, #2
74
        bne     1b
75
 
76
        @ transmit a byte from test uart
77
        ldrb    r6, [r5], #1
78
        str     r6, [r4]
79
 
80
        @ UART receive and transmit byte
81
        bl      uart_rx_check
82
 
83
        @ full message transmitted?
84
        cmp     r5, r7
85
        bne     main_loop
86
 
87
 
88
        @ while test_uart tx fifo empty == 0
89
2:      bl      uart_rx_check
90
        ldr     r0, [r8]
91
        ands    r0, r0, #1
92
        beq     2b
93
 
94
        @ wait until uart tx fifo empty == 1
95
        ldr     r3, AdrUART0FR @ flags
96
3:      ldr     r1, [r3]
97
        ands    r1, r1, #0x80
98
        beq     3b
99
 
100
        @ check the last few bytes received
101
        bl      uart_rx_check
102
 
103
@ ------------------------------------------
104
@ ------------------------------------------
105
 
106
        b       testpass
107
 
108
 
109
 
110
uart_rx_check:
111
        ldr     r2, AdrUART0DR @ rx/tx byte
112
        ldr     r3, AdrUART0FR @ flags
113
 
114
        @ if rx fifo empty flag == 1, return without doing anything
115
1:      ldr     r0, [r3]
116
        ands    r0, r0, #0x10
117
        movne   pc, lr
118
 
119
        ldrb    r0, [r2]        @ uart rx byte
120
        ldrb    r1, [r9], #1    @ transmitted text
121
        cmp     r0, r1
122
        movne   r10, #20
123
        bne     testfail
124
 
125
        @ check if there are more bytes in rx buffer
126
        b       1b
127
 
128
 
129
testfail:
130
        ldr     r11, AdrTEST_STATUS
131
        str     r10, [r11]
132
        b       testfail
133
 
134
testpass:
135
        ldr     r11, AdrTEST_STATUS
136
        mov     r10, #17
137
        str     r10, [r11]
138
        b       testpass
139
 
140
 
141
@ ------------------------------------------
142
@ ------------------------------------------
143
 
144
/* Write 17 to this address to generate a Test Passed message */
145
AdrTEST_STATUS:         .word  ADR_AMBER_TEST_STATUS
146
AdrTEST_IRQ_TIMER:      .word  ADR_AMBER_TEST_IRQ_TIMER
147
AdrTEST_RANDOM_NUM:     .word  ADR_AMBER_TEST_RANDOM_NUM
148
AdrTEST_UART_CONTROL:   .word  ADR_AMBER_TEST_UART_CONTROL
149
AdrTEST_UART_STATUS:    .word  ADR_AMBER_TEST_UART_STATUS
150
AdrTEST_UART_TXD:       .word  ADR_AMBER_TEST_UART_TXD
151
 
152
AdrUART0LCRH:           .word  ADR_AMBER_UART0_LCRH
153
AdrUART0DR:             .word  ADR_AMBER_UART0_DR
154
AdrUART0FR:             .word  ADR_AMBER_UART0_FR
155
 
156
                        /* Include some non-characters in the string to test all 8 bits */
157
Message:                .word  0xa0ff810a
158
                        .ascii "\nThis message is brought to you by UART0\nIsnt that cool\nThats all folks\n"
159
EndMessage:             .word  0

powered by: WebSVN 2.1.0

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