Esempio n. 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;
}
Esempio n. 2
0
/*******************************************************************************
    Function Name  : USBdev_Reset.
    Description    : USB device reset routine.
    Input          : None.
    Output         : None.
    Return         : None.
*******************************************************************************/
void USBdev_Reset() {
	// Set DEVICE as not configured
	pInformation->Current_Configuration = 0;

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

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

	// BTABLE_ADDRESS = 0
	USB->BTABLE = 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,VCOM_INT_SIZE);
	SetEPRxStatus(ENDP3,EP_RX_VALID);
	SetEPTxStatus(ENDP3,EP_TX_DIS);

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

	bDeviceState = ATTACHED;
}
Esempio n. 3
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();
}
Esempio n. 4
0
void Device_Reset(void) {
  /* Set the device as not configured */
  pInformation->Current_Configuration = 0;

  /* Current feature initialization */
  pInformation->Current_Feature = ConfigDescriptor[7];

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

  SetBTABLE(0x00);

  /* 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, VCP_DATA_SIZE);
  SetEPRxStatus(ENDP3, EP_RX_VALID);
  SetEPTxStatus(ENDP3, EP_TX_DIS);

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

  /* Device attached */
  led_off();
}
/*******************************************************************************
* 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;
}
Esempio n. 6
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);
    }
	}
}
Esempio n. 7
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);
}
Esempio n. 8
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;
}
Esempio n. 9
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;
}
Esempio n. 10
0
void usbReset(void) {
  dfuUpdateByReset();

  pInformation->Current_Configuration = 0;
  pInformation->Current_Feature = usbConfigDescriptorDFU.Descriptor[7];

  _SetBTABLE(BTABLE_ADDRESS);

  /* setup the ctrl endpoint */
  _SetEPType(ENDP0, EP_CONTROL);
  _SetEPTxStatus(ENDP0, EP_TX_STALL);

  _SetEPRxAddr(ENDP0, ENDP0_RXADDR);
  _SetEPTxAddr(ENDP0, ENDP0_TXADDR);

  Clear_Status_Out(ENDP0);

  SetEPRxCount(ENDP0, pProperty->MaxPacketSize);
  //  SetEPTxCount(ENDP0, pProperty->MaxPacketSize);
  SetEPRxValid(ENDP0);

  bDeviceState = ATTACHED;
  SetDeviceAddress(0); /* different than usbSetDeviceAddr! comes from usb_core */
}
Esempio n. 11
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);
}
Esempio n. 12
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);
}
Esempio n. 13
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;
}
Esempio n. 14
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;
}