Exemple #1
0
/** Main program entry point. This routine configures the hardware required by the application, then
 *  starts the scheduler to run the USB management task.
 */
int main(void)
{
	SetupHardware();
	
	LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);

	for (;;)
	{
		Main_Task();
		USB_USBTask();
	}
}
/*FUNCTION*----------------------------------------------------------------
*
* Function Name  : main
* Returned Value : none
* Comments       :
*     Execution starts here
*
*END*--------------------------------------------------------------------*/
void main() 
{
    /* Body */
    USB_STATUS           status = USB_OK;
    _usb_host_handle     host_handle;
    uint_32 i;
    /* Initialize the current platform. Call for the _bsp_platform_init which is specific to each processor family */
    _bsp_platform_init();
    GPIO_Init();

    /* Protect bootloader area (sector 0 to sector 3)*/
#ifdef  __MCF52259_H__ 
	#ifdef __DEBUG__
		MCF_CFM_CFMPROT = 0x0F;
	#else
		MCF_CFM_CFMPROT = 0x07;
	#endif
#elif defined(MCU_MK60N512VMD100)
         FTFL_FPROT3 = 0xF0; 
#endif /* End __MCF52259_H__ */

#ifdef __DEBUG__
    sci1_init();
#endif
    
    for(i=0;i<=2000;i++);
    Switch_mode();                /* check for bootloader mode */ 
    TimerInit();
    POLL_init();                  /* Init polling global variable */
    
    SetOutput(BSP_LED1, FALSE);
    SetOutput(BSP_LED2, FALSE);
    
    DisableInterrupts; 
#if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
    usb_int_dis();
#endif  
    status = _usb_host_init
             (HOST_CONTROLLER_NUMBER,    /* Use value in header file */
             MAX_FRAME_SIZE,             /* Frame size per USB spec  */
             &host_handle);              /* Returned pointer */

    if (status != USB_OK) {
#ifdef __DEBUG__
        printf("\nUSB Host Initialization failed. STATUS: %x", status);
#endif
    }

    /*
    ** Since we are going to act as the host driver, register
    ** the driver information for wanted class/subclass/protocols
    */
    status = _usb_host_driver_info_register(host_handle, (void*)DriverInfoTable);
    if (status != USB_OK) {
#ifdef __DEBUG__
        printf("\nDriver Registration failed. STATUS: %x", status);
#endif
    } 
    EnableInterrupts;
#if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
    usb_int_en();
#endif
    /* Run bootloader mode */
#ifdef __DEBUG__
    printf("\n****************************************************************************\n\r");
    printf("*                              Bootloader mode                             *\n\r");
    printf("****************************************************************************\n\r"); 
    printf("\nUSB stick boot loader\n\rWaiting for USB mass storage to be attached...\n\r");
#endif
    for(;;) {
        Main_Task();
        Poll();
        __RESET_WATCHDOG(); /* feeds the dog */
    } /* loop forever */
    /* please make sure that you never leave main */
} /* EndBody */
Exemple #3
0
void main(void) 
#endif
{
  USB_STATUS           status = USB_OK;
  _usb_host_handle     host_handle;

  /* Initialize the current platform. Call for the _bsp_platform_init which is specific to each processor family */
  _bsp_platform_init();
#ifdef MCU_MK70F12
  sci2_init();
#else
  sci1_init();
#endif
    
  TimerInit();
  
  /* Init polling global variable */
  POLL_init(); 

  DisableInterrupts;
  #if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
  usb_int_dis();
  #endif  
  status = _usb_host_init
    (HOST_CONTROLLER_NUMBER,    /* Use value in header file */
     MAX_FRAME_SIZE,            /* Frame size per USB spec  */
     &host_handle);             /* Returned pointer */

  if (status != USB_OK) 
  {
    printf("\nUSB Host Initialization failed. STATUS: 0x%x", (unsigned int) status);    
  } /* Endif */

   /*
   ** Since we are going to act as the host driver, register
   ** the driver information for wanted class/subclass/protocols
   */
  status = _usb_host_driver_info_register(host_handle, (void *)DriverInfoTable);
  if (status != USB_OK) 
  {
     printf("\nDriver Registration failed. STATUS: 0x%x", (unsigned int)status);      
  }
   
  EnableInterrupts;
  #if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
  usb_int_en();
  #endif
   
  pCmd.CBW_PTR = (CBW_STRUCT_PTR)USB_mem_alloc_word_aligned(sizeof(CBW_STRUCT));  
  if (pCmd.CBW_PTR == NULL)
  {
     printf ("\nUnable to allocate Command Block Wrapper!");     
  }
  memset(pCmd.CBW_PTR, 0, sizeof(CBW_STRUCT));
   
  pCmd.CSW_PTR = (CSW_STRUCT_PTR)USB_mem_alloc_word_aligned(sizeof(CSW_STRUCT));   
  if (pCmd.CSW_PTR == NULL)
  {
     printf ("\nUnable to allocate Command Status Wrapper!");     
  }    
  memset(pCmd.CSW_PTR, 0, sizeof(CSW_STRUCT));
  
  printf("\nUSB MSD Command test\nWaiting for USB mass storage to be attached...\n");

  for(;;) 
  {
    Main_Task();
    Poll();
    __RESET_WATCHDOG(); /* feeds the dog */
  } /* loop forever */
  /* please make sure that you never leave main */
#ifdef __GNUC__
   return 0;
#endif
}