Пример #1
0
void main(void)
{
  USB_STATUS      status = USB_OK;

   
   /* Initialize the current platform. Call for the _bsp_platform_init which is specific to each processor family */
   _bsp_platform_init();
   sci1_init();
   sci2_init();
   IIC_ModuleInit();
   TimerInit();    

   DisableInterrupts;   
	/* enable interrupt OTG module */	           
	 Int_Ctl_int_init(IRQ3_INT_CNTL, IRQ3_ISR_SRC, 2,2, TRUE); 
	 MCF_EPORT_EPPAR   |= MCF_EPORT_EPPAR_EPPA3_FALLING; /* falling edge */
	 MCF_EPORT_EPDDR	&= ~MCF_EPORT_EPDDR_EPDD3; /* set input*/
	 MCF_EPORT_EPIER   |= MCF_EPORT_EPIER_EPIE3;	/* enable interrupts IRQ 3 */  
	  /* set VHost pin ( PUC3) */	 
	 
	 MCF_GPIO_DDRUC  |= MCF_GPIO_DDRUC_DDRUC3; /* set output */
	 MCF_GPIO_PUCPAR  |= MCF_GPIO_PUCPAR_UCTS2_GPIO; /* set as GPIO */
	 ENABLE_USB_5V;
   status = _usb_otg_init(0, (OTG_INIT_STRUCT*)&otg_init, &otg_handle);
   if(status == USB_OK)
   {   
	   status = _usb_otg_register_callback(otg_handle, App_OtgCallback);
   }	   
 	
   EnableInterrupts;
   #if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
   usb_int_en();
   #endif	  

   printf("\n\rInitialization passed. Plug-in MSD device to USB port");
   printf("\n\rPress P to print the menu:");
   
   for(;;) 
   {      
     _usb_otg_task();
	 
	   if(dev_stack_active)
	   {	      
       App_PeripheralTask();
	   }
	   if(host_stack_active)
	   {
	     App_Host_Task();
	   }
      
      App_HandleUserInput();
      __RESET_WATCHDOG(); /* feeds the dog */     
      
      
  } /* loop forever */
  /* please make sure that you never leave main */
}
Пример #2
0
/*FUNCTION*----------------------------------------------------------------
*
* Function Name  : OTG_App_Init
* Returned Value : none
* Comments       :
*
*
*END*--------------------------------------------------------------------*/
void OTG_App_Init()
{
    /* Initialize the current platform. Call for the _bsp_platform_init which is specific to each processor family */
    OS_Lock();
    g_otg_handle  = NULL;
    g_otg_state = 0;
    g_dev_type = dev_b;
    g_sess_vld = FALSE;
    g_vbus_err = FALSE;

    g_otg_app_event_handle = OS_Event_create(0);
    printf("\n\r otg module is initilalizing:");
    _usb_otg_init(USBCFG_DEFAULT_OTG_CONTROLLER, (otg_int_struct_t *)&g_otg_init, &g_otg_handle);
    printf("\n\rPress P to print the menu:");
    OS_Unlock();
}