]>
Commit | Line | Data |
---|---|---|
1 | // Copyright (C) 2009 Ubixum, Inc. | |
2 | // | |
3 | // This library is free software; you can redistribute it and/or | |
4 | // modify it under the terms of the GNU Lesser General Public | |
5 | // License as published by the Free Software Foundation; either | |
6 | // version 2.1 of the License, or (at your option) any later version. | |
7 | // | |
8 | // This library is distributed in the hope that it will be useful, | |
9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
11 | // Lesser General Public License for more details. | |
12 | // | |
13 | // You should have received a copy of the GNU Lesser General Public | |
14 | // License along with this library; if not, write to the Free Software | |
15 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | |
16 | ||
17 | /*! \file | |
18 | * | |
19 | * These functions do the same thing that the Cypress gpif designer expored c file does. | |
20 | * Instead of including their file directly in your project, you include just the | |
21 | * generated waveform data. The gpif2dat script in the utils folder will export your | |
22 | * waveform data to a file that can be included in your project. | |
23 | * */ | |
24 | ||
25 | #ifndef GPIF_H | |
26 | #define GPIF_H | |
27 | ||
28 | #include "fx2types.h" | |
29 | ||
30 | #define GPIFDONE (GPIFTRIG&0x80) | |
31 | #define GPIFTC16 (MAKEWORD(GPIFTCB1,GPIFTCB0)) | |
32 | #define GPIFTC32 (MAKEDWORD(MAKEWORD(GPIFTCB3,GPIFTCB2),MAKEWORD(GPIFTCB1,GPIFTCB0))) | |
33 | ||
34 | ||
35 | /** | |
36 | * Gpif designer generates a c file with waveform data. | |
37 | * Copy the WaveData[128] array | |
38 | * and the InitData[7] to your code somewhere | |
39 | * Then this function is pretty much the reset of the generated | |
40 | * code but ported to sdcc. | |
41 | * | |
42 | * uses syncdelay of 4 which might not be long enough if peripheral | |
43 | * runs slower than 30mhz. May not affect anything. | |
44 | * | |
45 | * IFCONFIG is set with IFCFG[1:0] = 10 for GPIF master but you still | |
46 | * have to set the ifclk, polarity, and the rest of the bits | |
47 | **/ | |
48 | ||
49 | void gpif_init( BYTE* waveform, BYTE* initdata ); | |
50 | ||
51 | /** | |
52 | * Uses the correct bytes from your flowstates array. | |
53 | * This may or may not be needed depending on whether | |
54 | * your waveform data uses flowstates. If you don't | |
55 | * know if you need them or not, you probably don't. | |
56 | * | |
57 | * flowstates should have 36 elements. | |
58 | * bank should be 0-3 | |
59 | **/ | |
60 | void gpif_setflowstate( BYTE* flowstates, BYTE bank); | |
61 | ||
62 | ||
63 | ||
64 | //! These defines/functions pretty much out of the TRM 10.4 | |
65 | #define GPIFTRGWR 0 | |
66 | #define GPIFTRGRD 4 | |
67 | typedef enum { | |
68 | GPIF_EP2 = 0, | |
69 | GPIF_EP4 = 1, | |
70 | GPIF_EP6 = 2, | |
71 | GPIF_EP8 = 3 | |
72 | } GPIF_EP_NUM; | |
73 | ||
74 | /** | |
75 | * \brief Simple function to help set the transaction count for gpif | |
76 | * transactions. | |
77 | * \param tc 32 bit Transaction Count | |
78 | **/ | |
79 | void gpif_set_tc32(DWORD tc); | |
80 | /** | |
81 | * \brief Simple function to set transaction count for gpif transactions. | |
82 | * \param tc 16 bit Transaction Count | |
83 | **/ | |
84 | void gpif_set_tc16(WORD tc); | |
85 | ||
86 | ||
87 | /** | |
88 | * Use the gpif to read a single word at a time. | |
89 | * Read len words and store in res | |
90 | * | |
91 | * At least one EPxFIFOCFG has to have wordwide=1 or this | |
92 | * functions won't transfer both bytes. | |
93 | **/ | |
94 | ||
95 | void gpif_single_read16( WORD* res , WORD len); | |
96 | ||
97 | /** | |
98 | * Use the gpif to write a single word at a time. | |
99 | * Write len words from data | |
100 | * | |
101 | * At leat one EPxFIFOCFG has to have wordwide=1 or this | |
102 | * function won't transfer both bytes. | |
103 | **/ | |
104 | void gpif_single_write16( WORD* __data, WORD len); | |
105 | ||
106 | void gpif_fifo_read ( GPIF_EP_NUM ep_num ); | |
107 | ||
108 | void gpif_fifo_write( GPIF_EP_NUM ep_num ); | |
109 | ||
110 | #endif |