Beispiel #1
0
void Chap9_BurstTransmitEP0(PUCHAR pData, USHORT len)
{
    ControlData.wCount = 0;
    if(ControlData.wLength > len)
        ControlData.wLength = len;

    ControlData.Addr.pData = pData;

        if( ControlData.wLength >= EP0_PACKET_SIZE)
        {
            Hal4D13_WriteEndpoint(EPINDEX4EP0_CONTROL_IN, pData, EP0_PACKET_SIZE);

            RaiseIRQL();
            if(!ControlData.Abort)
            {
                ControlData.wCount += EP0_PACKET_SIZE;
                bD13flags.bits.DCP_state = USBFSM4DCP_DATAIN;

            }
            LowerIRQL();
        }
        else
        {
            Hal4D13_WriteEndpoint(EPINDEX4EP0_CONTROL_IN, pData, ControlData.wLength);

            RaiseIRQL();
            if(!ControlData.Abort)
            {
                ControlData.wCount += ControlData.wLength;
                bD13flags.bits.DCP_state = USBFSM4DCP_HANDSHAKE;

            }
            LowerIRQL();
        }
}
Beispiel #2
0
USHORT Hal4D13_WriteISOEndpoint(UCHAR bEPIndex, USHORT ISOBuffer[512], USHORT len)
{
	USHORT i;

	if(bD13flags.bits.At_IRQL1 == 0)
		RaiseIRQL();

	//IOWR(ISP1362_BASE,D13_COMMAND_PORT, D13CMD_EP_WR_FIFO + bEPIndex);
    USB_DC_CMD_WRITE(D13CMD_EP_WR_FIFO + bEPIndex);

	//IOWR(ISP1362_BASE,D13_DATA_PORT, 512);
    USB_DC_DATA_WRITE(512);

	/* Write Buffer */

	for(i=0; i<len; i++)
	{
		//IOWR(ISP1362_BASE,D13_DATA_PORT, ISOBuffer[i]);
        USB_DC_DATA_WRITE(ISOBuffer[i]);
	}



	if(bD13flags.bits.At_IRQL1 == 0)
		LowerIRQL();

	return i;
}
Beispiel #3
0
void Chap9_StallEP0InControlRead(void)
{
    Hal4D13_StallEP0InControlRead();
    RaiseIRQL();
    if(!ControlData.Abort)
    {
        bD13flags.bits.DCP_state = USBFSM4DCP_STALL;

    }
    LowerIRQL();
}
Beispiel #4
0
void read_write_register(void)
{
	unsigned char i;

	if(ControlData.DeviceRequest.bmRequestType & (unsigned char)USB_ENDPOINT_DIRECTION_MASK)
	{
		if(bD13flags.bits.verbose)
		{
			printf("Read Registers: Offset = 0x%x, Length = 0x%x, Index = 0x%x.\n",
				ControlData.DeviceRequest.wValue,
				ControlData.DeviceRequest.wLength,
				ControlData.DeviceRequest.wIndex);
		}

		if(ControlData.DeviceRequest.wIndex == GET_FIRMWARE_VERSION &&
			ControlData.DeviceRequest.wValue == 0 &&
			ControlData.DeviceRequest.wLength == 1)
			{
				get_firmware_version();
			}
		else
		{
			Chap9_StallEP0();
			printf("stall: get firmware version\n");
		}

	}
	else
	{
		if(bD13flags.bits.verbose)
		{

			printf("Write Registers: Offset = 0x%x, Length = 0x%x, Index = 0x%x.\n",
				ControlData.DeviceRequest.wValue,
				ControlData.DeviceRequest.wLength,
				ControlData.DeviceRequest.wIndex);

			printf("Data: ");
			for(i = 0; i < ControlData.DeviceRequest.wLength; i ++)
				printf("0x%x, ", *((ControlData.dataBuffer)+i));
			printf("\n");
		}

		if(ControlData.DeviceRequest.wIndex == SETUP_DMA_REQUEST &&
			ControlData.DeviceRequest.wValue == 0 &&
			ControlData.DeviceRequest.wLength == 6)
			{
				RaiseIRQL();
				setup_dma_request();
				LowerIRQL();
			}

	}
}
Beispiel #5
0
void D13Bus_SingleTransmitEP0(UCHAR * buf, UCHAR len)
{
	Hal4D13_SingleTransmitEP0(buf, len);

	RaiseIRQL();
	if(!ControlData.Abort)
    {
		ControlData.wLength = ControlData.wCount = len;
        bD13flags.bits.DCP_state = USBFSM4DCP_HANDSHAKE;
	}
	LowerIRQL();

}
void Chap9_BurstTransmitEP0(PUCHAR pData, USHORT len)
{
	ControlData.wCount = 0;
    //printf("wCount = %d \n",ControlData.wCount);
	if(ControlData.wLength > len)
		ControlData.wLength = len;

	printf("wLength = %d \n",ControlData.wLength);	
	ControlData.Addr.pData = pData;

		if( ControlData.wLength >= EP0_PACKET_SIZE)
		{
			Hal4D13_WriteEndpoint(EPINDEX4EP0_CONTROL_IN, pData, EP0_PACKET_SIZE);

			RaiseIRQL();
			if(!ControlData.Abort)
			{
				ControlData.wCount += EP0_PACKET_SIZE;
				bD13flags.bits.DCP_state = USBFSM4DCP_DATAIN;

			}
			LowerIRQL();
		}
		else
		{
			USHORT i = Hal4D13_WriteEndpoint(EPINDEX4EP0_CONTROL_IN, pData, ControlData.wLength);
            //printf("Descriptor size after writing to Ep0 is %d \n ",i);

			RaiseIRQL();
			if(!ControlData.Abort)
			{
				ControlData.wCount += ControlData.wLength;
				bD13flags.bits.DCP_state = USBFSM4DCP_HANDSHAKE;

			}
			LowerIRQL();
		}
}
Beispiel #7
0
void Chap9_StallEP0(void)
{
    UCHAR dir;
    dir = ControlData.DeviceRequest.bmRequestType & USB_REQUEST_DIR_MASK;
    if(dir)
    {
        Hal4D13_StallEP0InControlRead();
    }
    else
    {
        Hal4D13_StallEP0InControlWrite();
    }

    RaiseIRQL();
    if(!ControlData.Abort)
    {
        bD13flags.bits.DCP_state = USBFSM4DCP_STALL;

    }
    LowerIRQL();
}
Beispiel #8
0
void setup_dma_request()
{
	memcpy((unsigned char *)&ioRequest + ControlData.DeviceRequest.wValue,
		ControlData.dataBuffer,
		ControlData.DeviceRequest.wLength);

	ioRequest.uSize = SWAP(ioRequest.uSize);
	ioRequest.uAddressL = SWAP(ioRequest.uAddressL);
	printf("Setup Data: addL, addH, uSize =%x, %x, %x \n", \
				ioRequest.uAddressL, ioRequest.bAddressH, ioRequest.uSize);

	if(ioRequest.uSize > DMA_BUFFER_SIZE) // Unaccepted request
	{
		Chap9_StallEP0();
		printf("stall: ioRequest.uSize > DMA_BUFFER_SIZE.\n");
	}
	else
	{
		RaiseIRQL();
		bD13flags.bits.setup_dma = 1;
		LowerIRQL();
	}
}
Beispiel #9
0
void EnableIsoMode()
{
	IsoMode = 0;
	if( ControlData.DeviceRequest.wLength == 0)
	{
		IsoMode &= ~ControlData.DeviceRequest.wIndex;
		IsoMode |= ControlData.DeviceRequest.wValue;

		printf("IsoMode %x\n",IsoMode );

		if(IsoMode&ISO_LOOP)
		{

		   RaiseIRQL();
		   bD13flags.bits.ISO_state = ISO_LOOP;
		   LowerIRQL();

		   IsoDisable =0;
		   IsoInPattern = 0;
		   IsoInPktLen = ISO_FIFOSIZE_512;
		   IsoOutPattern = 0;
		   IsoOutPktLen = ISO_FIFOSIZE_512;

		}
		else
		{

			 if(IsoMode&ISO_OUT)
			 {

			   RaiseIRQL();
			   bD13flags.bits.ISO_state = ISO_OUT;
			   LowerIRQL();

			   IsoDisable =0;
			   IsoOutPattern = 0;
			   IsoOutPktLen = ISO_FIFOSIZE_512;
			   printf("Iso-Out Pattern %x, PktLen %u bytes\n",IsoInPattern,IsoOutPktLen);

			 }
			 if(IsoMode&ISO_IN)
			 {
				bD13flags.bits.ISO_state = ISO_IN;

			   IsoDisable =0;
			   IsoInPattern = 0;
			   IsoInPktLen = ISO_FIFOSIZE_512;

				//IOWR(ISP1362_BASE,D13_COMMAND_PORT, D13CMD_EP_VALID_BUF+EPINDEX4EP06);
                USB_DC_CMD_WRITE(D13CMD_EP_VALID_BUF+EPINDEX4EP06);
				printf("Iso-IN  Pattern %x, PktLen %u bytes\n",IsoInPattern,IsoInPktLen);
			 }

		}

		Chap9_SingleTransmitEP0(0, 0);
	}
	else
	{
		Chap9_StallEP0();
	}
}
Beispiel #10
0
void Chap9_SetAddress(void)
{

    UCHAR   j;

    {
        RaiseIRQL();
        disable();
        if(!ControlData.Abort)
        {
            if(bUSBCheck_Device_State.State_bits.DEVICE_DEFAULT_STATE)
            {
                if((ControlData.DeviceRequest.wValue & DEVICE_ADDRESS_MASK) != 0 )
                {
                    bUSBCheck_Device_State.State_bits.DEVICE_DEFAULT_STATE = 0;
                    Hal4D13_SetAddressEnable((UCHAR)(ControlData.DeviceRequest.wValue &
                                            DEVICE_ADDRESS_MASK), 1);
                    bUSBCheck_Device_State.State_bits.DEVICE_ADDRESS_STATE = 1;
                    Chap9_SingleTransmitEP0(0, 0);

                }

                else
                    bUSBCheck_Device_State.State_bits.DEVICE_DEFAULT_STATE = 1;
            }

            else if(bUSBCheck_Device_State.State_bits.DEVICE_ADDRESS_STATE)
            {
                if((ControlData.DeviceRequest.wValue & DEVICE_ADDRESS_MASK) == 0 )
                {
                    Hal4D13_SetAddressEnable((UCHAR)(ControlData.DeviceRequest.wValue &
                                            DEVICE_ADDRESS_MASK), 1);
                    bUSBCheck_Device_State.State_bits.DEVICE_DEFAULT_STATE = 1;
                    bUSBCheck_Device_State.State_bits.DEVICE_ADDRESS_STATE = 0;
                    Chap9_SingleTransmitEP0(0, 0);

                }

                else
                {
                    bUSBCheck_Device_State.State_bits.DEVICE_DEFAULT_STATE = 0;
                    Hal4D13_SetAddressEnable((UCHAR)(ControlData.DeviceRequest.wValue &
                                            DEVICE_ADDRESS_MASK), 1);
                    bUSBCheck_Device_State.State_bits.DEVICE_ADDRESS_STATE = 1;
                    Chap9_SingleTransmitEP0(0, 0);

                }

            }

            else
            {

                bUSBCheck_Device_State.State_bits.DEVICE_CONFIGURATION_STATE = 0;
                bUSBCheck_Device_State.State_bits.DEVICE_ADDRESS_STATE = 0;
                bUSBCheck_Device_State.State_bits.DEVICE_DEFAULT_STATE = 1;
                j = DEV_BEHAVIOUR_NOT_SPECIFIED;
                Chap9_SingleTransmitEP0(&j, 0);
            }

        }
        LowerIRQL();
        enable();

    }
    printf("Addr %x\n",Hal4D13_GetAddress());
}