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

Subversion Repositories amber

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

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
        bl      uart_rx_check
64
        cmp     r5, r7
65
        bne     1b
66
 
67
        @ check the last few bytes received
68
        bl      uart_rx_check
69
 
70
        @ check that all bytes were received
71
        add     r9, r9, #2
72
        cmp     r9, r7
73
        movne   r10, #100
74
        bne     testfail
75
 
76
        b       testpass
77
 
78
        @ -------------------------------------------
79
 
80
 
81
wait_tx_full:
82
        @ with timeout loop of 0x400
83
        ldr     r0, AdrUART0FR
84
        mov     r2, #0x400
85
1:      subs    r2, r2, #1
86
        moveq   r10, #100
87
        beq     testfail
88
        ldr     r1, [r0]
89
        ands    r1, r1, #0x20
90
        bne     1b
91
        mov     pc, lr
92
 
93
 
94
uart_rx_check:
95
        ldr     r2, AdrUART0DR @ rx/tx byte
96
        ldr     r3, AdrUART0FR @ flags
97
 
98
        @ if rx fifo empty flag == 1, return without doing anything
99
1:      ldr     r0, [r3]
100
        ands    r0, r0, #0x10
101
        movne   pc, lr
102
 
103
        ldrb    r0, [r2]        @ uart rx byte
104
        ldrb    r1, [r9], #1    @ transmitted text
105
        cmp     r0, r1
106
        movne   r10, #20
107
        bne     testfail
108
 
109
        @ check if there are more bytes in rx buffer
110
        b       1b
111
 
112
 
113
testfail:
114
        ldr     r11, AdrTestStatus
115
        str     r10, [r11]
116
        b       testfail
117
 
118
testpass:
119
        ldr     r11, AdrTestStatus
120
        mov     r10, #17
121
        str     r10, [r11]
122
        b       testpass
123
 
124
 
125
@ ------------------------------------------
126
@ ------------------------------------------
127
 
128
/* Write 17 to this address to generate a Test Passed message */
129
AdrTestStatus:          .word  ADR_AMBER_TEST_STATUS
130
 
131
AdrTEST_UART_CONTROL:   .word  ADR_AMBER_TEST_UART_CONTROL
132
AdrUART0DR:             .word  ADR_AMBER_UART0_DR
133
AdrUART0FR:             .word  ADR_AMBER_UART0_FR
134
Message:                .ascii "\nThis message is brought to you by UART0\nThats all folks\n"
135
EndMessage:             .word  0

powered by: WebSVN 2.1.0

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