Exemplo n.º 1
0
/**
  * @brief  USBD_Init
  *         Initializes the device stack and load the class driver
  * @param  pdev: device instance
  * @param  class_cb: Class callback structure address
  * @param  usr_cb: User callback structure address
  * @retval None
  */
void USBD_Init(USB_CORE_HANDLE *pdev,
               USBD_DEVICE *pDevice,                  
               USBD_Class_cb_TypeDef *class_cb, 
               USBD_Usr_cb_TypeDef *usr_cb)
{
  /* Hardware Init */
  USB_BSP_Init(pdev);  
  
  USBD_DeInit(pdev);
  
  /*Register class and user callbacks */
  pdev->dev.class_cb = class_cb;
  pdev->dev.usr_cb = usr_cb;  
  pdev->dev.usr_device = pDevice;    
  
  /* Update the serial number string descriptor with the data from the unique ID*/
  Get_SerialNum();
  
  /* set USB DEVICE core params */
  DCD_Init(pdev);
  
  /* Upon Init call usr callback */
  pdev->dev.usr_cb->Init();
  
  /* Enable Interrupts */
  USB_BSP_EnableInterrupt(pdev);
  
  /* Enable the pull-up */
#ifdef INTERNAL_PULLUP
  DCD_DevConnect(pdev);
#else
 USB_BSP_DevConnect(pdev);
#endif
}
Exemplo n.º 2
0
/**
* @brief  USBD_Init
*         Initailizes the device stack and load the class driver
* @param  pdev: device instance
* @param  core_address: USB OTG core ID
* @param  class_cb: Class callback structure address
* @param  usr_cb: User callback structure address
* @retval None
*/
void USBD_Init(USB_OTG_CORE_HANDLE *pdev,
               USB_OTG_CORE_ID_TypeDef coreID,
               USBD_DEVICE *pDevice,
               USBD_Class_cb_TypeDef *class_cb,
               USBD_Usr_cb_TypeDef *usr_cb)
{
  /* Hardware Init */
  USB_OTG_BSP_Init(pdev);

  USBD_DeInit(pdev);

  /*Register class and user callbacks */
  pdev->dev.class_cb = class_cb;
  pdev->dev.usr_cb = usr_cb;
  pdev->dev.usr_device = pDevice;

  /* set USB OTG core params */
  DCD_Init(pdev , coreID);

  /* Upon Init call usr callback */
  pdev->dev.usr_cb->Init();

  /* Enable Interrupts */
  USB_OTG_BSP_EnableInterrupt(pdev);
}
Exemplo n.º 3
0
/*
 *  ======== MGR_Init ========
 *      Initialize MGR's private state, keeping a reference count on each call.
 */
bool MGR_Init(void)
{
	bool fRetval = true;
	bool fInitDCD = false;

	DBC_Require(cRefs >= 0);

	if (cRefs == 0) {

		/* Set the Trace mask */
		DBC_Assert(!MGR_DebugMask.flags);

		GT_create(&MGR_DebugMask, "MG");	/* "MG" for Manager */
		fInitDCD = DCD_Init();	/*  DCD Module */

		if (!fInitDCD) {
			fRetval = false;
			GT_0trace(MGR_DebugMask, GT_6CLASS,
				 "MGR_Init failed\n");
		}
	}

	if (fRetval)
		cRefs++;


	GT_1trace(MGR_DebugMask, GT_5CLASS,
		 "Entered MGR_Init, ref count:  0x%x\n", cRefs);
	DBC_Ensure((fRetval && (cRefs > 0)) || (!fRetval && (cRefs >= 0)));

	return fRetval;
}
Exemplo n.º 4
0
/**
* @brief  USBD_Init
*         Initailizes the device stack and load the class driver
* @param  pdev: device instance
* @param  core_address: USB OTG core ID
* @param  cb: callback structure address
* @retval None
*/
void USBD_Init(USB_OTG_CORE_HANDLE *pdev,
               USB_OTG_CORE_ID_TypeDef coreID,
               USBD_Device_cb_TypeDef *cb)
{
  //USB_OTG_BSP_Init(pdev);

  /*Register class and user callbacks */
  pdev->dev.cb = cb;

  /* set USB OTG core params */
  DCD_Init(pdev , coreID);

  /* Upon Init call usr callback */
  pdev->dev.cb->UsrInit();

  /* Enable Interrupts */
  //USB_OTG_BSP_EnableInterrupt(pdev);
}