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

Subversion Repositories simple_customized_counter

[/] [simple_customized_counter/] [trunk/] [TestCounterOprEventAPI/] [CppCode/] [TestProject/] [TestProject.cpp] - Blame information for rev 50

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

Line No. Rev Author Line
1 37 lmorin12
#include <windows.h>
2
#include <iostream>
3
using namespace std;
4
 
5
#include "api.h"
6
#include "CCounter.h"
7
 
8
int main(int argc, char* argv[])
9
{
10
    int  Value = 0;         // Counter value
11
    char chKey = ' ';       // Pressed key value
12
    int  iLoadValue = 0;    // Load value
13
 
14
    // Operation enum
15
    enum Opr_t { cOprNone, cOprReset, cOprUp, cOprDown, cOprLoad };
16
 
17
        // Declare the board interface object
18
    CCounter oFPGA;
19
 
20
        // Initialize and conect to FPGA board
21
    if( oFPGA.Initialize() != 0 )
22
        {
23
        cout << "Failed to initialize\n";
24
                return 1;
25
        };
26
 
27
        // Sends a reset, function start() is executed in each component
28
    oFPGA.pApi->SendStartEvent( );
29
 
30
    // Infinite loop, until quit 
31
    while(true)
32
    {
33
        // Print options
34
        system("cls");
35
        cout << "1 - (R)eset\n";
36
        cout << "2 - (U)p\n";
37
        cout << "3 - (D)own\n";
38
        cout << "4 - (L)oad\n";
39
        cout << "    Load Value: " << iLoadValue << endl << endl;
40
        cout << "q - (Q)uit\n\n";
41
        cout << "Counter value " << Value << endl << endl;
42
        cout << "Select operation: ";
43
 
44
        cin >> chKey;
45
 
46
        // If the user wants to quit
47
        if((chKey == 'q') || (chKey == 'Q'))
48
            break;  // Exit the while!
49
 
50
        // Allows to received future events
51
        oFPGA.pApi->ReStartEventsReception();
52
 
53
        switch(chKey)
54
        {
55
            // Reset counter
56
            case '1':
57
                                oFPGA.Set_iOpr(cOprReset, true);
58
                break;
59
 
60
            // Up counter
61
            case '2':
62
                                oFPGA.Set_iOpr(cOprUp, true);
63
                break;
64
 
65
                // Down counter
66
            case '3':
67
                oFPGA.Set_iOpr(cOprDown, true);
68
                break;
69
 
70
                // Load value
71
            case '4':
72
                cout << "\nEnter the load value 0 - 255 : ";
73
                cin >> iLoadValue;
74
                oFPGA.Set_iLoadValue(iLoadValue);
75
                oFPGA.Set_iOpr(cOprLoad, true);
76
                break;
77
        }  // End switch
78
 
79
        oFPGA.pApi->SendEvents();
80
        oFPGA.pApi->WaitForEvents();
81
 
82
        Value = oFPGA.Get_oValue();
83
    } // End while
84
 
85
    return 0;
86
}
87
 
88
 

powered by: WebSVN 2.1.0

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