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

Subversion Repositories pcie_ds_dma

[/] [pcie_ds_dma/] [trunk/] [soft/] [linux/] [application/] [adm_test/] [src/] [work/] [main.cpp] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 dsmv
 
2
/*
3
#ifndef __PEX_H__
4
    #include "pex.h"
5
#endif
6
*/
7
 
8
#include "board.h"
9
#include "pex_board.h"
10
 
11
#include <cassert>
12
#include <cstdlib>
13
#include <cstring>
14
#include <iostream>
15
#include <iomanip>
16
#include <climits>
17
 
18
//-----------------------------------------------------------------------------
19
 
20
using namespace std;
21
 
22
//-----------------------------------------------------------------------------
23
 
24
#include <locale.h>
25
#include <unistd.h>
26
#include <stdlib.h>
27
#include <stdio.h>
28
#include <signal.h>
29
 
30
#include "cl_ambpex.h"
31
#include "tf_test.h"
32
#include "tf_teststrm.h"
33
#include "tf_teststrmout.h"
34
//#include "useful.h"
35
 
36
#define DEVICE_NAME "/dev/AMBPEXARM_DEVID0"
37
//#define DEVICE_NAME "/dev/AMBPEX50"
38
CL_AMBPEX *pBrd = NULL;
39
U32 isTwoTest=0;
40
static volatile int exit_flag = 0;
41
 
42
void signa_handler(int signo)
43
{
44
    exit_flag = 1;
45
}
46
 
47
int BRDC_main(int argc, BRDCHAR* argv[])
48
{
49
    // анализ командной строки
50
    setlocale( LC_ALL, "Russian" );
51
    signal(SIGINT, signa_handler);
52
 
53
    TF_Test  *pTest=NULL;
54
    TF_Test  *pTest2=NULL;
55
 
56
    BRDCHAR* fname = argv[1];
57
    BRDCHAR* fname2=NULL;
58
    if( argc<2 )
59
    {
60
        fname=(BRDCHAR*)_BRDC("");
61
    }
62
    if( argc==3 )
63
    {
64
        fname2=argv[2];
65
    }
66
 
67
    try
68
    {
69
        pBrd = new CL_AMBPEX(DEVICE_NAME);
70
 
71
        int ret=pBrd->init();
72
 
73
        if( 0==ret )
74
        {
75
            BRDC_fprintf( stderr, _BRDC("Module "DEVICE_NAME" successfuly opened\n") );
76
 
77
            for( int trd=0; trd<8; trd++ )
78
                pBrd->RegPokeInd( trd, 0, 1 );
79
 
80
            for( int trd=0; trd<8; trd++ )
81
                for( int ii=1; ii<32; ii++ )
82
                    pBrd->RegPokeInd( trd, ii, 0 );
83
 
84
            for( int trd=0; trd<8; trd++ )
85
                pBrd->RegPokeInd( trd, 0, 0 );
86
 
87
 
88
        } else
89
        {
90
            BRDC_fprintf( stderr, _BRDC("Error open module "DEVICE_NAME": ret=0x%.8X\n"), ret );
91
            exit(-1);
92
        }
93
 
94
        if( fname[0]=='o' )
95
            pTest = new TF_TestStrmOut( fname, pBrd );
96
        else
97
            pTest = new TF_TestStrm( fname, pBrd );
98
 
99
        Sleep( 10 );
100
 
101
        if( fname2 )
102
        {
103
            isTwoTest=1;
104
            if( fname2[0]=='o' )
105
                pTest2 = new TF_TestStrmOut( fname2, pBrd );
106
            else
107
                pTest2 = new TF_TestStrm( fname2, pBrd );
108
        }
109
 
110
        pTest->Prepare();
111
        if( pTest2 )
112
            pTest2->Prepare();
113
 
114
        Sleep( 10 );
115
        pTest->Start();
116
        Sleep( 10 );
117
        if( pTest2 )
118
            pTest2->Start();
119
 
120
        //int key;
121
        int isFirstCallStep=1;
122
        for( ; ; )
123
        {
124
            //if( kbhit() )
125
            //{
126
                //int key=getch();
127
                if( exit_flag )
128
                {
129
                    pTest->Stop();
130
                    if( pTest2 )
131
                        pTest2->Stop();
132
                    BRDC_fprintf( stderr, _BRDC("\n\nCancel\n") );
133
                }
134
/*
135
                if( key=='i' )
136
                {
137
                    pBrd->RegPokeInd( 4, TRDIND_DELAY_CTRL, 0x12 );
138
                    pBrd->RegPokeInd( 4, TRDIND_DELAY_CTRL, 0x10 );
139
                    g_DelayCnt--; BRDC_fprintf( stderr, "\n\ng_DelayCnt = %d ", g_DelayCnt );
140
                }
141
 
142
                if( key=='o' )
143
                {
144
                    pBrd->RegPokeInd( 4, TRDIND_DELAY_CTRL, 0x13 );
145
                    pBrd->RegPokeInd( 4, TRDIND_DELAY_CTRL, 0x11 );
146
                    g_DelayCnt++; BRDC_fprintf( stderr, "\n\ng_DelayCnt = %d ", g_DelayCnt );
147
                }
148
*/
149
            //}
150
 
151
            ret=pTest->isComplete();
152
            if( ret )
153
            {
154
                if( pTest2 )
155
                {
156
                    ret=pTest2->isComplete();
157
                    if( ret )
158
                        break;
159
                } else
160
                {
161
                    break;
162
                }
163
 
164
            }
165
 
166
            //SetConsoleCursorPosition(hConsoleOut, rCursorPosition);
167
            if( isFirstCallStep || isTwoTest )
168
            {
169
 
170
                BRDC_fprintf( stderr, _BRDC("%10s %10s %10s %10s %10s %10s %10s %10s\n"), _BRDC(""), _BRDC("BLOCK_WR"), _BRDC("BLOCK_RD"), _BRDC("BLOCK_OK"), _BRDC("BLOCK_ERR"), _BRDC("SPD_CURR"), _BRDC("SPD_AVR"), _BRDC("STATUS"));
171
                BRDC_fprintf( stderr, _BRDC("\n"));
172
            }
173
 
174
            if (isFirstCallStep)
175
            {
176
                isFirstCallStep=false;
177
            }
178
 
179
            pTest->Step();
180
            if( isTwoTest )
181
                BRDC_fprintf( stderr, "\n" );
182
            if( pTest2 )
183
                pTest2->Step();
184
            if( isTwoTest )
185
                BRDC_fprintf( stderr, "\n\n" );
186
 
187
            Sleep( 400 );
188
 
189
            fflush( stdout );
190
 
191
            if(exit_flag)
192
                break;
193
        }
194
        pTest->GetResult();
195
        if( pTest2 )
196
            pTest2->GetResult();
197
 
198
 
199
        delete pTest; pTest=NULL;
200
        delete pTest2; pTest2=NULL;
201
 
202
    }
203
    catch( BRDCHAR* str )
204
    {
205
        BRDC_fprintf( stderr, _BRDC("Err: %s \n"), str );
206
    }
207
    catch( ... )
208
    {
209
        BRDC_fprintf( stderr, _BRDC("Неизвестная ошибка выполнения программы\n") );
210
    }
211
 
212
    BRDC_fprintf( stderr, "\n Press any key\n" );
213
 
214
    return 0;
215
}

powered by: WebSVN 2.1.0

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