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 */ }
/*FUNCTION*---------------------------------------------------------------- * * Function Name : OTG_App_Periodic_Task * Returned Value : none * Comments : * * *END*--------------------------------------------------------------------*/ void OTG_App_Periodic_Task() { uint32_t otg_app_event_value; #if (OS_ADAPTER_ACTIVE_OS == OS_ADAPTER_MQX) OS_Event_wait(g_otg_app_event_handle,~((uint32_t)0), FALSE, 200); #endif otg_app_event_value = OS_Event_get_value(g_otg_app_event_handle); if (otg_app_event_value) { App_Print_Event(otg_app_event_value); OTG_App_Load_Unload_Task(otg_app_event_value); } App_HandleUserInput(); }