Example #1
0
/*******************************************************************************
* Function Name  : Setup0_Process
* Description    : Get the device request data and dispatch to individual process.
* Input          : None.
* Output         : None.
* Return         : Post0_Process.
*******************************************************************************/
uint8_t Setup0_Process(void) {
    union {
        uint8_t* b;
        uint16_t* w;
    } pBuf;
    
    uint16_t offset = 1;
  
    pBuf.b = PMAAddr + (uint8_t *)(_GetEPRxAddr(ENDP0) * 2); /* *2 for 32 bits addr */

    if (pInformation->ControlState != PAUSE) {
        pInformation->USBbmRequestType = *pBuf.b++; /* bmRequestType */
        pInformation->USBbRequest = *pBuf.b++; /* bRequest */
        pBuf.w += offset;  /* word not accessed because of 32 bits addressing */
        pInformation->USBwValue = ByteSwap(*pBuf.w++); /* wValue */
        pBuf.w += offset;  /* word not accessed because of 32 bits addressing */
        pInformation->USBwIndex  = ByteSwap(*pBuf.w++); /* wIndex */
        pBuf.w += offset;  /* word not accessed because of 32 bits addressing */
        pInformation->USBwLength = *pBuf.w; /* wLength */
    }

    pInformation->ControlState = SETTING_UP;
    if (pInformation->USBwLength == 0) {
        /* Setup with no data stage */
        NoData_Setup0();
    }
    else {
        /* Setup with data stage */
        Data_Setup0();
    }
    
    return Post0_Process();
}
Example #2
0
/*******************************************************************************
* Function Name  : Setup0_Process
* Description    : Get the device request data and dispatch to individual process.
* Input          : None.
* Output         : None.
* Return         : Post0_Process.
*******************************************************************************/
uint8_t Setup0_Process(void) {
	union {
		uint8_t* b;
		uint16_t* w;
	} pBuf;
	uint16_t offset = 1;
  
	pBuf.b = USB_PMAADDR + (uint8_t *)(GetEPRxAddr(ENDP0) * 2); // *2 for 32 bits addr

	if (pInformation->ControlState != PAUSE) {
		pInformation->USBbmRequestType = *pBuf.b++; // bmRequestType
		pInformation->USBbRequest = *pBuf.b++; // bRequest
		pBuf.w += offset;  // word not accessed because of 32 bits addressing
		pInformation->USBwValue = ByteSwap(*pBuf.w++); // wValue
		pBuf.w += offset;  // word not accessed because of 32 bits addressing
		pInformation->USBwIndex  = ByteSwap(*pBuf.w++); // wIndex
		pBuf.w += offset;  // word not accessed because of 32 bits addressing
		pInformation->USBwLength = *pBuf.w; // wLength
	}
	pInformation->ControlState = SETTING_UP;
	if (pInformation->USBwLength == 0) {
		// Setup with no data stage
		NoData_Setup0();
	} else {
		// Setup with data stage
		Data_Setup0();
	}

	return Post0_Process();
}
Example #3
0
/*******************************************************************************
* Function Name  : Setup0_Process
* Description    : Get the device request data and dispatch to individual process.
* Input          : None.
* Output         : None.
* Return         : Post0_Process.
*******************************************************************************/
uint8_t Setup0_Process(void)
{

  union
  {
    uint8_t* b;
    uint16_t* w;
  } pBuf;

#ifdef STM32F10X_CL
  USB_OTG_EP *ep;
  uint16_t offset = 0;
 
  ep = PCD_GetOutEP(ENDP0);
  pBuf.b = ep->xfer_buff;
  
  OTGD_FS_EP0StartXfer(ep);
#else  
  uint16_t offset = 1;
  
  pBuf.b = PMAAddr + (uint8_t *)(_GetEPRxAddr(ENDP0) * 2); /* *2 for 32 bits addr */
#endif /* STM32F10X_CL */

  if (pInformation->ControlState != PAUSE)
  {
    pInformation->USBbmRequestType = *pBuf.b++; /* bmRequestType */
    pInformation->USBbRequest = *pBuf.b++; /* bRequest */
    pBuf.w += offset;  /* word not accessed because of 32 bits addressing */
    pInformation->USBwValue = ByteSwap(*pBuf.w++); /* wValue */
    pBuf.w += offset;  /* word not accessed because of 32 bits addressing */
    pInformation->USBwIndex  = ByteSwap(*pBuf.w++); /* wIndex */
    pBuf.w += offset;  /* word not accessed because of 32 bits addressing */
    pInformation->USBwLength = *pBuf.w; /* wLength */
  }

  pInformation->ControlState = SETTING_UP;
  if (pInformation->USBwLength == 0)
  {
    /* Setup with no data stage */
    NoData_Setup0();
  }
  else
  {
    /* Setup with data stage */
    Data_Setup0();
  }
  return Post0_Process();
}