Example #1
0
void CDC_Init(void)
{
	uint_8   error;
    g_send_size = 0;
    
  	// Create USB semaphore
  	if (OSSemCreate(0,&USB_Sem) != ALLOC_EVENT_OK)
    {
        while(1){};
    };
  	
  	// Cria uma fila de recepcao para a porta serial
  	if (OSQueueCreate(CONSOLE_BUFFER_SIZE, &USB) != ALLOC_EVENT_OK)
  	{
  		while(1){};
  	};	    
    
    UserEnterCritical();	
    #if (defined _MCF51MM256_H) || (defined _MCF51JE256_H) || (defined _MCF51JE128_H)
     usb_int_dis();
    #endif
    
    /* Initialize the USB interface */
    SCGC2 |= SCGC2_USB_MASK;     /* Enables usb clock */
    
    error = USB_Class_CDC_Init(CONTROLLER_ID,USB_App_Callback,
                                NULL,USB_Notify_Callback);
    //if(error != USB_OK)
    /* Error initializing USB-CDC Class */
    
    UserExitCritical();
	#if (defined _MCF51MM256_H) || (defined _MCF51JE256_H) || (defined _MCF51JE128_H)
     usb_int_en();
    #endif
}
Example #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
}
Example #3
0
void TestApp_Init(void)
{
    uint_8   error;
    
    DisableInterrupts;
#if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
    usb_int_dis();
#endif
    
#if !(defined _MC9S08JS16_H)
#if (defined MCU_mcf51jf128)
    sci1_init();
#else
    sci_init();
#endif
#endif /* _MC9S08JS16_H */
    
#if  ((defined __MCF52xxx_H__) || (defined __MK_xxx_H__))
    pit1_init();
#elif (defined _MC9S08JM60_H) || (defined _MC9S08JM16_H) || (defined _MC9S08JS16_H)
    rtc_init();
#elif (defined MCU_mcf51jf128)
    ftm0_init();
#else
    cmt_init();
#endif
    
    pwm_init();
    /* Initialize the USB interface */
    error = USB_Class_Audio_Init(CONTROLLER_ID,USB_App_Callback,
                                 NULL,NULL);
    UNUSED(error);
    
    EnableInterrupts;
#if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
    usb_int_en();
#endif
}
Example #4
0
void TestApp_Init(void)
{
    uint_8   error;

    g_recv_size = 0;
    g_send_size= 0;
    DisableInterrupts;		
    #if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
     usb_int_dis();
    #endif
    /* Initialize the USB interface */
    error = USB_Class_CDC_Init(CONTROLLER_ID,USB_App_Callback,
                                NULL,USB_Notify_Callback, TRUE);
    if(error != USB_OK)
    {
        /* Error initializing USB-CDC Class */
        return;
    }
    EnableInterrupts;
	#if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
     usb_int_en();
    #endif
}
/*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 */
Example #6
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
}
Example #7
0
void main(void) {
  
  extern uint32 __VECTOR_RAM[];           //Get vector table that was copied to RAM
  static USB_STATUS status = USB_OK;
 

  printf("Main OK\n\r");

  /*******************************************/
  /* NVIC Configuration */
    __VECTOR_RAM[89]=(uint_32)USB_ISR;      //replace ISR
    NVICICER2|=(1<<9);                     //Clear any pending interrupts on USB
    NVICISER2|=(1<<9);                     //Enable interrupts from USB module  
  /*******************************************/


    // Disable Watchdog
    //__UNLOCK_WATCHDOG();
    //WDOG_ST_CTRL_H = 0x0;


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

  //sci1_init();

  //TimerInit();

  printf("Timer Init OK\n\r");
  
  DisableInterrupts;  
  #if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
  usb_int_dis();
  #endif 
  //status = _usb_host_driver_install(0, (pointer2)&_bsp_usb_host_callback_table);


  status = _usb_host_init(HOST_CONTROLLER_NUMBER, /* Use value in header file */
        MAX_FRAME_SIZE,         /* Frame size per USB spec  */
       &host_handle);          /* Returned pointer2 */
  /*
   ** since we are going to act as the host driver, register the driver
   ** information for wanted class/subclass/protocols
   */

  printf("USB HOST Init OK\n\r");
  
  
  status = _usb_host_driver_info_register(host_handle, (void*)DriverInfoTable);
  if(status != USB_OK) {         
      exit(1);
  }
  _usb_event_init(&USB_Event);  
  EnableInterrupts;
  #if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
  usb_int_en();
  #endif   
  printf("\nUSB HID Mouse\nWaiting for USB Mouse to be attached...\n");
  ////fflush(stdout);
  
  for(;;) {
    
    Mouse_Task(main_buffer,&main_hid_com);     
    _usb_khci_task();   
    __RESET_WATCHDOG(); /* feeds the dog */
  } /* loop forever */
  /* please make sure that you never leave main */
}
Example #8
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
}
Example #9
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
}