projects
/
fx2fw-sdcc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
version 4.2.0
[fx2fw-sdcc]
/
hw_xpcu_i.c
diff --git
a/hw_xpcu_i.c
b/hw_xpcu_i.c
index
0e80063
..
c4bb681
100644
(file)
--- a/
hw_xpcu_i.c
+++ b/
hw_xpcu_i.c
@@
-1,300
+1,152
@@
/*-----------------------------------------------------------------------------
\r
/*-----------------------------------------------------------------------------
\r
-
\r
*
\r
*
\r
-
\r
* Hardware-dependent code for usb_jtag
\r
* Hardware-dependent code for usb_jtag
\r
-
\r
*-----------------------------------------------------------------------------
\r
*-----------------------------------------------------------------------------
\r
-
\r
* Copyright (C) 2007 Kolja Waschk, ixo.de
\r
* Copyright (C) 2007 Kolja Waschk, ixo.de
\r
-
\r
*-----------------------------------------------------------------------------
\r
*-----------------------------------------------------------------------------
\r
-
\r
* This code is part of usbjtag. usbjtag is free software; you can redistribute
\r
* This code is part of usbjtag. usbjtag is free software; you can redistribute
\r
-
\r
* it and/or modify it under the terms of the GNU General Public License as
\r
* it and/or modify it under the terms of the GNU General Public License as
\r
-
\r
* published by the Free Software Foundation; either version 2 of the License,
\r
* published by the Free Software Foundation; either version 2 of the License,
\r
-
\r
* or (at your option) any later version. usbjtag is distributed in the hope
\r
* or (at your option) any later version. usbjtag is distributed in the hope
\r
-
\r
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
\r
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
\r
-
\r
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
-
\r
* GNU General Public License for more details. You should have received a
\r
* GNU General Public License for more details. You should have received a
\r
-
\r
* copy of the GNU General Public License along with this program in the file
\r
* copy of the GNU General Public License along with this program in the file
\r
-
\r
* COPYING; if not, write to the Free Software Foundation, Inc., 51 Franklin
\r
* COPYING; if not, write to the Free Software Foundation, Inc., 51 Franklin
\r
-
\r
* St, Fifth Floor, Boston, MA 02110-1301 USA
\r
* St, Fifth Floor, Boston, MA 02110-1301 USA
\r
-
\r
*-----------------------------------------------------------------------------
\r
*-----------------------------------------------------------------------------
\r
-
\r
*/
\r
\r
*/
\r
\r
-
\r
-
\r
#include "hardware.h"
\r
#include "hardware.h"
\r
-
\r
#include "fx2regs.h"
\r
#include "fx2regs.h"
\r
-
\r
#include "syncdelay.h"
\r
\r
#include "syncdelay.h"
\r
\r
-
\r
-
\r
//---------------------------------------------------------------------------
\r
\r
//---------------------------------------------------------------------------
\r
\r
-
\r
-
\r
#define SetTCK(x) do{if(x) IOE|=0x08; else IOE&=~0x08; }while(0)
\r
#define SetTCK(x) do{if(x) IOE|=0x08; else IOE&=~0x08; }while(0)
\r
-
\r
#define SetTMS(x) do{if(x) IOE|=0x10; else IOE&=~0x10; }while(0)
\r
#define SetTMS(x) do{if(x) IOE|=0x10; else IOE&=~0x10; }while(0)
\r
-
\r
#define SetTDI(x) do{if(x) IOE|=0x40; else IOE&=~0x40; }while(0)
\r
#define SetTDI(x) do{if(x) IOE|=0x40; else IOE&=~0x40; }while(0)
\r
-
\r
#define GetTDO() ((IOE>>5)&1)
\r
\r
#define GetTDO() ((IOE>>5)&1)
\r
\r
-
\r
-
\r
/* XPCU has neither AS nor PS mode pins */
\r
\r
/* XPCU has neither AS nor PS mode pins */
\r
\r
-
\r
-
\r
#define HAVE_OE_LED 1
\r
#define HAVE_OE_LED 1
\r
-
\r
/* +0=green led, +1=red led */
\r
/* +0=green led, +1=red led */
\r
-
\r
sbit at 0x80+1 OELED;
\r
sbit at 0x80+1 OELED;
\r
-
\r
#define SetOELED(x) do{OELED=(x);}while(0)
\r
\r
#define SetOELED(x) do{OELED=(x);}while(0)
\r
\r
-
\r
-
\r
//-----------------------------------------------------------------------------
\r
\r
//-----------------------------------------------------------------------------
\r
\r
-
\r
-
\r
void ProgIO_Poll(void) {}
\r
void ProgIO_Poll(void) {}
\r
-
\r
void ProgIO_Enable(void) {}
\r
void ProgIO_Enable(void) {}
\r
-
\r
void ProgIO_Disable(void) {}
\r
void ProgIO_Disable(void) {}
\r
-
\r
void ProgIO_Deinit(void) {}
\r
\r
void ProgIO_Deinit(void) {}
\r
\r
-
\r
-
\r
void ProgIO_Init(void)
\r
void ProgIO_Init(void)
\r
-
\r
{
\r
{
\r
-
\r
/* The following code depends on your actual circuit design.
\r
/* The following code depends on your actual circuit design.
\r
-
\r
Make required changes _before_ you try the code! */
\r
\r
Make required changes _before_ you try the code! */
\r
\r
-
\r
-
\r
// set the CPU clock to 48MHz, enable clock output to FPGA
\r
// set the CPU clock to 48MHz, enable clock output to FPGA
\r
-
\r
CPUCS = bmCLKOE | bmCLKSPD1;
\r
\r
CPUCS = bmCLKOE | bmCLKSPD1;
\r
\r
-
\r
-
\r
// Use internal 48 MHz, enable output, use "Port" mode for all pins
\r
// Use internal 48 MHz, enable output, use "Port" mode for all pins
\r
-
\r
IFCONFIG = bmIFCLKSRC | bm3048MHZ | bmIFCLKOE;
\r
\r
IFCONFIG = bmIFCLKSRC | bm3048MHZ | bmIFCLKOE;
\r
\r
-
\r
-
\r
GPIFABORT = 0xFF;
\r
\r
GPIFABORT = 0xFF;
\r
\r
-
\r
-
\r
PORTACFG = 0x00; OEA = 0x03; IOA=0x01;
\r
PORTACFG = 0x00; OEA = 0x03; IOA=0x01;
\r
-
\r
PORTCCFG = 0x00; OEC = 0x00; IOC=0x00;
\r
PORTCCFG = 0x00; OEC = 0x00; IOC=0x00;
\r
-
\r
PORTECFG = 0x00; OEE = 0x58; IOE=0x00;
\r
PORTECFG = 0x00; OEE = 0x58; IOE=0x00;
\r
-
\r
}
\r
\r
}
\r
\r
-
\r
-
\r
void ProgIO_Set_State(unsigned char d)
\r
void ProgIO_Set_State(unsigned char d)
\r
-
\r
{
\r
{
\r
-
\r
- /* Set state of output pins:
\r
-
\r
+ /* Set state of output pins
\r
+ * (d is the byte from the host):
\r
*
\r
*
\r
-
\r
* d.0 => TCK
\r
* d.0 => TCK
\r
-
\r
* d.1 => TMS
\r
* d.1 => TMS
\r
-
\r
* d.2 => nCE (only #ifdef HAVE_AS_MODE)
\r
* d.2 => nCE (only #ifdef HAVE_AS_MODE)
\r
-
\r
* d.3 => nCS (only #ifdef HAVE_AS_MODE)
\r
* d.3 => nCS (only #ifdef HAVE_AS_MODE)
\r
-
\r
* d.4 => TDI
\r
* d.4 => TDI
\r
-
\r
* d.6 => LED / Output Enable
\r
* d.6 => LED / Output Enable
\r
-
\r
*/
\r
\r
*/
\r
\r
-
\r
-
\r
SetTCK((d & bmBIT0) ? 1 : 0);
\r
SetTCK((d & bmBIT0) ? 1 : 0);
\r
-
\r
SetTMS((d & bmBIT1) ? 1 : 0);
\r
SetTMS((d & bmBIT1) ? 1 : 0);
\r
-
\r
SetTDI((d & bmBIT4) ? 1 : 0);
\r
SetTDI((d & bmBIT4) ? 1 : 0);
\r
-
\r
#ifdef HAVE_OE_LED
\r
#ifdef HAVE_OE_LED
\r
-
\r
SetOELED((d & bmBIT5) ? 1 : 0);
\r
SetOELED((d & bmBIT5) ? 1 : 0);
\r
-
\r
#endif
\r
#endif
\r
-
\r
}
\r
\r
}
\r
\r
-
\r
-
\r
unsigned char ProgIO_Set_Get_State(unsigned char d)
\r
unsigned char ProgIO_Set_Get_State(unsigned char d)
\r
-
\r
{
\r
{
\r
-
\r
- /* Read state of input pins:
\r
-
\r
+ /* Set state of output pins (s.a.)
\r
+ * then read state of input pins:
\r
*
\r
*
\r
-
\r
* TDO => d.0
\r
* TDO => d.0
\r
-
\r
* DATAOUT => d.1 (only #ifdef HAVE_AS_MODE)
\r
* DATAOUT => d.1 (only #ifdef HAVE_AS_MODE)
\r
-
\r
*/
\r
\r
*/
\r
\r
-
\r
-
\r
ProgIO_Set_State(d);
\r
ProgIO_Set_State(d);
\r
-
\r
- return 2|GetTDO();
\r
-
\r
+ return 2|GetTDO(); /* DATAOUT assumed high, no AS mode */
\r
}
\r
\r
}
\r
\r
-
\r
-
\r
void ProgIO_ShiftOut(unsigned char c)
\r
void ProgIO_ShiftOut(unsigned char c)
\r
-
\r
{
\r
{
\r
-
\r
/* Shift out byte C:
\r
/* Shift out byte C:
\r
-
\r
*
\r
*
\r
-
\r
* 8x {
\r
* 8x {
\r
-
\r
* Output least significant bit on TDI
\r
* Output least significant bit on TDI
\r
-
\r
* Raise TCK
\r
* Raise TCK
\r
-
\r
* Shift c right
\r
* Shift c right
\r
-
\r
* Lower TCK
\r
* Lower TCK
\r
-
\r
* }
\r
* }
\r
-
\r
*/
\r
\r
*/
\r
\r
-
\r
-
\r
unsigned char lc=c;
\r
\r
unsigned char lc=c;
\r
\r
-
\r
-
\r
if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc>>=1; IOE&=~0x08;
\r
if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc>>=1; IOE&=~0x08;
\r
-
\r
if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc>>=1; IOE&=~0x08;
\r
if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc>>=1; IOE&=~0x08;
\r
-
\r
if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc>>=1; IOE&=~0x08;
\r
if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc>>=1; IOE&=~0x08;
\r
-
\r
if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc>>=1; IOE&=~0x08;
\r
\r
if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc>>=1; IOE&=~0x08;
\r
\r
-
\r
-
\r
if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc>>=1; IOE&=~0x08;
\r
if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc>>=1; IOE&=~0x08;
\r
-
\r
if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc>>=1; IOE&=~0x08;
\r
if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc>>=1; IOE&=~0x08;
\r
-
\r
if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc>>=1; IOE&=~0x08;
\r
if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc>>=1; IOE&=~0x08;
\r
-
\r
if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc>>=1; IOE&=~0x08;
\r
if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc>>=1; IOE&=~0x08;
\r
-
\r
}
\r
\r
}
\r
\r
-
\r
-
\r
unsigned char ProgIO_ShiftInOut(unsigned char c)
\r
unsigned char ProgIO_ShiftInOut(unsigned char c)
\r
-
\r
{
\r
{
\r
-
\r
/* Shift out byte C, shift in from TDO:
\r
/* Shift out byte C, shift in from TDO:
\r
-
\r
*
\r
*
\r
-
\r
* 8x {
\r
* 8x {
\r
-
\r
* Read carry from TDO
\r
* Read carry from TDO
\r
-
\r
* Output least significant bit on TDI
\r
* Output least significant bit on TDI
\r
-
\r
* Raise TCK
\r
* Raise TCK
\r
-
\r
- * Shift c right, append carry (TDO) at left
\r
-
\r
+ * Shift c right, append carry (TDO) at left (into MSB)
\r
* Lower TCK
\r
* Lower TCK
\r
-
\r
* }
\r
* }
\r
-
\r
* Return c.
\r
* Return c.
\r
-
\r
*/
\r
\r
*/
\r
\r
-
\r
-
\r
unsigned char carry;
\r
unsigned char carry;
\r
-
\r
unsigned char lc=c;
\r
\r
unsigned char lc=c;
\r
\r
-
\r
-
\r
carry = (IOE&0x20)<<2; if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc=carry|(lc>>1); IOE&=~0x08;
\r
carry = (IOE&0x20)<<2; if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc=carry|(lc>>1); IOE&=~0x08;
\r
-
\r
carry = (IOE&0x20)<<2; if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc=carry|(lc>>1); IOE&=~0x08;
\r
carry = (IOE&0x20)<<2; if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc=carry|(lc>>1); IOE&=~0x08;
\r
-
\r
carry = (IOE&0x20)<<2; if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc=carry|(lc>>1); IOE&=~0x08;
\r
carry = (IOE&0x20)<<2; if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc=carry|(lc>>1); IOE&=~0x08;
\r
-
\r
carry = (IOE&0x20)<<2; if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc=carry|(lc>>1); IOE&=~0x08;
\r
\r
carry = (IOE&0x20)<<2; if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc=carry|(lc>>1); IOE&=~0x08;
\r
\r
-
\r
-
\r
carry = (IOE&0x20)<<2; if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc=carry|(lc>>1); IOE&=~0x08;
\r
carry = (IOE&0x20)<<2; if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc=carry|(lc>>1); IOE&=~0x08;
\r
-
\r
carry = (IOE&0x20)<<2; if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc=carry|(lc>>1); IOE&=~0x08;
\r
carry = (IOE&0x20)<<2; if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc=carry|(lc>>1); IOE&=~0x08;
\r
-
\r
carry = (IOE&0x20)<<2; if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc=carry|(lc>>1); IOE&=~0x08;
\r
carry = (IOE&0x20)<<2; if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc=carry|(lc>>1); IOE&=~0x08;
\r
-
\r
carry = (IOE&0x20)<<2; if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc=carry|(lc>>1); IOE&=~0x08;
\r
\r
carry = (IOE&0x20)<<2; if(lc&1) IOE|=0x40; else IOE&=~0x40; IOE|=0x08; lc=carry|(lc>>1); IOE&=~0x08;
\r
\r
-
\r
-
\r
return lc;
\r
return lc;
\r
-
\r
}
\r
\r
\r
}
\r
\r
\r
-
\r
-
\r
-
\r