1 // Copyright (C) 2009 Ubixum, Inc.
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.
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, see <http://www.gnu.org/licenses/>.
18 * These functions do the same thing that the Cypress gpif designer expored c file does.
19 * Instead of including their file directly in your project, you include just the
20 * generated waveform data. The gpif2dat script in the utils folder will export your
21 * waveform data to a file that can be included in your project.
29 #define GPIFDONE (GPIFTRIG&0x80)
30 #define GPIFTC16 (MAKEWORD(GPIFTCB1,GPIFTCB0))
31 #define GPIFTC32 (MAKEDWORD(MAKEWORD(GPIFTCB3,GPIFTCB2),MAKEWORD(GPIFTCB1,GPIFTCB0)))
35 * Gpif designer generates a c file with waveform data.
36 * Copy the WaveData[128] array
37 * and the InitData[7] to your code somewhere
38 * Then this function is pretty much the reset of the generated
39 * code but ported to sdcc.
41 * uses syncdelay of 4 which might not be long enough if peripheral
42 * runs slower than 30mhz. May not affect anything.
44 * IFCONFIG is set with IFCFG[1:0] = 10 for GPIF master but you still
45 * have to set the ifclk, polarity, and the rest of the bits
48 void gpif_init( BYTE* waveform, BYTE* initdata );
51 * Uses the correct bytes from your flowstates array.
52 * This may or may not be needed depending on whether
53 * your waveform data uses flowstates. If you don't
54 * know if you need them or not, you probably don't.
56 * flowstates should have 36 elements.
59 void gpif_setflowstate( BYTE* flowstates, BYTE bank);
63 //! These defines/functions pretty much out of the TRM 10.4
74 * \brief Simple function to help set the transaction count for gpif
76 * \param tc 32 bit Transaction Count
78 void gpif_set_tc32(DWORD tc);
80 * \brief Simple function to set transaction count for gpif transactions.
81 * \param tc 16 bit Transaction Count
83 void gpif_set_tc16(WORD tc);
87 * Use the gpif to read a single word at a time.
88 * Read len words and store in res
90 * At least one EPxFIFOCFG has to have wordwide=1 or this
91 * functions won't transfer both bytes.
94 void gpif_single_read16( WORD* res , WORD len);
97 * Use the gpif to write a single word at a time.
98 * Write len words from data
100 * At leat one EPxFIFOCFG has to have wordwide=1 or this
101 * function won't transfer both bytes.
103 void gpif_single_write16( WORD* __data, WORD len);
105 void gpif_fifo_read ( GPIF_EP_NUM ep_num );
107 void gpif_fifo_write( GPIF_EP_NUM ep_num );