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

Subversion Repositories s80186

[/] [s80186/] [trunk/] [vendor/] [altera-jtag/] [jload.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 jamieiles
/* Copyright 2012 Brian Swetland <swetland@frotz.net>
2
 *
3
 * Licensed under the Apache License, Version 2.0 (the "License");
4
 * you may not use this file except in compliance with the License.
5
 * You may obtain a copy of the License at
6
 *
7
 *     http://www.apache.org/licenses/LICENSE-2.0
8
 *
9
 * Unless required by applicable law or agreed to in writing, software
10
 * distributed under the License is distributed on an "AS IS" BASIS,
11
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
 * See the License for the specific language governing permissions and
13
 * limitations under the License.
14
 */
15
 
16
#include <stdio.h>
17
#include <stdlib.h>
18
#include <ctype.h>
19
#include "jtag.h"
20
 
21
#define VIR_CTRL        0x0
22
#define VIR_ADDR        0x1
23
#define VIR_DATA        0x2
24
 
25
int main(int argc, char **argv) {
26
        unsigned bits;
27
        char buf[1024];
28
        FILE *fp;
29
 
30
        if (argc != 2) {
31
                fprintf(stderr,"usage: download hexfile\n");
32
                return -1;
33
        }
34
 
35
        if (jtag_open_virtual_device(0x00))
36
                return -1;
37
 
38
        fp = fopen(argv[1],"r");
39
        if (!fp) return -1;
40
 
41
        jtag_vir(VIR_CTRL);
42
        jtag_vdr(32, 1, 0);
43
 
44
        jtag_vir(VIR_ADDR);
45
        jtag_vdr(32, 0, 0);
46
 
47
        jtag_vir(VIR_DATA);
48
        while (fgets(buf, 1024, fp)) {
49
                if(buf[0] == '/') continue;
50
                if(isspace(buf[0])) continue;
51
                bits = strtoul(buf, 0, 16);
52
                jtag_vdr(32, bits, 0);
53
        }
54
 
55
        jtag_vir(VIR_CTRL);
56
        jtag_vdr(32, 0, 0);
57
        return 0;
58
}
59
 

powered by: WebSVN 2.1.0

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