Update incorrectly checked in Makefile.am
[debian/gnuradio] / usrp2 / firmware / apps / test_ram.c
1 /*
2  * Copyright 2007 Free Software Foundation, Inc.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16  */
17
18 #include <stdio.h>
19 #include <stdint.h>
20 #include <u2_init.h>            /* FIXME */
21 #include <sd.h>
22 #include <string.h>
23 #include <hal_io.h>
24 #include <nonstdio.h>
25 #include <hal_uart.h>
26
27 #define ASSERT_TRUE(x) \
28   do { \
29     if (!(x)){ \
30       printf("ASSERT_TRUE failed on line %d\n", __LINE__); \
31       nerrors++; \
32     } \
33   } while(0)
34
35 #define ASSERT_FALSE(x) \
36   do { \
37     if (x){ \
38       printf("ASSERT_FALSE failed on line %d\n", __LINE__); \
39       nerrors++; \
40     } \
41   } while(0)
42
43
44 #define BUFSIZE 128
45
46 int test_ram()
47 {
48   int i,j,k;
49   output_regs->ram_page = 1<<10;
50   
51   extram[0] = 0xDEADBEEF;
52   extram[1] = 0xF00D1234;
53   extram[7] = 0x76543210;
54   
55   output_regs->ram_page = 2<<10;
56   extram[7] = 0x55555555;
57   extram[1] = 0xaaaaaaaa;
58   extram[0] = 0xeeeeeeee;
59   
60   output_regs->ram_page = 1<<10;
61   
62   i = extram[0];
63   k = extram[1];
64   j = extram[7];
65   
66   if((i != 0xDEADBEEF)||(j!=0x76543210)||(k!=0xF00D1234)) {
67     puts("RAM FAIL1!\n");
68     puthex32_nl(i);
69     puthex32_nl(j);
70     puthex32_nl(k);
71     return 0;
72   }
73   
74   output_regs->ram_page = 2<<10;
75
76   j = extram[7];
77   k = extram[1];
78   i = extram[0];
79
80   if((i != 0xeeeeeeee)||(j!=0x55555555)||(k!=0xaaaaaaaa)) {
81     puts("RAM FAIL2!\n");
82     puthex32_nl(i);
83     puthex32_nl(j);
84     puthex32_nl(k);
85     return 0;
86   }
87   return 1;
88 }
89
90 int
91 main(void)
92 {
93
94   u2_init();
95   puts("\ntest_ram\n");
96   int success = test_ram();
97   if(success)
98     puts("RAM Passed Tests\n");
99   else
100     puts("RAM Failed\n");
101
102   hal_finish();
103   return 0;
104 }
105