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

Subversion Repositories amber

[/] [amber/] [trunk/] [sw/] [boot-loader-ethmac/] [utilities.c] - Blame information for rev 80

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 61 csantifort
/*----------------------------------------------------------------
2
//                                                              //
3
//  boot-loader-ethmac.c                                        //
4
//                                                              //
5
//  This file is part of the Amber project                      //
6
//  http://www.opencores.org/project,amber                      //
7
//                                                              //
8
//  Description                                                 //
9
//  The main functions for the boot loader application. This    //
10 80 csantifort
//  application is embedded in the FPGA's SRAM and is used      //
11 61 csantifort
//  to load larger applications into the DDR3 memory on         //
12
//  the development board.                                      //
13
//                                                              //
14
//  Author(s):                                                  //
15
//      - Conor Santifort, csantifort.amber@gmail.com           //
16
//                                                              //
17
//////////////////////////////////////////////////////////////////
18
//                                                              //
19
// Copyright (C) 2011 Authors and OPENCORES.ORG                 //
20
//                                                              //
21
// This source file may be used and distributed without         //
22
// restriction provided that this copyright statement is not    //
23
// removed from the file and that any derivative work contains  //
24
// the original copyright notice and the associated disclaimer. //
25
//                                                              //
26
// This source file is free software; you can redistribute it   //
27
// and/or modify it under the terms of the GNU Lesser General   //
28
// Public License as published by the Free Software Foundation; //
29
// either version 2.1 of the License, or (at your option) any   //
30
// later version.                                               //
31
//                                                              //
32
// This source is distributed in the hope that it will be       //
33
// useful, but WITHOUT ANY WARRANTY; without even the implied   //
34
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
35
// PURPOSE.  See the GNU Lesser General Public License for more //
36
// details.                                                     //
37
//                                                              //
38
// You should have received a copy of the GNU Lesser General    //
39
// Public License along with this source; if not, download it   //
40
// from http://www.opencores.org/lgpl.shtml                     //
41
//                                                              //
42
----------------------------------------------------------------*/
43
 
44
#include "amber_registers.h"
45
#include "utilities.h"
46
 
47
 
48
int next_string(char*buf)
49
{
50
    int pos = 0;
51
    while (*buf != 0) {buf++; pos++;}
52
    return ++pos;
53
}
54
 
55
 
56
int strcmp(char* str1, char*str2)
57
{
58
    int pos = 0;
59
    int equal=1;
60 80 csantifort
 
61 61 csantifort
    while (*str1!=0 && *str2!=0 && pos<256 && equal) {
62
        equal = *str1==*str2;
63
        str1++;
64
        str2++;
65
        pos++;
66
        }
67
    return equal;
68
}
69
 
70
 
71
/* Return a number recovered from a string of hex digits */
72
int get_hex (char * buf, unsigned int *num)
73
{
74
    int cpos = 0, done = 0;
75
    *num = 0;
76
 
77 80 csantifort
    while (!done) {
78 61 csantifort
        if ( buf[cpos] >= '0' && buf[cpos] <= '9' ) {
79
           *num = *num<<4;
80
           *num = *num + buf[cpos] - '0';
81
           }
82
        else if ( buf[cpos] >= 'A' && buf[cpos] <= 'F' ) {
83
            *num = *num<<4;
84
            *num = *num + buf[cpos] - 'A' + 10;
85
           }
86
        else if ( buf[cpos] >= 'a' && buf[cpos] <= 'f' ) {
87
            *num = *num<<4;
88
            *num = *num + buf[cpos] - 'a' + 10;
89
           }
90
        else
91
            done = 1;
92 80 csantifort
 
93 61 csantifort
        // Don't increment cops if the first character is not part of an ascii-hex string
94
        // oo that a 0 is returned to indicate failure.
95 80 csantifort
        if (!done)
96 61 csantifort
            cpos++;
97 80 csantifort
 
98 61 csantifort
        if (cpos >= 8)
99
            done = 1;
100
        }
101 80 csantifort
 
102 61 csantifort
    /* Return length of acsii-hex string */
103
    return cpos;
104
}
105
 
106
 
107
void udelay20(void)
108
{
109
    volatile int i;
110
    for (i=0;i<500;i++) ;
111
}
112
 
113
 
114
void phy_rst(int value)
115
{
116
    *(unsigned int *) ADR_AMBER_TEST_PHY_RST = value;
117
}
118
 

powered by: WebSVN 2.1.0

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