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

Subversion Repositories amber

[/] [amber/] [trunk/] [hw/] [tests/] [uart_rxint.S] - Blame information for rev 14

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

powered by: WebSVN 2.1.0

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