예제 #1
0
/*******************************************************************************
* Function Name  : Set_CSW
* Description    : Set the SCW with the needed fields.
* Input          : u8 CSW_Status this filed can be CSW_CMD_PASSED,CSW_CMD_FAILED,
*                  or CSW_PHASE_ERROR.
* Output         : None.
* Return         : None.
*******************************************************************************/
void Set_CSW (u8 CSW_Status, u8 Send_Permission)
{
  CSW.dSignature = BOT_CSW_SIGNATURE;
  CSW.bStatus = CSW_Status;

  UserToPMABufferCopy(((u8 *)& CSW), ENDP3_TXADDR, CSW_DATA_LENGTH);

  SetEPTxCount(ENDP3, CSW_DATA_LENGTH);
  Bot_State = BOT_ERROR;
  if (Send_Permission)
  {
    Bot_State = BOT_CSW_Send;
    SetEPTxStatus(ENDP3, EP_TX_VALID);
  }

}
예제 #2
0
/*******************************************************************************
* Function Name  : Set_CSW
* Description    : Set the SCW with the needed fields.
* Input          : uint8_t CSW_Status this filed can be CSW_CMD_PASSED,CSW_CMD_FAILED,
*                  or CSW_PHASE_ERROR.
* Output         : None.
* Return         : None.
*******************************************************************************/
void Set_CSW (uint8_t CSW_Status, uint8_t Send_Permission)
{
  CSW.dSignature = BOT_CSW_SIGNATURE;
  CSW.bStatus = CSW_Status;

  USB_SIL_Write(EP1_IN, ((uint8_t *)& CSW), CSW_DATA_LENGTH);

  Bot_State = BOT_ERROR;
  if (Send_Permission)
  {
    Bot_State = BOT_CSW_Send;
#ifndef USE_STM3210C_EVAL
    SetEPTxStatus(ENDP1, EP_TX_VALID);
#endif  
  }

}
예제 #3
0
파일: usb_core.c 프로젝트: muchtech/stm32
/*******************************************************************************
* Function Name  : Standard_SetEndPointFeature
* Description    : Set or enable a specific feature of EndPoint
* Input          : None.
* Output         : None.
* Return         : - Return USB_SUCCESS, if the request is performed.
*                  - Return USB_UNSUPPORT, if the request is invalid.
*******************************************************************************/
RESULT Standard_SetEndPointFeature(void)
{
    uint32_t    wIndex0;
    uint32_t    Related_Endpoint;
    uint32_t    rEP;
    uint32_t    Status;

    wIndex0 = pInformation->USBwIndex0;
    rEP = wIndex0 & ~0x80;
    Related_Endpoint = ENDP0 + rEP;

    if (ValBit(pInformation->USBwIndex0, 7))
    {
        /* get Status of endpoint & stall the request if the related_ENdpoint
        is Disabled*/
        Status = GetEPTxStatus(Related_Endpoint);
    }
    else
    {
        Status = GetEPRxStatus(Related_Endpoint);
    }

    if (Related_Endpoint >= Device_Table.Total_Endpoint
            || pInformation->USBwValue != 0 || Status == 0
            || pInformation->Current_Configuration == 0)
    {
        return USB_UNSUPPORT;
    }
    else
    {
        if (wIndex0 & 0x80)
        {
            /* IN endpoint */
            SetEPTxStatus(Related_Endpoint, EP_TX_STALL);
        }

        else
        {
            /* OUT endpoint */
            SetEPRxStatus(Related_Endpoint, EP_RX_STALL);
        }
    }
    pUser_Standard_Requests->User_SetEndPointFeature();
    return USB_SUCCESS;
}
예제 #4
0
/*******************************************************************************
* Function Name  : Read_Memory
* Description    : Handle the Read operation from the microSD card.
*******************************************************************************/
void Read_Memory(u32 Memory_Offset, u32 Transfer_Length)
{
  static u32 Offset, Length;

  if (TransferState == TXFR_IDLE )
  {
    Offset = Memory_Offset * Mass_Block_Size;
    Length = Transfer_Length * Mass_Block_Size;
    TransferState = TXFR_ONGOING;
  }

  if (TransferState == TXFR_ONGOING )
  {
    if (!Block_Read_count)
    {
      Clash = 1;
      __ExtFlash_PageRD(Data_Buffer, Offset, Mass_Block_Size);           
      UserToPMABufferCopy((u8 *)Data_Buffer, ENDP1_TXADDR, BULK_MAX_PACKET_SIZE);
      Block_Read_count = Mass_Block_Size - BULK_MAX_PACKET_SIZE;
      Block_offset = BULK_MAX_PACKET_SIZE;
    }
    else
    {
      UserToPMABufferCopy((u8 *)Data_Buffer + Block_offset, ENDP1_TXADDR, BULK_MAX_PACKET_SIZE);
      Block_Read_count -= BULK_MAX_PACKET_SIZE;
      Block_offset += BULK_MAX_PACKET_SIZE;
    }

    SetEPTxCount(ENDP1, BULK_MAX_PACKET_SIZE);
    SetEPTxStatus(ENDP1, EP_TX_VALID);
    Offset += BULK_MAX_PACKET_SIZE;
    Length -= BULK_MAX_PACKET_SIZE;

    CSW.dDataResidue -= BULK_MAX_PACKET_SIZE;
  }
  if (Length == 0)
  {
    Block_Read_count = 0;
    Block_offset = 0;
    Offset = 0;
    Bot_State = BOT_DATA_IN_LAST;
    TransferState = TXFR_IDLE;
  }
}
예제 #5
0
파일: usb_desc.c 프로젝트: bogus532/monkey
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);
    }
	}
}
/*******************************************************************************
* Function Name  : Read_Memory
* Description    : Handle the Read operation from the microSD card. 
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
void Read_Memory(void)
{ //unsigned int a=0,b=0;	 
	NAND_ADDRESS Nand_Addr;
 // GPIO_SetBits(GPIOB, GPIO_Pin_5);
  if (!Block_Read_count)
  {	
		//NAND_ConvertOffsetToAddress(Memory_Offset, 64, &Nand_Addr);
		NAND_ConvertOffsetToAddress(Memory_Offset, 2048, &Nand_Addr);
		NAND_ReadSmallPage(Data1_Buffer, Nand_Addr, 1);
		//NAND_ReadSpareArea(Data1_Buffer, Nand_Addr, 1);
    UserToPMABufferCopy(Data1_Buffer, ENDP1_TXADDR, BULK_MAX_PACKET_SIZE);
    Block_Read_count = 2048 - BULK_MAX_PACKET_SIZE;
		//Block_Read_count = 64 - BULK_MAX_PACKET_SIZE;
    Block_offset = BULK_MAX_PACKET_SIZE;	 
  }
  else
  {
    UserToPMABufferCopy(Data1_Buffer + Block_offset, ENDP1_TXADDR, BULK_MAX_PACKET_SIZE);
    Block_Read_count -= BULK_MAX_PACKET_SIZE;
    Block_offset += BULK_MAX_PACKET_SIZE;
  }

  SetEPTxCount(ENDP1, BULK_MAX_PACKET_SIZE);
  SetEPTxStatus(ENDP1, EP_TX_VALID);

  Memory_Offset += BULK_MAX_PACKET_SIZE;
  Transfer_Length -= BULK_MAX_PACKET_SIZE;

  CSW.dDataResidue -= BULK_MAX_PACKET_SIZE;
  //Led_RW_ON();

  if (Transfer_Length == 0)
  {
    Block_Read_count = 0;
    Block_offset = 0;
    Memory_Offset = 0;
    Bot_State = BOT_DATA_IN_LAST;
    //Led_RW_OFF();
  }
}
예제 #7
0
파일: memory.c 프로젝트: eleqian/WiDSO
/*******************************************************************************
* Function Name  : Read_Memory
* Description    : Handle the Read operation from the microSD card.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
void Read_Memory(uint8_t lun, uint32_t Memory_Offset, uint32_t Transfer_Length)
{
    static uint32_t Offset, Length;

    if (TransferState == TXFR_IDLE) {
        Offset = Memory_Offset * Mass_Block_Size[lun];
        Length = Transfer_Length * Mass_Block_Size[lun];
        TransferState = TXFR_ONGOING;
    }

    if (TransferState == TXFR_ONGOING) {
        // 缓冲区空时从存储设备读取数据
        if (0 == Block_Read_count) {
            MAL_Read(lun, Offset, Data_Buffer, Mass_Block_Size[lun]);
            Block_Read_count = Mass_Block_Size[lun];
            Block_offset = 0;
        }

        USB_SIL_Write(EP1_IN, (uint8_t *)Data_Buffer + Block_offset, BULK_MAX_PACKET_SIZE);
        Block_Read_count -= BULK_MAX_PACKET_SIZE;
        Block_offset += BULK_MAX_PACKET_SIZE;

        SetEPTxCount(ENDP1, BULK_MAX_PACKET_SIZE);
        SetEPTxStatus(ENDP1, EP_TX_VALID);
        Offset += BULK_MAX_PACKET_SIZE;
        Length -= BULK_MAX_PACKET_SIZE;

        CSW.dDataResidue -= BULK_MAX_PACKET_SIZE;
        USB_Led_RW_ON();
    }

    if (Length == 0) {
        Block_Read_count = 0;
        Block_offset = 0;
        Offset = 0;
        Bot_State = BOT_DATA_IN_LAST;
        TransferState = TXFR_IDLE;
        USB_Led_RW_OFF();
    }
}
예제 #8
0
파일: STM32_USBD.c 프로젝트: GorosVi/vsprog
vsf_err_t stm32_usbd_ep_set_IN_epsize(uint8_t idx, uint16_t epsize)
{
	int8_t index;
	
	index = stm32_usbd_get_ep(idx);
	if (index < 0)
	{
		return VSFERR_FAIL;
	}
	idx = (uint8_t)index;
	
	if ((EP_Cfg_Ptr - epsize) < STM32_USBD_EP_NUM * 8)
	{
		return VSFERR_NOT_ENOUGH_RESOURCES;
	}
	
	stm32_usbd_IN_epsize[idx] = epsize;
	SetEPTxCount(idx, epsize);
	// fix for 16-bit aligned memory
	EP_Cfg_Ptr -= epsize & 1 ? epsize + 1 : epsize;
	SetEPTxAddr(idx, EP_Cfg_Ptr);
	SetEPTxStatus(idx, EP_TX_NAK);
	return VSFERR_NONE;
}
예제 #9
0
파일: usb_dcd.c 프로젝트: royazriel/RoboMow
/**
  * @brief Stall an endpoint.
  * @param  pdev: device instance
  * @param  epnum: endpoint address
  * @retval : status
  */
uint32_t  DCD_EP_Stall (USB_CORE_HANDLE *pdev, uint8_t   epnum)
{
  USB_EP *ep;
  if ((0x80 & epnum) == 0x80)
  {
    ep = &pdev->dev.in_ep[epnum & 0x7F];    
  }
  else
  {
    ep = &pdev->dev.out_ep[epnum];
  }
  
  if (ep->num ==0)
  {
    /* This macro sets STALL status for RX & TX*/ 
    _SetEPRxTxStatus(ep->num,EP_RX_STALL,EP_TX_STALL); 
    /*Endpoint is stalled */
    ep->is_stall = 1;
    return USB_OK;
  }
  if (ep->is_in)
  {  
    /* IN endpoint */
    ep->is_stall = 1;
    /* IN Endpoint stalled */
   SetEPTxStatus(ep->num , EP_TX_STALL); 
  }
  else
  { 
    ep->is_stall = 1;
    /* OUT Endpoint stalled */
    SetEPRxStatus(ep->num , EP_RX_STALL);
  }
  
  return USB_OK;
}
예제 #10
0
파일: usb_endp.c 프로젝트: tk14/DCMonitor
/*******************************************************************************
* Function Name  : EP1_Send_Callback.
* Description    : EP1 Sending data Callback Routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
void EP1_Send_Callback(void)
{
  UserToPMABufferCopy((u8 *)USB_S_Buffer, ENDP1_TXADDR, USB_S_Size);
  SetEPTxCount(ENDP1, USB_S_Size);
  SetEPTxStatus(ENDP1, EP_TX_VALID);
}
예제 #11
0
파일: usb_dcd.c 프로젝트: royazriel/RoboMow
/**
  * @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; 
}
예제 #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;
}
예제 #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;
    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);
}
예제 #14
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);
}
예제 #15
0
파일: usb_regs.c 프로젝트: 9zigen/stm32
/*******************************************************************************
* Function Name  : SetEPTxValid
* Description    : Valid the endpoint Tx Status.
* Input          : bEpNum: Endpoint Number.  
* Output         : None.
* Return         : None.
*******************************************************************************/
void SetEPTxValid(uint8_t bEpNum) {
	SetEPTxStatus(bEpNum,EP_TX_VALID);
}
예제 #16
0
/*******************************************************************************
* Function Name  : Standard_ClearFeature.
* Description    : Clear or disable a specific feature.
* Input          : None.
* Output         : None.
* Return         : - Return USB_SUCCESS, if the request is performed.
*                  - Return USB_UNSUPPORT, if the request is invalid.
*******************************************************************************/
RESULT Standard_ClearFeature(void) {
    uint32_t Type_Rec = Type_Recipient;
    uint32_t Status;


    if(Type_Rec == (STANDARD_REQUEST | DEVICE_RECIPIENT)) { /*Device Clear Feature*/
        ClrBit(pInformation->Current_Feature, 5);
        return USB_SUCCESS;
    } else if(Type_Rec == (STANDARD_REQUEST | ENDPOINT_RECIPIENT)) { /*EndPoint Clear Feature*/
        DEVICE* pDev;
        uint32_t Related_Endpoint;
        uint32_t wIndex0;
        uint32_t rEP;

        if((pInformation->USBwValue != ENDPOINT_STALL) || (pInformation->USBwIndex1 != 0)) {
            return USB_UNSUPPORT;
        }

        pDev = &Device_Table;
        wIndex0 = pInformation->USBwIndex0;
        rEP = wIndex0 & ~0x80;
        Related_Endpoint = ENDP0 + rEP;

        if(ValBit(pInformation->USBwIndex0, 7)) {
            /*Get Status of endpoint & stall the request if the related_ENdpoint
            is Disabled*/
            Status = _GetEPTxStatus(Related_Endpoint);
        } else {
            Status = _GetEPRxStatus(Related_Endpoint);
        }

        if((rEP >= pDev->Total_Endpoint) || (Status == 0) || (pInformation->Current_Configuration == 0)) {
            return USB_UNSUPPORT;
        }


        if(wIndex0 & 0x80) {
            /* IN endpoint */
            if(_GetTxStallStatus(Related_Endpoint)) {
#ifndef STM32F10X_CL
                ClearDTOG_TX(Related_Endpoint);
#endif /* STM32F10X_CL */
                SetEPTxStatus(Related_Endpoint, EP_TX_VALID);
            }
        } else {
            /* OUT endpoint */
            if(_GetRxStallStatus(Related_Endpoint)) {
                if(Related_Endpoint == ENDP0) {
                    /* After clear the STALL, enable the default endpoint receiver */
                    SetEPRxCount(Related_Endpoint, Device_Property.MaxPacketSize);
                    _SetEPRxStatus(Related_Endpoint, EP_RX_VALID);
                } else {
#ifndef STM32F10X_CL
                    ClearDTOG_RX(Related_Endpoint);
#endif /* STM32F10X_CL */
                    _SetEPRxStatus(Related_Endpoint, EP_RX_VALID);
                }
            }
        }
        pUser_Standard_Requests->User_ClearFeature();
        return USB_SUCCESS;
    }

    return USB_UNSUPPORT;
}
예제 #17
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;
}