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

Subversion Repositories gpib_controller

[/] [gpib_controller/] [trunk/] [prototype_1/] [PC_software/] [test_src/] [readRawRegs.c] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 Andrewski
/*
2 12 Andrewski
*This file is part of fpga_gpib_controller.
3
*
4
* Fpga_gpib_controller 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
* Fpga_gpib_controller 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 Fpga_gpib_controller.  If not, see <http://www.gnu.org/licenses/>.
16
*/
17
/*
18 3 Andrewski
 ============================================================================
19
 Name        : GPIB_access.c
20 12 Andrewski
 Author      : Andrzej Paluch
21 3 Andrewski
 Version     :
22
 Copyright   : Your copyright notice
23
 Description : Hello World in C, Ansi-style
24
 ============================================================================
25
 */
26
 
27
#include <stdio.h>
28
#include <stdlib.h>
29
 
30
#include "GpibRegAccess.h"
31
 
32
#define CHECK(x) if(!(x)) goto error;
33
 
34
int rawRegAccessMain(int argc, char* argv[]) {
35
 
36
        printf("start\n");
37
 
38
        struct GpibRegAccess ra;
39
 
40
        CHECK(GpibRegAccess_init(&ra));
41
 
42
        RegType value, value1;
43
        unsigned int tempInt;
44
        SizeType regAddr = 1;
45
 
46
        char chr;
47
 
48
        do
49
        {
50
                chr = getchar();
51
 
52
                value = 0;
53
                value1 = 0;
54
 
55
                if(chr != 'e')
56
                {
57
                        if(chr == 'r')
58
                        {
59
                                scanf("%u", &regAddr);
60
                                CHECK(GpibRegAccess_readReg(&ra, regAddr, &value));
61
                                printf("\n%x\n", value);
62
                        }
63
                        else if(chr == 'w')
64
                        {
65
                                scanf("%u", &regAddr);
66
                                scanf("%x", &tempInt);
67
 
68
                                value = tempInt;
69
 
70
                                //printf("\n%u %u\n", regAddr, value);
71
 
72
                                CHECK(GpibRegAccess_writeReg(&ra, regAddr, value));
73
                        }
74
                        else if(chr == 'a')
75
                        {
76
                                scanf("%u", &regAddr);
77
                                scanf("%x", &tempInt);
78
 
79
                                value = tempInt;
80
 
81
                                //printf("\n%u %u\n", regAddr, value);
82
 
83
                                CHECK(GpibRegAccess_readReg(&ra, regAddr, &value1));
84
                                CHECK(GpibRegAccess_writeReg(&ra, regAddr, value & value1));
85
                        }
86
                        else if(chr == 'o')
87
                        {
88
                                scanf("%u", &regAddr);
89
                                scanf("%x", &tempInt);
90
 
91
                                value = tempInt;
92
 
93
                                //printf("\n%u %u\n", regAddr, value);
94
 
95
                                CHECK(GpibRegAccess_readReg(&ra, regAddr, &value1));
96
                                CHECK(GpibRegAccess_writeReg(&ra, regAddr, value | value1));
97
                        }
98
                }
99
                else
100
                {
101
                        break;
102
                }
103
        }
104
        while(true);
105
 
106
        GpibRegAccess_release(&ra);
107
 
108
        printf("end\n");
109
 
110
        return 0;
111
 
112
        error:
113
                printf("error");
114
                GpibRegAccess_release(&ra);
115
                return -1;
116
}

powered by: WebSVN 2.1.0

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