⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usb.c

📁 ISP1583 Mass Storgae Firmware
💻 C
📖 第 1 页 / 共 5 页
字号:
                                                                                  
   Descriptor_Ptr = &Standard_String_ID[0];		//set pointer to interface descriptor

   D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;

	if((UC) USB_Device_Request.wLength < 4)
		{
			D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = (UC) USB_Device_Request.wLength;
			D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = 0;
		}
	else
		{
			D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = 4;
			D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = 0;
		}
		

   //send string ID
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO

   D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.DSEN = 1;

   //check for status stage
   while(!USB_Int_Flag.BITS.EP0TX)
   {
      if(USB_Int_Flag.BITS.SUSP ||
         Kernel_Flag.BITS.Bus_Reset)
         return;
   }
                                                
   USB_Int_Flag.BITS.EP0TX = 0;

	D14_Cntrl_Reg.D14_ENDPT_INDEX = 0;
	D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STATUS = 1;
                                                
}   

//***********************************************************************
//*										    							               *
//*	Routine 	:                                                		   *
//*	Input		: None                   								         *     
//*	Output	: None                                   					   *
//*	Function	:                                            			   *
//*																		               *
//***********************************************************************

void Send_Manufacturer_String(void)
{
                                                
   Descriptor_Ptr = &Standard_Manufacturer_String[0];		//set pointer to interface descriptor

   D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;

   D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = 28;
	D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = 0;
	

   //send manufacturer string
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO

   D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.DSEN = 1;


   //Check for IN Token ACK
   while(!USB_Int_Flag.BITS.EP0TX)
   {
      if(USB_Int_Flag.BITS.SUSP ||
         Kernel_Flag.BITS.Bus_Reset)
         return;
   }
                                                
   USB_Int_Flag.BITS.EP0TX = 0;

	D14_Cntrl_Reg.D14_ENDPT_INDEX = 0;
	D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STATUS = 1;
                                                
}


//***********************************************************************
//*										    							               *
//*	Routine 	:                                                		   *
//*	Input		: None                   								         *     
//*	Output	: None                                   					   *
//*	Function	:                                            			   *
//*																		               *
//***********************************************************************

void Send_Product_String(void)
{

   Descriptor_Ptr = &Standard_Product_String[0];		//set pointer to interface descriptor

   D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;

   D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = 48;
	D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = 0;
	
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;	//fill up FIFO
	Descriptor_Ptr++;
   D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;	//fill up FIFO

   D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.DSEN = 1;

   //check for status stage
   while(!USB_Int_Flag.BITS.EP0TX)
   {
      if(USB_Int_Flag.BITS.SUSP ||
         Kernel_Flag.BITS.Bus_Reset)
         return;
   }
                                                
   USB_Int_Flag.BITS.EP0TX = 0;
   
   D14_Cntrl_Reg.D14_ENDPT_INDEX = 0;
	D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STATUS = 1;
                                                
}


//***********************************************************************
//*										    							               *
//*	Routine 	:                                                		   *
//*	Input		: None                   								         *     
//*	Output	: None                                   					   *
//*	Function	:                                            			   *
//*																		               *
//***********************************************************************

void Send_Endpoint_Descriptor(void)
{

   if((USB_Device_Request.wValue & 0x00ff) > 0x0001)
   {
	   D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STALL = 1;
                                                   
      while(!USB_Int_Flag.BITS.EP0SETUP)
      {
         if(USB_Int_Flag.BITS.SUSP ||
            Kernel_Flag.BITS.Bus_Reset)
            return;
   
      }
      
      USB_Int_Flag.BITS.EP0TX = 0;
   }
   else
	{
	
      Descriptor_Ptr = &Bulk_Out_Descriptor[0]; //set pointer to Bulk Out endpoint descriptor

      D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;

      D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = 14;
		D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = 0;

      D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
		Descriptor_Ptr++;
      D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;
		Descriptor_Ptr++;
      D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
		Descriptor_Ptr++;
      D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;
		Descriptor_Ptr++;
      D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
		Descriptor_Ptr++;
      D14_Cntrl_Reg.D14_DATA_PORT_MSB = *Descriptor_Ptr;
		Descriptor_Ptr++;
      D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;

      Descriptor_Ptr = &Bulk_In_Descriptor[0]; //set pointer to Bulk In endpoint descriptor

      D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -