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, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
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.
30 #define GPIFDONE (GPIFTRIG&0x80)
31 #define GPIFTC16 (MAKEWORD(GPIFTCB1,GPIFTCB0))
32 #define GPIFTC32 (MAKEDWORD(MAKEWORD(GPIFTCB3,GPIFTCB2),MAKEWORD(GPIFTCB1,GPIFTCB0)))
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
49 void gpif_init( BYTE
* waveform
, BYTE
* initdata
);
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.
60 void gpif_setflowstate( BYTE
* flowstates
, BYTE bank
);
64 //! These defines/functions pretty much out of the TRM 10.4
75 * \brief Simple function to help set the transaction count for gpif
77 * \param tc 32 bit Transaction Count
79 void gpif_set_tc32(DWORD tc
);
81 * \brief Simple function to set transaction count for gpif transactions.
82 * \param tc 16 bit Transaction Count
84 void gpif_set_tc16(WORD tc
);
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.
95 void gpif_single_read16( WORD
* res
, WORD len
);
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
);