Пример #1
0
void main(void) 
#endif
{
    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();
    #ifdef MCU_MK70F12
        sci2_init();
    #else
        sci1_init();
    #endif
    TimerInit();
    
    /* Init polling global variable */
    POLL_init();
    DisableInterrupts;
    
    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);
        fflush(stdout);
        exit(1);
    }
    
    /*
    ** 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("\nUSB Initialization driver info failed! STATUS: 0x%x", status);
        fflush(stdout);      
        exit(1);
    }
    EnableInterrupts;

    printf("\nUSB Printer Host Demo\nWaiting for USB printer to be attached...\n");
    fflush(stdout);
    
    for(;;) 
    {
        Poll();
        Printer_Task(NULL);
        __RESET_WATCHDOG(); /* feeds the dog */
    } /* Loop forever */
    /* Please make sure that you never leave main */
#ifdef __GNUC__
return 0;
#endif
}
Пример #2
0
void main(void)
#endif
{       
    /* 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();

    /* event for USB callback signaling */
    _usb_event_init(&USB_Event);   
  
    DisableInterrupts; 
    #if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
    usb_int_dis();
    #endif	
    ApplicationInit();
	EnableInterrupts;
    #if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
    usb_int_en();
    #endif		
    
    fflush(stdout);
	
	/*
     ** Infinite loop, waiting for events requiring action
     */
    for(;;) 
    {
      Poll();
      Main_App_Task();
      __RESET_WATCHDOG(); /* feeds the dog */
    }  
#ifdef __GNUC__
    return 0;
#endif
}
Пример #3
0
/*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 */
Пример #4
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
}
Пример #5
0
void main_usb(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();
#if 0 /* << EST */
#ifdef MCU_MK70F12
  sci2_init();
#else
  sci1_init();
#endif
   TimerInit();
#endif
   
   /* Init polling global variable */
   POLL_init(); 

   DisableInterrupts;
   #if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
   usb_int_dis();
   #endif	   
   /*
   ** It means that we are going to act like host, so we initialize the
   ** host stack. This call will allow USB system to allocate memory for
   ** data structures, it uses later (e.g pipes etc.).
   */
   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) 
   {
#if 0 /* << EST */
      printf("\nUSB Host Initialization failed. STATUS: %%x",(unsigned int) status);
      fflush(stdout);
#endif
      exit(3);
   }
   status = _usb_host_driver_info_register (
                                    host_handle,
                                    (void *)DriverInfoTable
                                    );
   if (status != USB_OK) 
   {
#if 0 /* << EST */
     printf("\nDriver Registration failed. STATUS: %%x", (unsigned int)status);
      fflush(stdout);
#endif
      exit(4);
   }    
  
  EnableInterrupts;
  #if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
  usb_int_en();
  #endif	  

#if 0 /* << EST */
  printf("\fInitialization passed. Plug-in CDC device to USB port.\nUse ttyb: as the in/out port for CDC device data.\n");
#endif  
  _usb_event_init(&device_registered);
  uart2usb_num = usb2uart_num = 0; /* reset number of bytes in buffers */

#if 0 /* << EST */
  f_usb = (FILE_CDC_PTR)malloc(sizeof(FILE_CDC));
  memset(f_usb, 0, sizeof(FILE_CDC));
#else
  f_usb = (FILE_CDC_PTR)USB_mem_alloc_zero(sizeof(FILE_CDC));
#endif
    
  f_usb->DEV_PTR = (IO_DEVICE_STRUCT_PTR)USB_mem_alloc_word_aligned(sizeof(IO_DEVICE_STRUCT));
  
  for(;;) 
  {
    Poll(); 
    CDC_Task();
#if 0 /* << EST */
    __RESET_WATCHDOG(); /* feeds the dog */
#endif
  } /* loop forever */
  /* please make sure that you never leave main */
#ifdef __GNUC__
  return 0;
#endif
}
Пример #6
0
void main(void) 
#endif
{
   USB_STATUS           status = USB_OK;
   _usb_host_handle     host_handle;
   boolean send = TRUE;
   
   /* 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(); 
    
#if (defined(_MCF51MM256_H) || (defined _MCF51JE256_H))
   cmt_init();
   Mcu_Init();
   Kbi_Init();
   pwm_init();
#endif

#if (defined(__MCF52259_H__) || (defined (__MCF52221_H__)) ||(defined (_MK_xxx_H_)) )
   	GPIO_Init();
   	pit0_init();
   	pwm_init();
#endif

#if (defined MCU_mcf51jf128)
   	GPIO_Init();
   	mtim_init();
   	pwm_init();
#endif
   DisableInterrupts;
   #if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
   usb_int_dis();
   #endif	   
   /*
   ** It means that we are going to act like host, so we initialize the
   ** host stack. This call will allow USB system to allocate memory for
   ** data structures, it uses later (e.g pipes etc.).
   */
   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);
	   fflush(stdout);
	   exit(3);
   }
   status = _usb_host_driver_info_register (
                                    host_handle,
                                    (pointer)DriverInfoTable
                                    );
	if (status != USB_OK) 
	{
		printf("\nDriver Registration failed! STATUS: 0x%x",(unsigned int) status);
		fflush(stdout);
		exit(4);
   }    
  
  EnableInterrupts;
  #if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
  usb_int_en();
  #endif	  

  printf("USB Host Audio Demo\r\nWaitting for USB Audio Device to be attached...\r\n");
 
 _usb_event_init(&USB_Event);
 
	for(;;)
	{
    Poll(); 
    Audio_Task();
    __RESET_WATCHDOG(); /* feeds the dog */
  } /* loop forever */
  /* please make sure that you never leave main */
#ifdef __GNUC__
return 0;
#endif
}