📄 iso.c
字号:
/*
//*************************************************************************
//
// P H I L I P S P R O P R I E T A R Y
//
// COPYRIGHT (c) 2001 BY PHILIPS SINGAPORE.
// -- ALL RIGHTS RESERVED --
//
// File Name: ISO.C
// Author: Jiang Qian
// Created: 12 Apr 2001
// Modified:
// Revision: 1.0
//
//*************************************************************************
*/
#include <stdio.h>
#include <string.h>
#include <bios.h>
#include <dos.h>
#include "BasicTyp.h"
#include "common.h"
#include "mainloop.h"
#include "usb200.h"
#include "Hal4sys.h"
#include "ISP1581.h"
#include "chap_9.h"
#include "verify.h"
#include "iso.h"
extern ISP1581FLAGS bISP1581flags;
extern CONTROL_XFER ControlData;
extern IO_REQUEST idata ioRequest;
extern unsigned long isoBuffer;
extern GLOBE_VARIABLE globe_variable;
void EnableIsoMode(void)
{
bISP1581flags.bits.ISO_CONFIG = 1;
}
void ISO_CONFIG(void)
{
unsigned short far *fp;
unsigned short seg, off;
unsigned char IsoMode = 0; //ISO_IN:01|ISO_OUT:02;
unsigned short length;
if( ControlData.DeviceRequest.wLength == 0)
{
IsoMode &= ~ControlData.DeviceRequest.wIndex;
IsoMode |= ControlData.DeviceRequest.wValue;
#ifdef debug
cprintf("IsoMode %x\r\n",IsoMode );
#endif
if(IsoMode&ISO_IN)
{
// ISO in loop mode
RaiseIRQL();
globe_variable.isoINCount = 0;
globe_variable.isoINSize = 256;
seg = (isoBuffer + globe_variable.isoINCount)>>4;
off = (isoBuffer + globe_variable.isoINCount)&0xf;
fp = MK_FP(seg, off);
length = globe_variable.isoINSize - globe_variable.isoINCount;
if(length <= 256)
{
ISP1581_SetEPIndex(EPINDEX4EP07OUT);// work around for es4, write in endpoint corrupts out endpoint data
ISP1581_WriteISOEndpoint(EPINDEX4EP03IN, fp, length);
globe_variable.isoINCount += length;
bISP1581flags.bits.ISO_state = ISO_IDLE;
}
else
{
ISP1581_SetEPIndex(EPINDEX4EP07OUT);// work around for es4, write in endpoint corrupts out endpoint data
ISP1581_WriteISOEndpoint(EPINDEX4EP03IN, fp, 256);
globe_variable.isoINCount += 256;
bISP1581flags.bits.ISO_state = ISO_IN;
}
#ifdef debug
cprintf(" IN \n");
#else
cprintf(" IN ");
#endif
LowerIRQL();
}
else
{
if(IsoMode & ISO_OUT)
{
//ISO out mode
RaiseIRQL();
bISP1581flags.bits.ISO_state = ISO_OUT;
//globe_variable.isoINSize = 0;
globe_variable.isoOUTSize = 0;
globe_variable.isoOUTCount = 0;
globe_variable.isoINCount = 0;
LowerIRQL();
#ifdef debug
cprintf(" Out \n");
#else
cprintf(" Out ");
#endif
}
if(IsoMode&ISO_LOOP)
{
RaiseIRQL();
bISP1581flags.bits.ISO_state = ISO_LOOP;
globe_variable.isoINSize = 0;
globe_variable.isoOUTCount = 0;
globe_variable.isoINCount = 0;
LowerIRQL();
#ifdef debug
cprintf(" LOOP \n");
#endif
}
}
// SETUP_ISOInterrupt();
Chap9_ControlWriteHandshake();
// bISP1581flags.bits.DCP_state = USBFSM4DCP_CONTROLWRITEHANDSHAKE;
#ifdef debug
// cprintf("^_^%hxNODATAPHASE", bISP1581flags.bits.DCP_state);
#endif
}
else
{
Chap9_StallEP0();
}
}
void Wait4Ns( unsigned long timeNs)
{
unsigned long i;
for(i=0; i<timeNs; i++)
;
}
/*
USHORT ReadISOEndpoint(UCHAR bEPIndex, USHORT ISOBuffer[512], USHORT len)
{
USHORT i, j;
return j;
}
USHORT WriteISOEndpoint(UCHAR bEPIndex, USHORT ISOBuffer[512], USHORT len)
{
USHORT i;
// static UCHAR j;
if(bISP1581flags.bits.At_IRQL1 == 0)
RaiseIRQL();
#ifdef debug
// cprintf("length = %x \n %x \n ", (UCHAR)len, (UCHAR)(len>>8));
// Select Endpoint
cprintf("-----\n");
#endif
if(bISP1581flags.bits.At_IRQL1 == 0)
LowerIRQL();
return i;
}
*/
void SETUP_ISOInterrupt(void)
{
unsigned int c;
c = ISP1581_GetIntEnableHigh();
ISP1581_SetIntEnableHigh(c|int_ep3rx|int_ep3tx);
}
void CLEAR_ISOInterrupt(void)
{
unsigned int c;
c = ISP1581_GetIntEnableHigh();
ISP1581_SetIntEnableHigh(c&~(int_ep3rx|int_ep3tx));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -