📄 function.c
字号:
#pragma NOIV
#include "testheader.h"
#include "testregs.h"
extern BOOL Rwuen;
extern BOOL GotSUD;
extern BOOL Sleep;
extern BOOL Selfpwr;
extern int ByteCount0;
extern BOOL InPrepare0;
BYTE Configuration;
BYTE AlternateSetting;
BYTE suspCount;
void TD_Init(void)
{
IN07VAL |= bmEP1 + bmEP2 + bmEP3 + bmEP4 + bmEP5 + bmEP6 + bmEP7;
OUT07VAL |= bmEP1 + bmEP2 + bmEP3 + bmEP4 + bmEP5+ bmEP6 + bmEP7;
OUT07IEN |= bmEP1 + bmEP2 + bmEP3 + bmEP4 + bmEP5 + bmEP6 + bmEP7;
IN07IEN |= bmEP1 + bmEP2 + bmEP3 + bmEP4 + bmEP5 + bmEP6 + bmEP7;
suspCount = 1;
Rwuen = TRUE;
InPrepare0=FALSE;
ByteCount0=0;
PORTCCFG = 0x0C;
OEC = 0xF2;
PORTBCFG = 0x00;
OEB = 0xFF;
OUTB =0x00;
PORTACFG = 0x20;
OEA = 0xDF;
OUTA =(PINSA)&0xEF;
OUTA =(PINSA)|0x40;
OUTA =(PINSA)&0x7F;
OUTC =(PINSC)|0x70;
OUTC =(PINSC)&0xFD;
OUTC =(PINSC)&0xFD;
OUTC =(PINSC)|0x02;
OUTC =(PINSC)|0x02;
}
void TD_Poll(void)
{
}
BOOL TD_Suspend(void)
{
return(TRUE);
}
BOOL TD_Resume(void)
{
return(TRUE);
}
BOOL DR_GetDescriptor(void)
{
return(TRUE);
}
BOOL DR_GetInterface(void)
{
IN0BUF[0] = AlternateSetting;
EZUSB_SET_EP_BYTES(IN0BUF_ID,1);
return(TRUE);
}
BOOL DR_SetInterface(void)
{
AlternateSetting = SETUPDAT[2];
return(TRUE);
}
BOOL DR_GetConfiguration(void)
{
IN0BUF[0] = Configuration;
EZUSB_SET_EP_BYTES(IN0BUF_ID,1);
return(TRUE);
}
BOOL DR_SetConfiguration(void)
{
Configuration = SETUPDAT[2];
return(TRUE);
}
BOOL DR_GetStatus(void)
{
return(TRUE);
}
BOOL DR_ClearFeature(void)
{
return(TRUE);
}
BOOL DR_SetFeature(void)
{
return(TRUE);
}
BOOL DR_VendorCmnd(void)
{
if (SETUPDAT[1] == 0xB0)
{
EZUSB_UNARM_EP(EPID(SETUPDAT[4]));
return(FALSE);
}
return(TRUE);
}
void ISR_Sudav(void) interrupt USB_VECT
{
GotSUD = TRUE;
EZUSB_IRQ_CLEAR();
USBIRQ = bmSUDAV;
}
void ISR_Sutok(void) interrupt USB_VECT
{
EPIO[OUT0BUF_ID].cntrl = 0;
EZUSB_IRQ_CLEAR();
USBIRQ = bmSUTOK;
}
void ISR_Sof(void) interrupt USB_VECT
{
EZUSB_IRQ_CLEAR();
USBIRQ = bmSOF;
}
void ISR_Ures(void) interrupt USB_VECT
{
EPIO[OUT1BUF_ID].bytes = 0;
EPIO[OUT2BUF_ID].bytes = 0;
EPIO[OUT3BUF_ID].bytes = 0;
EPIO[OUT4BUF_ID].bytes = 0;
EPIO[OUT5BUF_ID].bytes = 0;
EPIO[OUT6BUF_ID].bytes = 0;
EPIO[OUT7BUF_ID].bytes = 0;
EZUSB_IRQ_CLEAR();
USBIRQ = bmURES;
}
void ISR_Spare(void) interrupt USB_VECT
{
}
void ISR_Susp(void) interrupt USB_VECT
{
if (suspCount)
{
suspCount--;
}
else
{
Sleep = TRUE;
}
EZUSB_IRQ_CLEAR();
USBIRQ = bmSUSP;
}
void ISR_Ep0in(void) interrupt USB_VECT
{
}
void ISR_Ep0out(void) interrupt USB_VECT
{
}
void ISR_Ep1in(void) interrupt USB_VECT
{
}
void ISR_Ep1out(void) interrupt USB_VECT
{
}
void ISR_Ep2in(void) interrupt USB_VECT
{
int i;
if(InPrepare0==TRUE)
{
FASTXFR = 0x40 ;
AUTOPTRH = 0x7E ;
AUTOPTRL = 0x00 ;
for (i=0; i < 8; i++)
{
AUTODATA = ACC;
AUTODATA = ACC;
AUTODATA = ACC;
AUTODATA = ACC;
AUTODATA = ACC;
AUTODATA = ACC;
AUTODATA = ACC;
AUTODATA = ACC;
}
FASTXFR = 0x0;
ByteCount0=ByteCount0+64;
if(ByteCount0>=512)
{
InPrepare0=FALSE;
ByteCount0=0;
}
IN2BC=64;
}
EZUSB_IRQ_CLEAR();
IN07IRQ = bmEP2;
}
void ISR_Ep2out(void) interrupt USB_VECT
{
}
void ISR_Ep3in(void) interrupt USB_VECT
{
}
void ISR_Ep3out(void) interrupt USB_VECT
{
}
void ISR_Ep4in(void) interrupt USB_VECT
{
}
void ISR_Ep4out(void) interrupt USB_VECT
{
}
void ISR_Ep5in(void) interrupt USB_VECT
{
}
void ISR_Ep5out(void) interrupt USB_VECT
{
if(OUT5BUF[0]==0x3C)
{
OUTB =OUT5BUF[1];
}
OUT5BC = 0;
EZUSB_IRQ_CLEAR();
OUT07IRQ = bmEP5;
}
void ISR_Ep6in(void) interrupt USB_VECT
{
}
void ISR_Ep6out(void) interrupt USB_VECT
{
if(OUT6BUF[0]==0x2B)
{
EX0 = 0;
OUTC =(PINSC)&0x7F;
OUTA =(PINSA)&0x7F;
}
OUT6BC = 0;
EZUSB_IRQ_CLEAR();
OUT07IRQ = bmEP6;
}
void ISR_Ep7in(void) interrupt USB_VECT
{
}
void ISR_Ep7out(void) interrupt USB_VECT
{
if(OUT7BUF[0]==0x1A)
{
OUTC =(PINSC)&0xFD;
OUTC =(PINSC)&0xFD;
OUTC =(PINSC)|0x02;
OUTC =(PINSC)|0x02;
OUTC =(PINSC)|0x70;
OUTC =(PINSC)|0x80;
EX0 = 1;
OUTA =(PINSA)|0x80;
}
OUT7BC = 0;
EZUSB_IRQ_CLEAR();
OUT07IRQ = bmEP7;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -