Example #1
0
/*******************************************************************************
* Function Name  : Virtual_Com_Port_Reset
* Description    : Virtual_Com_Port Mouse reset routine
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
void Virtual_Com_Port_Reset(void)
{
  /* Set Virtual_Com_Port DEVICE as not configured */
  pInformation->Current_Configuration = 0;

  /* Current Feature initialization */
  pInformation->Current_Feature = Virtual_Com_Port_ConfigDescriptor[7];

  /* Set Virtual_Com_Port DEVICE with the default Interface*/
  pInformation->Current_Interface = 0;

  SetBTABLE(BTABLE_ADDRESS);

  /* Initialize Endpoint 0 */
  SetEPType(ENDP0, EP_CONTROL);
  SetEPTxStatus(ENDP0, EP_TX_STALL);
  SetEPRxAddr(ENDP0, ENDP0_RXADDR);
  SetEPTxAddr(ENDP0, ENDP0_TXADDR);
  Clear_Status_Out(ENDP0);
  SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
  SetEPRxValid(ENDP0);

  /* Initialize Endpoint 1 */
  SetEPType(ENDP1, EP_BULK);
  SetEPTxAddr(ENDP1, ENDP1_TXADDR);
  SetEPTxStatus(ENDP1, EP_TX_NAK);
  SetEPRxStatus(ENDP1, EP_RX_DIS);

  /* Initialize Endpoint 2 */
  SetEPType(ENDP2, EP_INTERRUPT);
  SetEPTxAddr(ENDP2, ENDP2_TXADDR);
  SetEPRxStatus(ENDP2, EP_RX_DIS);
  SetEPTxStatus(ENDP2, EP_TX_NAK);

  /* Initialize Endpoint 3 */
  SetEPType(ENDP3, EP_BULK);
  SetEPRxAddr(ENDP3, ENDP3_RXADDR);
  SetEPRxCount(ENDP3, VIRTUAL_COM_PORT_DATA_SIZE);
  SetEPRxStatus(ENDP3, EP_RX_VALID);
  SetEPTxStatus(ENDP3, EP_TX_DIS);

  /* Set this device to response on default address */
  SetDeviceAddress(0);
  
  bDeviceState = ATTACHED;
}
Example #2
0
/*******************************************************************************
* Function Name  : MASS_Reset
* Description    : Mass Storage reset routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
void MASS_Reset()
{
  /* Set the device as not configured */
  Device_Info.Current_Configuration = 0;

  /* Current Feature initialization */
  pInformation->Current_Feature = MASS_ConfigDescriptor[7];

  SetBTABLE(BTABLE_ADDRESS);

  /* Initialize Endpoint 0 */
  SetEPType(ENDP0, EP_CONTROL);
  SetEPTxStatus(ENDP0, EP_TX_NAK);
  SetEPRxAddr(ENDP0, ENDP0_RXADDR);
  SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
  SetEPTxAddr(ENDP0, ENDP0_TXADDR);
  Clear_Status_Out(ENDP0);
  SetEPRxValid(ENDP0);

  /* Initialize Endpoint 1 */
  SetEPType(ENDP1, EP_BULK);
  SetEPTxAddr(ENDP1, ENDP1_TXADDR);
  SetEPTxStatus(ENDP1, EP_TX_NAK);
  SetEPRxStatus(ENDP1, EP_RX_DIS);

  /* Initialize Endpoint 2 */
  SetEPType(ENDP2, EP_BULK);
  SetEPRxAddr(ENDP2, ENDP2_RXADDR);
  SetEPRxCount(ENDP2, Device_Property.MaxPacketSize);
  SetEPRxStatus(ENDP2, EP_RX_VALID);
  SetEPTxStatus(ENDP2, EP_TX_DIS);


  SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
  SetEPRxValid(ENDP0);

  /* Set the device to response on default address */
  SetDeviceAddress(0);

  bDeviceState = ATTACHED;

  CBW.dSignature = BOT_CBW_SIGNATURE;
  Bot_State = BOT_IDLE;
  USB_NotConfigured_LED();
}
/*******************************************************************************
* Function Name  : PIOS_HID_Reset.
* Description    : Custom HID reset routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
void PIOS_HID_Reset(void)
{
  /* Set Joystick_DEVICE as not configured */
  pInformation->Current_Configuration = 0;
  pInformation->Current_Interface = 0;/*the default Interface*/
  
  /* Current Feature initialization */
  pInformation->Current_Feature = PIOS_HID_ConfigDescriptor[7];
  
#ifdef STM32F10X_CL   
  /* EP0 is already configured in DFU_Init() by USB_SIL_Init() function */
  
  /* Init EP1 IN as Interrupt endpoint */
  OTG_DEV_EP_Init(EP1_IN, OTG_DEV_EP_TYPE_INT, 2);
  
  /* Init EP1 OUT as Interrupt endpoint */
  OTG_DEV_EP_Init(EP1_OUT, OTG_DEV_EP_TYPE_INT, 2);
#else 
  SetBTABLE(BTABLE_ADDRESS);

  /* Initialize Endpoint 0 */
  SetEPType(ENDP0, EP_CONTROL);
  SetEPTxStatus(ENDP0, EP_TX_STALL);
  SetEPRxAddr(ENDP0, ENDP0_RXADDR);
  SetEPTxAddr(ENDP0, ENDP0_TXADDR);
  Clear_Status_Out(ENDP0);
  SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
  SetEPRxValid(ENDP0);

  /* Initialize Endpoint 1 */
  SetEPType(ENDP1, EP_INTERRUPT);
  SetEPTxAddr(ENDP1, ENDP1_TXADDR);
  SetEPRxAddr(ENDP1, ENDP1_RXADDR);
  SetEPTxCount(ENDP1, PIOS_USB_HID_DATA_LENGTH+2);  /* add two for indicating report id and valid data length */
  SetEPRxCount(ENDP1, PIOS_USB_HID_DATA_LENGTH+2);
  SetEPRxStatus(ENDP1, EP_RX_VALID);
  SetEPTxStatus(ENDP1, EP_TX_NAK);

  /* Set this device to response on default address */
  SetDeviceAddress(0);
#endif /* STM32F10X_CL */

  bDeviceState = ATTACHED;
}
Example #4
0
void monkey_ep_reset(void) {
  int i;

  /* Set Joystick_DEVICE as not configured */
  pInformation->Current_Configuration = 0;
  pInformation->Current_Interface = 0;/*the default Interface*/

  /* Current Feature initialization */
  pInformation->Current_Feature = config1_descriptor[7];

  for(i=0; i<8; ++i) {
    if(ep_conf_list[i].direct==0) continue;
    
		switch(ep_conf_list[i].attr) {
			case 0x00:
        SetEPType(i, EP_BULK);
        ClearEPDoubleBuff(i);
        break;
			case 0x01:
        SetEPType(i, EP_CONTROL);
        Clear_Status_Out(i);
        break;
			case 0x02:
        SetEPType(i, EP_ISOCHRONOUS);
        break;
			case 0x03:
        SetEPType(i, EP_INTERRUPT);
        break;
		}

    if(ep_conf_list[i].direct & EP_IN) {
      SetEPTxStatus(i, ep_conf_list[i].tx_status);
      SetEPTxAddr(i, ep_conf_list[i].tx_addr);
      SetEPTxCount(i, ep_conf_list[i].tx_max);
    }
    if(ep_conf_list[i].direct & EP_OUT) {
      SetEPRxAddr(i, ep_conf_list[i].rx_addr);
      SetEPRxCount(i, ep_conf_list[i].rx_max);
      SetEPRxStatus(i, ep_conf_list[i].rx_status);
    }
	}
}
Example #5
0
/*******************************************************************************
* Function Name  : OTPWriter_Reset.
* Description    : OTPWriter Mouse reset routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
void OTPWriter_Reset(void)
{
  /* Set OTPWriter_DEVICE as not configured */
  pInformation->Current_Configuration = 0;
  pInformation->Current_Interface = 0;/*the default Interface*/

  /* Current Feature initialization */
  pInformation->Current_Feature = OTPWriter_ConfigDescriptor[7];

  SetBTABLE(BTABLE_ADDRESS);

  /* Initialize Endpoint 0 */
  SetEPType(ENDP0, EP_CONTROL);
  SetEPTxStatus(ENDP0, EP_TX_STALL);
  SetEPRxAddr(ENDP0, ENDP0_RXADDR);
  SetEPTxAddr(ENDP0, ENDP0_TXADDR);
  Clear_Status_Out(ENDP0);
  SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
  SetEPRxValid(ENDP0);

  /* Initialize Endpoint 1 */
  SetEPType(ENDP1, EP_INTERRUPT);
  SetEPRxAddr(ENDP1, ENDP1_RXADDR);
  SetEPRxCount(ENDP1, ReceiveLength);
  SetEPRxStatus(ENDP1, EP_RX_VALID);
  //SetEPTxStatus(ENDP1, EP_TX_DIS);

  /* Initialize Endpoint 2 */
  SetEPType(ENDP2, EP_INTERRUPT);
  SetEPTxAddr(ENDP2, ENDP2_TXADDR);
  SetEPTxCount(ENDP2, SendLength);
  // SetEPTxStatus(ENDP2, EP_TX_DIS);
  SetEPTxStatus(ENDP2, EP_TX_NAK);

  bDeviceState = ATTACHED;

  /* Set this device to response on default address */
  SetDeviceAddress(0);
}
Example #6
0
/*******************************************************************************
* Function Name  : Microphone_Reset.
* Description    : Microphone reset routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
void Microphone_Reset()
{
  /* Set Microphone device as not configured state */
  pInformation->Current_Configuration = 0;

  /* Current Feature initialization */
  pInformation->Current_Feature = Microphone_ConfigDescriptor[7];

  SetBTABLE(BTABLE_ADDRESS);

  /* Initialize Endpoint 0 */
  SetEPType(ENDP0, EP_CONTROL);
  SetEPTxStatus(ENDP0, EP_TX_NAK);
  SetEPRxAddr(ENDP0, ENDP0_RXADDR);
  SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
  SetEPTxAddr(ENDP0, ENDP0_TXADDR);
  Clear_Status_Out(ENDP0);
  SetEPRxValid(ENDP0);

  /* Initialize Endpoint 1 */
  SetEPType(ENDP1, EP_ISOCHRONOUS);
  SetEPDblBuffAddr(ENDP1, ENDP1_BUF0Addr, ENDP1_BUF1Addr);
  //SetEPDblBuffCount(ENDP1, EP_DBUF_IN, 0x40);
  SetEPDblBuffCount(ENDP1, EP_DBUF_IN, 0x60);
  ClearDTOG_RX(ENDP1);
  ClearDTOG_TX(ENDP1);
  ToggleDTOG_TX(ENDP1);
  SetEPRxStatus(ENDP1, EP_RX_DIS);
  SetEPTxStatus(ENDP1, EP_TX_VALID);

  SetEPRxValid(ENDP0);
  /* Set this device to response on default address */
  SetDeviceAddress(0);

  bDeviceState = ATTACHED;

  //In_Data_Offset = 0;
  //Out_Data_Offset = 0;
}
Example #7
0
/*******************************************************************************
    Function Name  : Speaker_Reset.
    Description    : Speaker reset routine.
    Input          : None.
    Output         : None.
    Return         : None.
*******************************************************************************/
void Speaker_Reset() {
	// Set Speaker device as not configured state
	pInformation->Current_Configuration = 0;

	// Current Feature initialization
	pInformation->Current_Feature = Speaker_ConfigDescriptor[7];

//	*BTABLE = BTABLE_ADDRESS & 0xFFF8;
	*BTABLE = BTABLE_ADDRESS; // BTABLE_ADDRESS = 0

	// Initialize Endpoint 0
	SetEPType(ENDP0,EP_CONTROL);
	SetEPTxStatus(ENDP0,EP_TX_NAK);
	SetEPRxAddr(ENDP0,ENDP0_RXADDR);
	SetEPRxCount(ENDP0,Device_Property.MaxPacketSize);
	SetEPTxAddr(ENDP0,ENDP0_TXADDR);
	Clear_Status_Out(ENDP0);
	SetEPRxValid(ENDP0);

	// Initialize Endpoint 1
	SetEPType(ENDP1,EP_ISOCHRONOUS);
	SetEPDblBuffAddr(ENDP1,ENDP1_BUF0Addr,ENDP1_BUF1Addr);
	SetEPDblBuffCount(ENDP1,EP_DBUF_OUT,0x40);
	ClearDTOG_RX(ENDP1);
	ClearDTOG_TX(ENDP1);
	ToggleDTOG_TX(ENDP1);
	SetEPRxStatus(ENDP1,EP_RX_VALID);
	SetEPTxStatus(ENDP1,EP_TX_DIS);
	SetEPRxValid(ENDP0);

	// Set this device to response on default address
	SetDeviceAddress(0);

	bDeviceState = ATTACHED;

	In_Data_Offset  = 0;
	Out_Data_Offset = 0;
}
Example #8
0
/*******************************************************************************
* Function Name  : CustomHID_Reset.
* Description    : Custom HID reset routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
void CustomHID_Reset(void)
{
  /* Set Joystick_DEVICE as not configured */
  pInformation->Current_Configuration = 0;
  pInformation->Current_Interface = 0;/*the default Interface*/
  
  /* Current Feature initialization */
  pInformation->Current_Feature = CustomHID_ConfigDescriptor[7];
  
  *(volatile unsigned *)(0x40005C50L)=(0x00&0xFFF8);//设置USB分组缓冲区描述表起始地址:0

  /* Initialize Endpoint 0 */
  //设置EP0控制端点	 ENDP0   ((u8)0)   EP_CONTROL     (0x0200)
  *(((volatile unsigned *)(0x40005C00L)) + ENDP0)=((_GetENDPOINT(ENDP0) & 0x898f) | EP_CONTROL);
  SetEPTxStatus(ENDP0, EP_TX_STALL);	  //设置EP0端点发送延迟
  SetEPRxAddr(ENDP0, ENDP0_RXADDR);		  //设置EP0的接受地址  ENDP0_RXADDR        (0x18)
  SetEPTxAddr(ENDP0, ENDP0_TXADDR);		  //设置EP0的发送地址  ENDP0_TXADDR        (0x58)
  _ClearEP_KIND(ENDP0);					  //设置端点EP0的类型DBL_BUF 双缓冲端点
  SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);	//设置EP0的计数器的值
  _SetEPRxStatus(ENDP0, EP_RX_VALID);					  //设置端点接受有效 EP_RX_VALID=0x3000

  /* Initialize Endpoint 1 */
     SetEPType(ENDP1, EP_INTERRUPT);
     SetEPRxAddr(ENDP1, ENDP1_RXADDR);	//ADDR内部寄存器被用作当前缓冲区的指针 ENDP1_RXADDR=(0x98)
     SetEPRxCount(ENDP1, 22);			//COUNT寄存器用于记录剩下未传输的字节数
     SetEPRxStatus(ENDP1, EP_RX_VALID);	//设置端点接受有效 EP_RX_VALID=0x3000

  /* Initialize Endpoint 2 */
     SetEPType(ENDP2, EP_INTERRUPT);
     SetEPTxAddr(ENDP2, ENDP2_TXADDR);
     SetEPTxCount(ENDP2, 22);
     SetEPTxStatus(ENDP2, EP_TX_NAK);//设置端点发送不应答 EP_TX_NAK=(0x0020)

  bDeviceState = ATTACHED;	//ATTACHED=1
  
  /* Set this device to response on default address */
  SetDeviceAddress(0);
}
Example #9
0
/**
  * @brief Configure an EP
  * @param  pdev : Device instance
  * @param  ep_addr: endpoint address
  * @param  ep_mps: endpoint max packet size
  * @param  ep_type: endpoint Type
  */
uint32_t DCD_EP_Open(USB_CORE_HANDLE *pdev , 
                     uint16_t ep_addr,
                     uint16_t ep_mps,
                     uint8_t ep_type)
{
  
  USB_EP *ep;
  
  /* initialize ep structure*/
  if ((ep_addr & 0x80) == 0x80)
  {
    ep = &pdev->dev.in_ep[ep_addr & 0x7F];
    ep->is_in = 1;
  }
  else
  {
    ep = &pdev->dev.out_ep[ep_addr & 0x7F];
    ep->is_in = 0;
  }
  
  ep->maxpacket = ep_mps;
  ep->type = ep_type;
  ep->num   = ep_addr & 0x7F;
  
  if (ep->num == 0)
  {
    /* Initialize the control transfer variables*/ 
    ep->ctl_data_len =0;
    ep->rem_data_len = 0;
    ep->total_data_len = 0;
  }
  
  /* Initialize the transaction level variables */
  ep->xfer_buff = 0;
  ep->xfer_len = 0;
  ep->xfer_count = 0;
  ep->is_stall = 0;
  
  /* initialize HW */
  switch (ep->type)
  {
  case USB_EP_CONTROL:
    SetEPType(ep->num, EP_CONTROL);
    break;
  case USB_EP_BULK:
    SetEPType(ep->num, EP_BULK);
    break;
  case USB_EP_INT:
    SetEPType(ep->num, EP_INTERRUPT);
    break;
  case USB_EP_ISOC:
    SetEPType(ep->num, EP_ISOCHRONOUS);
    break;
  } 
  
  if (ep->doublebuffer == 0) 
  {
    if (ep->is_in)
    {
      /*Set the endpoint Transmit buffer address */
      SetEPTxAddr(ep->num, ep->pmaadress);
      ClearDTOG_TX(ep->num);
      /* Configure NAK status for the Endpoint*/
      SetEPTxStatus(ep->num, EP_TX_NAK); 
    }
    else
    {
      /*Set the endpoint Receive buffer address */
      SetEPRxAddr(ep->num, ep->pmaadress);
      /*Set the endpoint Receive buffer counter*/
      SetEPRxCount(ep->num, ep->maxpacket);
      ClearDTOG_RX(ep->num);
      /* Configure VALID status for the Endpoint*/
      SetEPRxStatus(ep->num, EP_RX_VALID);
    }
  }
  /*Double Buffer*/
  else
  {
    /*Set the endpoint as double buffered*/
    SetEPDoubleBuff(ep->num);
    /*Set buffer address for double buffered mode*/
    SetEPDblBuffAddr(ep->num,ep->pmaaddr0, ep->pmaaddr1);
    
    if (ep->is_in==0)
    {
      /* Clear the data toggle bits for the endpoint IN/OUT*/
      ClearDTOG_RX(ep->num);
      ClearDTOG_TX(ep->num);
      
      /* Reset value of the data toggle bits for the endpoint out*/
      ToggleDTOG_TX(ep->num);
      
      SetEPRxStatus(ep->num, EP_RX_VALID);
      SetEPTxStatus(ep->num, EP_TX_DIS);
    }
    else
    {
      /* Clear the data toggle bits for the endpoint IN/OUT*/
      ClearDTOG_RX(ep->num);
      ClearDTOG_TX(ep->num);
      ToggleDTOG_RX(ep->num);
      /* Configure DISABLE status for the Endpoint*/
      SetEPTxStatus(ep->num, EP_TX_DIS);
      SetEPRxStatus(ep->num, EP_RX_DIS);
    }
  } 
  return USB_OK; 
}
Example #10
0
/*******************************************************************************
* Function Name  : Virtual_Com_Port_Reset
* Description    : Virtual_Com_Port Mouse reset routine
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
void Virtual_Com_Port_Reset(void)
{
    /* Set Virtual_Com_Port_DEVICE as not configured */
    pInformation->Current_Configuration = 0;
    pInformation->Current_Interface = 0;/*the default Interface*/
    SetBTABLE(BTABLE_ADDRESS);

    /* Initialize Endpoint 0 */
    SetEPType(ENDP0, EP_CONTROL);
    SetEPTxStatus(ENDP0, EP_TX_STALL);
    SetEPRxAddr(ENDP0, ENDP0_RXADDR);   //GS 0x40 64
    SetEPTxAddr(ENDP0, ENDP0_TXADDR);   //GS 0x80 128
    Clear_Status_Out(ENDP0);
    SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
    SetEPRxValid(ENDP0);

    /*-------------------------------------------------------------*/
    /* --------------   Buffer Description Table  -----------------*/
    /*-------------------------------------------------------------*/

//#define VIRTUAL_COM_PORT_DATA_SIZE	           64

    /* EP0  */
    /* rx/tx buffer base address */
//#define ENDP0_RXADDR        (0x40)
//#define ENDP0_TXADDR        (0x80)

    /* EP1  */
    /* tx buffer base address */
//#define ENDP1_BUFF0_ADDR        (0xC0)
//#define ENDP1_BUFF1_ADDR        (0x100)
//#define ENDP2_BUFF0_ADDR        (0x1C0)
//#define ENDP2_BUFF1_ADDR        (0x1D0)

    // Initialize Endpoint 1

    SetEPType(ENDP1, EP_BULK);
    SetEPTxAddr(ENDP1, ENDP1_BUFF_ADDR);
    SetEPRxCount(ENDP1,64);
    SetEPTxStatus(ENDP1, EP_TX_NAK);
    SetEPRxStatus(ENDP1, EP_RX_DIS);

    // Initialize Endpoint 2
    SetEPType(ENDP2, EP_BULK);
    SetEPRxAddr(ENDP2, ENDP2_BUFF_ADDR);
    SetEPRxCount(ENDP2, 64);
    SetEPRxStatus(ENDP2, EP_RX_VALID);
    SetEPTxStatus(ENDP2, EP_TX_DIS);

    // Initialize Endpoint 3  // IN cmd
    SetEPType(ENDP3, EP_BULK);
    SetEPTxAddr(ENDP3, ENDP3_BUFF_ADDR);
    SetEPRxCount(ENDP3, 64);
    SetEPTxStatus(ENDP3, EP_TX_NAK);
    SetEPRxStatus(ENDP3, EP_RX_DIS);

    // Initialize Endpoint 4 // OUT cmd
    SetEPType(ENDP4, EP_BULK);
    SetEPRxAddr(ENDP4, ENDP4_BUFF_ADDR);
    SetEPRxCount(ENDP4, 64);
    SetEPRxStatus(ENDP4, EP_RX_VALID);
    SetEPTxStatus(ENDP4, EP_TX_DIS);

    /* Set this device to respsonse on default address */
    SetDeviceAddress(0);
}
Example #11
0
/*******************************************************************************
* Function Name  : Joystick_Reset.
* Description    : Joystick Mouse reset routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
void USB_APP_Reset(void)
{
  /* Set Joystick_DEVICE as not configured */
  pInformation->Current_Configuration = 0;
 
  /* Current Feature initialization */
#if(USB_DEVICE_CONFIG & _USE_USB_VIRTUAL_COMM_DEVICE)
  if (g_usb_type == USB_VIRTUAL_PORT)
  {
	  pInformation->Current_Interface = 0;
	  pInformation->Current_Feature = Virtual_Com_Port_ConfigDescriptor[7];
  }
  else 
#endif

#if(USB_DEVICE_CONFIG & _USE_USB_KEYBOARD_DEVICE)
	  if(g_usb_type == USB_KEYBOARD)
  {
	 pInformation->Current_Interface = 0;
	 pInformation->Current_Feature = Keyboard_ConfigDescriptor[7];
  }
  else
#endif

#if(USB_DEVICE_CONFIG & _USE_USB_MASS_STOARGE_DEVICE)
  {
	pInformation->Current_Feature = MASS_ConfigDescriptor[7];
  }
#endif

#if(USB_DEVICE_CONFIG & _USE_USB_PRINTER_DEVICE)
	  {
		  pInformation->Current_Interface = 0;
		  pInformation->Current_Feature = Printer_ConfigDescriptor[7];
	  }
#endif

  SetBTABLE(BTABLE_ADDRESS);

  /* Initialize Endpoint 0 */
  SetEPType(ENDP0, EP_CONTROL);
  SetEPTxStatus(ENDP0, EP_TX_STALL);
  SetEPRxAddr(ENDP0, ENDP0_RXADDR);
  SetEPTxAddr(ENDP0, ENDP0_TXADDR);
  Clear_Status_Out(ENDP0);
  SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
  SetEPRxValid(ENDP0);
#if(USB_DEVICE_CONFIG & _USE_USB_VIRTUAL_COMM_DEVICE)
if (g_usb_type == USB_VIRTUAL_PORT)
{
	/* Initialize Endpoint 1 */
	SetEPType(ENDP1, EP_BULK);
	SetEPTxAddr(ENDP1, ENDP1_TXADDR);
	SetEPTxStatus(ENDP1, EP_TX_NAK);
	SetEPRxStatus(ENDP1, EP_RX_DIS);

	/* Initialize Endpoint 2 */
	SetEPType(ENDP2, EP_INTERRUPT);
	SetEPTxAddr(ENDP2, ENDP2_TXADDR);
	SetEPRxStatus(ENDP2, EP_RX_DIS);
	SetEPTxStatus(ENDP2, EP_TX_NAK);

	/* Initialize Endpoint 3 */
	SetEPType(ENDP3, EP_BULK);
	SetEPRxAddr(ENDP3, ENDP3_RXADDR);
	SetEPRxCount(ENDP3, VIRTUAL_COM_PORT_DATA_SIZE);
	SetEPRxStatus(ENDP3, EP_RX_VALID);
	SetEPTxStatus(ENDP3, EP_TX_DIS);
}
else 
#endif

#if(USB_DEVICE_CONFIG & _USE_USB_KEYBOARD_DEVICE)
if(g_usb_type == USB_KEYBOARD)
{
	/* Initialize Endpoint 1 */
	SetEPType(ENDP1, EP_INTERRUPT);
	SetEPTxAddr(ENDP1, ENDP1_TXADDR);
	SetEPTxCount(ENDP1, 1);
	SetEPRxStatus(ENDP1, EP_RX_DIS);
	SetEPTxStatus(ENDP1, EP_TX_NAK);
}
else
#endif

#if(USB_DEVICE_CONFIG & _USE_USB_MASS_STOARGE_DEVICE)
{
	/* Initialize Endpoint 1 */
	SetEPType(ENDP1, EP_BULK);
	SetEPTxAddr(ENDP1, ENDP1_TXADDR);
	SetEPTxStatus(ENDP1, EP_TX_NAK);
	SetEPRxStatus(ENDP1, EP_RX_DIS);

	/* Initialize Endpoint 2 */
	SetEPType(ENDP2, EP_BULK);
	SetEPRxAddr(ENDP2, ENDP2_RXADDR);
	SetEPRxCount(ENDP2, Device_Property.MaxPacketSize);			
	//SetEPRxCount(ENDP2, 0x40);										//joe ÐÞ¸Ä
	SetEPRxStatus(ENDP2, EP_RX_VALID);
	SetEPTxStatus(ENDP2, EP_TX_DIS);


	SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
	SetEPRxValid(ENDP0);

	CBW.dSignature = BOT_CBW_SIGNATURE;
	Bot_State = BOT_IDLE;
}
#endif

#if(USB_DEVICE_CONFIG & _USE_USB_PRINTER_DEVICE)
{
	/* Initialize Endpoint 1 */
	SetEPType(ENDP1, EP_BULK);
	SetEPTxAddr(ENDP1, ENDP1_TXADDR);
	SetEPTxStatus(ENDP1, EP_TX_NAK);
	SetEPRxStatus(ENDP1, EP_RX_DIS);

	/* Initialize Endpoint 2 */
	SetEPType(ENDP2, EP_BULK);
	SetEPRxAddr(ENDP2, ENDP2_RXADDR);
	SetEPRxCount(ENDP2, Device_Property.MaxPacketSize);			
	//SetEPRxCount(ENDP2, 0x40);										//joe ÐÞ¸Ä
	SetEPRxStatus(ENDP2, EP_RX_VALID);
	SetEPTxStatus(ENDP2, EP_TX_DIS);
}
#endif

  bDeviceState = ATTACHED;

  /* Set this device to response on default address */
  SetDeviceAddress(0);
}
Example #12
0
/*******************************************************************************
* Function Name  : USB_Reset
* Description    : USB reset routine
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
void USB_Reset(void)
{
  /* Set USB DEVICE as not configured */
  pInformation->Current_Configuration = 0;

  /* Set USB DEVICE with the default Interface*/
  pInformation->Current_Interface = 0;

#ifdef USB_CDC_ENABLE
  /* Current Feature initialization */
  pInformation->Current_Feature = CDC_ConfigDescriptor[7];
#endif

#ifdef USB_HID_ENABLE
  /* Current Feature initialization */
  pInformation->Current_Feature = HID_ConfigDescriptor[7];
#endif

  SetBTABLE(BTABLE_ADDRESS);

  /* Initialize Endpoint 0 */
  SetEPType(ENDP0, EP_CONTROL);
  SetEPTxStatus(ENDP0, EP_TX_STALL);
  SetEPRxAddr(ENDP0, ENDP0_RXADDR);
  SetEPTxAddr(ENDP0, ENDP0_TXADDR);
  Clear_Status_Out(ENDP0);
  SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
  SetEPRxValid(ENDP0);

#ifdef USB_CDC_ENABLE
  /* Initialize Endpoint 1 */
  SetEPType(ENDP1, EP_BULK);
  SetEPTxAddr(ENDP1, ENDP1_TXADDR);
  SetEPTxStatus(ENDP1, EP_TX_NAK);
  SetEPRxStatus(ENDP1, EP_RX_DIS);

  /* Initialize Endpoint 2 */
  SetEPType(ENDP2, EP_INTERRUPT);
  SetEPTxAddr(ENDP2, ENDP2_TXADDR);
  SetEPRxStatus(ENDP2, EP_RX_DIS);
  SetEPTxStatus(ENDP2, EP_TX_NAK);

  /* Initialize Endpoint 3 */
  SetEPType(ENDP3, EP_BULK);
  SetEPRxAddr(ENDP3, ENDP3_RXADDR);
  SetEPRxCount(ENDP3, CDC_DATA_SIZE);
  SetEPRxStatus(ENDP3, EP_RX_VALID);
  SetEPTxStatus(ENDP3, EP_TX_DIS);
#endif

#ifdef USB_HID_ENABLE
  /* Initialize Endpoint 1 */
  SetEPType(ENDP1, EP_INTERRUPT);
  SetEPTxAddr(ENDP1, ENDP1_TXADDR);
#if defined (SPARK_USB_MOUSE)
  SetEPTxCount(ENDP1, 4);
#elif defined (SPARK_USB_KEYBOARD)
  SetEPTxCount(ENDP1, 8);
#endif
  SetEPRxStatus(ENDP1, EP_RX_DIS);
  SetEPTxStatus(ENDP1, EP_TX_NAK);
#endif

  /* Set this device to response on default address */
  SetDeviceAddress(0);

  bDeviceState = ATTACHED;
}
Example #13
0
/*******************************************************************************
* Function Name  : Virtual_Com_Port_Reset
* Description    : Virtual_Com_Port Mouse reset routine
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
void Virtual_Com_Port_Reset(void)
{
	/* Set Virtual_Com_Port DEVICE as not configured */
	pInformation->Current_Configuration = 0;

	/* Current Feature initialization */
	pInformation->Current_Feature = Virtual_Com_Port_ConfigDescriptor[7];

	/* Set Virtual_Com_Port DEVICE with the default Interface*/
	pInformation->Current_Interface = 0;

#ifdef STM32F10X_CL     
	/* EP0 is already configured by USB_SIL_Init() function */
  
	/* Init EP1 IN as Bulk endpoint */
	OTG_DEV_EP_Init(EP1_IN, OTG_DEV_EP_TYPE_BULK, VIRTUAL_COM_PORT_DATA_SIZE);
  
	/* Init EP2 IN as Interrupt endpoint */
	OTG_DEV_EP_Init(EP2_IN, OTG_DEV_EP_TYPE_INT, VIRTUAL_COM_PORT_INT_SIZE);

	/* Init EP3 OUT as Bulk endpoint */
	OTG_DEV_EP_Init(EP3_OUT, OTG_DEV_EP_TYPE_BULK, VIRTUAL_COM_PORT_DATA_SIZE);  
#else 

	SetBTABLE(BTABLE_ADDRESS);

	/* Initialize Endpoint 0 */
	SetEPType(ENDP0, EP_CONTROL);
	SetEPTxStatus(ENDP0, EP_TX_STALL);
	SetEPRxAddr(ENDP0, ENDP0_RXADDR);
	SetEPTxAddr(ENDP0, ENDP0_TXADDR);
	Clear_Status_Out(ENDP0);
	SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
	SetEPRxValid(ENDP0);

	/* Initialize Endpoint 1 */
	SetEPType(ENDP1, EP_BULK);
	SetEPTxAddr(ENDP1, ENDP1_TXADDR);
	SetEPTxStatus(ENDP1, EP_TX_NAK);
	SetEPRxStatus(ENDP1, EP_RX_DIS);

	/* Initialize Endpoint 2 */
	SetEPType(ENDP2, EP_INTERRUPT);
	SetEPTxAddr(ENDP2, ENDP2_TXADDR);
	SetEPRxStatus(ENDP2, EP_RX_DIS);
	SetEPTxStatus(ENDP2, EP_TX_NAK);

	/* Initialize Endpoint 3 */
	SetEPType(ENDP3, EP_BULK);
	SetEPRxAddr(ENDP3, ENDP3_RXADDR);
	SetEPRxCount(ENDP3, VIRTUAL_COM_PORT_DATA_SIZE);
	SetEPRxStatus(ENDP3, EP_RX_VALID);
	SetEPTxStatus(ENDP3, EP_TX_DIS);


	/* Initialize Endpoint 4 */
	SetEPType(ENDP4, EP_BULK);
	SetEPTxAddr(ENDP4, ENDP4_TXADDR);
	SetEPTxStatus(ENDP4, EP_TX_NAK);
	SetEPRxStatus(ENDP4, EP_RX_DIS);

	/* Initialize Endpoint 5 */
	SetEPType(ENDP5, EP_INTERRUPT);
	SetEPTxAddr(ENDP5, ENDP5_TXADDR);
	SetEPRxStatus(ENDP5, EP_RX_DIS);
	SetEPTxStatus(ENDP5, EP_TX_NAK);

	/* Initialize Endpoint 6 */
	SetEPType(ENDP6, EP_BULK);
	SetEPRxAddr(ENDP6, ENDP6_RXADDR);
	SetEPRxCount(ENDP6, VIRTUAL_COM_PORT_DATA_SIZE);
	SetEPRxStatus(ENDP6, EP_RX_VALID);
	SetEPTxStatus(ENDP6, EP_TX_DIS);

	/* Set this device to response on default address */
	SetDeviceAddress(0);

#endif /* STM32F10X_CL */

	bDeviceState = ATTACHED;
}