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/] [board_exam/] [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
#ifndef __PEX_H__
3
    #include "pex_board.h"
4
#endif
5
 
6
#include <cassert>
7
#include <cstdlib>
8
#include <cstring>
9
#include <iostream>
10
#include <iomanip>
11
#include <climits>
12
#include <cstdio>
13
 
14
//-----------------------------------------------------------------------------
15
 
16
using namespace std;
17
 
18
//-----------------------------------------------------------------------------
19
#define NUM_BLOCK   4
20
#define BLOCK_SIZE  0x1000
21
//-----------------------------------------------------------------------------
22
 
23
int main(int argc, char *argv[])
24
{
25
    if(argc == 1) {
26
        std::cerr << "usage: %s <device name>" << argv[0] << endl;
27
        return -1;
28
    }
29
 
30
    std ::cout << "Start testing device " << argv[1] << endl;
31
 
32
    int dmaChan = 0;
33
    void* pBuffers[NUM_BLOCK] = {NULL};
34
 
35
    board *brd = new pex_board();
36
    brd->brd_open(argv[1]);
37
    brd->brd_init();
38
    brd->brd_pld_info();
39
 
40
    std ::cout << "Press enter to allocate DMA memory..." << endl;
41
    getchar();
42
 
43
    // Check BRDSHELL DMA interface
44
    BRDctrl_StreamCBufAlloc sSCA = {
45
        1,
46
        1,
47
        NUM_BLOCK,
48
        BLOCK_SIZE,
49
        &pBuffers[0],
50
        NULL,
51
    };
52
 
53
    brd->dma_alloc(dmaChan, &sSCA);
54
 
55
    std ::cout << "Press enter to start DMA channel..." << endl;
56
    getchar();
57
 
58
    brd->dma_start(dmaChan, 0);
59
 
60
    std ::cout << "Press enter to stop DMA channel..." << endl;
61
    getchar();
62
 
63
    brd->dma_stop(dmaChan);
64
 
65
    std ::cout << "Press enter to view DMA data (buffer 0)..." << endl;
66
    getchar();
67
 
68
    u32 *buffer = (u32*)pBuffers[0];
69
    for(unsigned i=0; i<BLOCK_SIZE/4; i+=128) {
70
        std::cout << hex << buffer[i] << " ";
71
    }
72
    std::cout << dec << endl;
73
 
74
    std ::cout << "Press enter to free DMA memory..." << endl;
75
    getchar();
76
 
77
    brd->dma_free_memory(dmaChan);
78
/*
79
    for(int i=0; i<16; i++)
80
        std ::cout << "BAR0[" << i << "] = 0x" << hex << brd->brd_bar0_read(i) << dec << endl;
81
 
82
    fprintf(stderr, "Press enter to read BAR1...\n");
83
    getchar();
84
 
85
    for(int i=0; i<16; i++)
86
        std ::cout << "BAR1[" << i << "] = 0x" << hex << brd->brd_bar1_read(i) << dec << endl;
87
*/
88
    brd->brd_close();
89
 
90
    delete brd;
91
 
92
    return 0;
93
}

powered by: WebSVN 2.1.0

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