?? gpif.c
字號:
// This program configures the General Programmable Interface (GPIF) for FX2.
// Parts of this program are automatically generated using the GPIFTool.
// Please do not modify sections of text which are marked as "DO NOT EDIT ...".
// You can modify the comments section of this GPIF program file using the dropdown menus
// and pop-up dialogs. These controls are available as hot spots in the text. Modifying the
// comments section will generate program code which will implement your GPIF program.
//
// DO NOT EDIT ...
// GPIF Initialization
// Interface Timing Sync
// Internal Ready Init IntRdy=1
// CTL Out Tristate-able Tristate
// SingleWrite WF Select 3
// SingleRead WF Select 2
// FifoWrite WF Select 1
// FifoRead WF Select 0
// Data Bus Idle Drive Tristate
// END DO NOT EDIT
// DO NOT EDIT ...
// GPIF Wave Names
// Wave 0 = FIFORd
// Wave 1 = unused
// Wave 2 = unused
// Wave 3 = unused
// GPIF Ctrl Outputs Level
// CTL 0 = FIFORD CMOS
// CTL 1 = CTL1 CMOS
// CTL 2 = CTL2 CMOS
// CTL 3 = unused CMOS
// CTL 4 = unused CMOS
// CTL 5 = unused CMOS
// GPIF Rdy Inputs
// RDY0 = EF#
// RDY1 = HF#
// RDY2 = unused
// RDY3 = unused
// RDY4 = unused
// RDY5 = TC
// FIFOFlag = FIFOFlag
// IntReady = IntReady
// END DO NOT EDIT
// DO NOT EDIT ...
//
// GPIF Waveform 0: FIFORd
//
// Interval 0 1 2 3 4 5 6 Idle (7)
// _________ _________ _________ _________ _________ _________ _________ _________
//
// AddrMode Same Val Same Val Same Val Same Val Same Val Same Val Same Val
// DataMode NO Data NO Data Activate NO Data Activate NO Data NO Data
// NextData SameData SameData SameData SameData SameData SameData SameData
// Int Trig No Int No Int No Int No Int No Int No Int No Int
// IF/Wait Wait 1 Wait 1 Wait 1 Wait 1 IF Wait 1 Wait 1
// Term A TC
// LFunc AND
// Term B TC
// Branch1 ThenIdle
// Branch0 Else 0
// Re-Exec No
// Sngl/CRC Default Default Default Default Default Default Default
// FIFORD 1 0 1 0 1 1 1 z
// CTL1 1 1 1 1 1 1 1 0
// CTL2 1 1 1 1 1 1 1 1
// unused 1 1 1 1 1 1 1 1
// unused
// unused
//
// END DO NOT EDIT
// DO NOT EDIT ...
//
// GPIF Waveform 1: unused
//
// Interval 0 1 2 3 4 5 6 Idle (7)
// _________ _________ _________ _________ _________ _________ _________ _________
//
// AddrMode Same Val Same Val Same Val Same Val Same Val Same Val Same Val
// DataMode Activate NO Data Activate NO Data NO Data NO Data NO Data
// NextData SameData NextData SameData NextData SameData SameData SameData
// Int Trig No Int No Int No Int No Int No Int No Int No Int
// IF/Wait Wait 1 Wait 1 Wait 1 IF Wait 1 Wait 1 Wait 1
// Term A TC
// LFunc AND
// Term B TC
// Branch1 ThenIdle
// Branch0 Else 0
// Re-Exec No
// Sngl/CRC Default Default Default Default Default Default Default
// FIFORD 0 1 0 1 1 1 1 z
// CTL1 1 1 1 1 1 1 1 0
// CTL2 1 1 1 1 1 1 1 1
// unused 1 1 1 1 1 1 1 1
// unused
// unused
//
// END DO NOT EDIT
// DO NOT EDIT ...
//
// GPIF Waveform 2: unused
//
// Interval 0 1 2 3 4 5 6 Idle (7)
// _________ _________ _________ _________ _________ _________ _________ _________
//
// AddrMode Same Val Same Val Same Val Same Val Same Val Same Val Same Val
// DataMode NO Data NO Data NO Data NO Data NO Data NO Data NO Data
// NextData SameData SameData SameData SameData SameData SameData SameData
// Int Trig No Int No Int No Int No Int No Int No Int No Int
// IF/Wait Wait 1 Wait 1 Wait 1 Wait 1 Wait 1 Wait 1 Wait 1
// Term A
// LFunc
// Term B
// Branch1
// Branch0
// Re-Exec
// Sngl/CRC Default Default Default Default Default Default Default
// FIFORD 1 1 1 1 1 1 1 z
// CTL1 1 1 1 1 1 1 1 0
// CTL2 1 1 1 1 1 1 1 1
// unused 1 1 1 1 1 1 1 1
// unused
// unused
//
// END DO NOT EDIT
// DO NOT EDIT ...
//
// GPIF Waveform 3: unused
//
// Interval 0 1 2 3 4 5 6 Idle (7)
// _________ _________ _________ _________ _________ _________ _________ _________
//
// AddrMode Same Val Same Val Same Val Same Val Same Val Same Val Same Val
// DataMode NO Data NO Data NO Data NO Data NO Data NO Data NO Data
// NextData SameData SameData SameData SameData SameData SameData SameData
// Int Trig No Int No Int No Int No Int No Int No Int No Int
// IF/Wait Wait 1 Wait 1 Wait 1 Wait 1 Wait 1 Wait 1 Wait 1
// Term A
// LFunc
// Term B
// Branch1
// Branch0
// Re-Exec
// Sngl/CRC Default Default Default Default Default Default Default
// FIFORD 1 1 1 1 1 1 1 z
// CTL1 1 1 1 1 1 1 1 0
// CTL2 1 1 1 1 1 1 1 1
// unused 1 1 1 1 1 1 1 1
// unused
// unused
//
// END DO NOT EDIT
// GPIF Program Code
// DO NOT EDIT ...
#include "testheader.h"
#include "testregs.h"
#include "testdly.h"
// END DO NOT EDIT
// DO NOT EDIT ...
const char xdata WaveData[128] =
{
// Wave 0
/* LenBr */ 0x01, 0x01, 0x01, 0x01, 0x38, 0x01, 0x01, 0x07,
/* Opcode*/ 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00,
/* Output*/ 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xED,
/* LFun */ 0x00, 0x2D, 0x2D, 0x2D, 0x2D, 0x2D, 0x12, 0x3F,
// Wave 1
/* LenBr */ 0x01, 0x01, 0x01, 0x38, 0x01, 0x01, 0x01, 0x07,
/* Opcode*/ 0x02, 0x04, 0x02, 0x05, 0x00, 0x00, 0x00, 0x00,
/* Output*/ 0xFE, 0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xED,
/* LFun */ 0x00, 0x2D, 0x2D, 0x2D, 0x12, 0x2D, 0x12, 0x3F,
// Wave 2
/* LenBr */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07,
/* Opcode*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* Output*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xED,
/* LFun */ 0x00, 0x09, 0x12, 0x12, 0x00, 0x2D, 0x12, 0x3F,
// Wave 3
/* LenBr */ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x07,
/* Opcode*/ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
/* Output*/ 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xED,
/* LFun */ 0x00, 0x09, 0x12, 0x12, 0x00, 0x2D, 0x12, 0x3F
};
// END DO NOT EDIT
// DO NOT EDIT ...
const char xdata InitData[7] =
{
/* Regs */ 0xC0,0x80,0x00,0xED,0x06,0xE4,0x11
};
// END DO NOT EDIT
// TO DO: You may add additional code below.
void GpifInit( void )
{
BYTE i;
// Registers which require a synchronization delay, see section 15.14
// FIFORESET FIFOPINPOLAR
// INPKTEND OUTPKTEND
// EPxBCH:L REVCTL
// GPIFTCB3 GPIFTCB2
// GPIFTCB1 GPIFTCB0
// EPxFIFOPFH:L EPxAUTOINLENH:L
// EPxFIFOCFG EPxGPIFFLGSEL
// PINFLAGSxx EPxFIFOIRQ
// EPxFIFOIE GPIFIRQ
// GPIFIE GPIFADRH:L
// UDMACRCH:L EPxGPIFTRIG
// GPIFTRIG
// Note: The pre-REVE EPxGPIFTCH/L register are affected, as well...
// ...these have been replaced by GPIFTC[B3:B0] registers
// 8051 doesn't have access to waveform memories 'til
// the part is in GPIF mode.
IFCONFIG = 0xE6;
// IFCLKSRC=1 , FIFOs executes on internal clk source
// xMHz=1 , 48MHz internal clk rate
// IFCLKOE=1 , Drive IFCLK pin signal at 48MHz
// IFCLKPOL=1 , Do not invert IFCLK pin signal from internal clk
// ASYNC=0 , FIFOs/GPIF operated in sync. mode
// GSTATE=1 , Drive GPIF states out on PORTE[2:0], debug WF
// IFCFG[1:0]=10, FX2 in GPIF master mode
GPIFABORT = 0xFF; // abort any waveforms pending
// GPIFREADYCFG = InitData[ 0 ] | bmBIT5;
GPIFREADYCFG = 0xE0;
GPIFCTLCFG = InitData[ 1 ];
GPIFIDLECS = InitData[ 2 ];
GPIFIDLECTL = InitData[ 3 ];
GPIFWFSELECT = InitData[ 5 ];
GPIFREADYSTAT = InitData[ 6 ];
SYNCDELAY;
EP2GPIFFLGSEL = 0x01; // For EP2OUT, GPIF uses EF flag
SYNCDELAY;
// global flowstate register initializations
FLOWLOGIC = 0x36; // 0011 0110b - LFUNC[1:0] = 00 (A AND B), TERMA/B[2:0]=110 (FIFO Flag)
SYNCDELAY;
FLOWSTB = 0x04; // 0000 0100b - MSTB[2:0] = 100 (CTL4), not used as strobe
SYNCDELAY;
GPIFHOLDAMOUNT = 0x01; // hold data for one half clock (10ns) assuming 48MHz IFCLK
SYNCDELAY;
FLOWSTBEDGE = 0x03; // move data on both edges of clock
SYNCDELAY;
FLOWSTBHPERIOD = 0x02; // 20.83ns half period
SYNCDELAY;
// use dual autopointer feature...
AUTOPTRSETUP = 0x07; // inc both pointers,
// ...warning: this introduces pdata hole(s)
// ...at E67B (XAUTODAT1) and E67C (XAUTODAT2)
// source
AUTOPTR1H = MSB( &WaveData );
AUTOPTR1L = LSB( &WaveData );
// destination
AUTOPTRH2 = 0xE4;
AUTOPTRL2 = 0x00;
// transfer
for ( i = 0x00; i < 128; i++ )
{
EXTAUTODAT2 = EXTAUTODAT1;
}
// Configure GPIF Address pins, output initial value,
PORTCCFG = 0xFF; // [7:0] as alt. func. GPIFADR[7:0]
OEC = 0xFF; // and as outputs
PORTECFG |= 0x80; // [8] as alt. func. GPIFADR[8]
OEE |= 0x80; // and as output
// ...OR... tri-state GPIFADR[8:0] pins
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -