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

Subversion Repositories usb_fpga_1_2

[/] [usb_fpga_1_2/] [trunk/] [include/] [ztex-utils.h] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 ZTEX
/*!
2
   ZTEX Firmware Kit for EZ-USB Microcontrollers
3
   Copyright (C) 2008-2009 ZTEX e.K.
4
   http://www.ztex.de
5
 
6
   This program is free software; you can redistribute it and/or modify
7
   it under the terms of the GNU General Public License version 3 as
8
   published by the Free Software Foundation.
9
 
10
   This program is distributed in the hope that it will be useful, but
11
   WITHOUT ANY WARRANTY; without even the implied warranty of
12
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
   General Public License for more details.
14
 
15
   You should have received a copy of the GNU General Public License
16
   along with this program; if not, see http://www.gnu.org/licenses/.
17
!*/
18
 
19
/*
20
   Various utility routines
21
*/
22
 
23
#ifndef[ZTEX_UTILS_H]
24
#define[ZTEX_UTILS_H]
25
 
26
#define[bmBIT0][1]
27
#define[bmBIT1][2]
28
#define[bmBIT2][4]
29
#define[bmBIT3][8]
30
#define[bmBIT4][16]
31
#define[bmBIT5][32]
32
#define[bmBIT6][64]
33
#define[bmBIT7][128]
34
 
35
#define[NOP;][_asm 
36
        nop
37
    _endasm;
38
]
39
 
40
#define[MSB(][)][((BYTE)(((unsigned short)($0)) >> 8))]
41
#define[LSB(][)][((BYTE)($0))]
42
#define[HI(][)][((BYTE)(((unsigned short)($0)) >> 8))]
43
#define[LO(][)][((BYTE)($0))]
44
 
45
typedef unsigned char BYTE;
46
typedef unsigned short WORD;
47
typedef unsigned long DWORD;
48
 
49
/* *********************************************************************
50
   ***** include the basic functions ***********************************
51
   ********************************************************************* */
52
#include[ezregs.h]
53
#include[ezintavecs.h]
54
 
55
/* *********************************************************************
56
   ***** wait **********************************************************
57
   ********************************************************************* */
58
void wait(WORD short ms) {        // wait in ms 
59
    WORD i,j;
60
    for (j=0; j<ms; j++)
61
        for (i=0; i<1200; i++);
62
}
63
 
64
 
65
/* *********************************************************************
66
   ***** uwait *********************************************************
67
   ********************************************************************* */
68
void uwait(WORD short us) {       // wait in 10µs steps
69
    WORD i,j;
70
    for (j=0; j<us; j++)
71
        for (i=0; i<120; i++);
72
}
73
 
74
 
75
/* *********************************************************************
76
   ***** MEM_COPY ******************************************************
77
   ********************************************************************* */
78
// copies 1..256 bytes 
79
void MEM_COPY1_int() __naked {
80
        _asm
81
020001$:
82
            mov         _AUTOPTRSETUP,#0x07
83
            mov         dptr,#_XAUTODAT1
84
            movx        a,@dptr
85
            mov         dptr,#_XAUTODAT2
86
            movx        @dptr,a
87
            djnz        r2, 020001$
88
            ret
89
        _endasm;
90
}
91
 
92
/*
93
    ! no spaces before/after commas allowed !
94
 
95
    This will work too:
96
        MEM_COPY1(fpga_checksum,EP0BUF+1,6);
97
*/
98
 
99
#define[MEM_COPY1(][,$1,$2);][{
100
        _asm
101
                mov     _AUTOPTRL1,#(_$0)
102
                mov     _AUTOPTRH1,#((_$0) >> 8)
103
                mov     _AUTOPTRL2,#(_$1)
104
                mov     _AUTOPTRH2,#((_$1) >> 8)
105
                mov     r2,#($2);
106
                lcall _MEM_COPY1_int
107
        _endasm;
108
}]
109
 
110
 
111
#endif // ZTEX_UTILS_H

powered by: WebSVN 2.1.0

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