remove a bash-ism from a Makefile
[fx2lib.git] / include / gpif.h
blob5afaf26e9aae81cacefad967b89bc9f50472f5be
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.
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
17 /*! \file
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 * */
25 #ifndef GPIF_H
26 #define GPIF_H
28 #include "fx2types.h"
30 #define GPIFDONE (GPIFTRIG&0x80)
31 #define GPIFTC16 (MAKEWORD(GPIFTCB1,GPIFTCB0))
32 #define GPIFTC32 (MAKEDWORD(MAKEWORD(GPIFTCB3,GPIFTCB2),MAKEWORD(GPIFTCB1,GPIFTCB0)))
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.
42 * uses syncdelay of 4 which might not be long enough if peripheral
43 * runs slower than 30mhz. May not affect anything.
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 **/
49 void gpif_init( BYTE* waveform, BYTE* initdata );
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.
57 * flowstates should have 36 elements.
58 * bank should be 0-3
59 **/
60 void gpif_setflowstate( BYTE* flowstates, BYTE bank);
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;
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);
87 /**
88 * Use the gpif to read a single word at a time.
89 * Read len words and store in res
91 * At least one EPxFIFOCFG has to have wordwide=1 or this
92 * functions won't transfer both bytes.
93 **/
95 void gpif_single_read16( WORD* res , WORD len);
97 /**
98 * Use the gpif to write a single word at a time.
99 * Write len words from data
101 * At leat one EPxFIFOCFG has to have wordwide=1 or this
102 * function won't transfer both bytes.
104 void gpif_single_write16( WORD* dat, WORD len);
106 void gpif_fifo_read ( GPIF_EP_NUM ep_num );
108 void gpif_fifo_write( GPIF_EP_NUM ep_num );
110 #endif