Beispiel #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
}
Beispiel #2
0
/*
** ===================================================================
**     Method      :  CDC1_Init (component FSL_USB_CDC_Device)
**     Description :
**         Initializes the driver
**     Parameters  : None
**     Returns     :
**         ---             - Error code
** ===================================================================
*/
byte CDC1_Init(void)
{
  uint_8 err;

  err = USB_Class_CDC_Init(CONTROLLER_ID, CDC1_App_Callback, NULL, CDC1_Notify_Callback, TRUE);
  if(err != USB_OK) {
    /* Error initializing USB-CDC Class */
    return ERR_FAILED;
  }
  return ERR_OK;
}
Beispiel #3
0
/*****************************************************************************
 *  
 *    @name         APP_init
 * 
 *    @brief         This function do initialization for APP.
 * 
 *    @param         None
 * 
 *    @return       None
 **                  
 *****************************************************************************/
void APP_init(void)
{
    cdc_config_struct_t cdc_config;
    cdc_config.cdc_application_callback.callback = USB_App_Device_Callback;
    cdc_config.cdc_application_callback.arg = &g_app_handle;
    cdc_config.vendor_req_callback.callback = NULL;
    cdc_config.vendor_req_callback.arg = NULL;
    cdc_config.class_specific_callback.callback = USB_App_Class_Callback;
    cdc_config.class_specific_callback.arg = &g_app_handle;
    cdc_config.board_init_callback.callback = usb_device_board_init;
    cdc_config.board_init_callback.arg = CONTROLLER_ID;
    cdc_config.desc_callback_ptr = &desc_callback;
    /* Always happen in control endpoint hence hard coded in Class layer*/
    
    g_cdc_device_speed = USB_SPEED_FULL;
    g_bulk_out_max_packet_size = FS_DIC_BULK_OUT_ENDP_PACKET_SIZE;
    g_bulk_in_max_packet_size = FS_DIC_BULK_IN_ENDP_PACKET_SIZE;
    /* Initialize the USB interface */
    USB_Class_CDC_Init(CONTROLLER_ID, &cdc_config, &g_app_handle);
    g_recv_size = 0;
    g_send_size = 0;
#if USBCFG_DEV_KEEP_ALIVE_MODE
#if (OS_ADAPTER_ACTIVE_OS == OS_ADAPTER_SDK)
    uint32_t powerModeAmount=sizeof(powerConfigs)/
    sizeof(power_manager_user_config_t *);

    vlprConfig.mode = kPowerManagerVlpr;
    //vlprConfig.policy = kPowerManagerPolicyAgreement;

    vlprConfig.sleepOnExitValue = false;

    vlpwConfig = vlprConfig;
    vlpwConfig.mode = kPowerManagerVlpw;

    vlpsConfig = vlprConfig;
    vlpsConfig.mode = kPowerManagerVlps;

    stopConfig = vlprConfig;
    stopConfig.mode = kPowerManagerStop;

    POWER_SYS_Init((power_manager_user_config_t const ** )&powerConfigs, powerModeAmount, NULL, 1U);
#if(defined FRDM_KL27Z)
    PORTA_PCR4 = 0;
    PORTA_PCR13 = 0;
    PORTB_PCR18 = 0;
    PORTB_PCR19 = 0;
    PORTC_PCR1 = 0;
    PORTC_PCR2 = 0;
    PORTC_PCR3 = 0;
#endif
#endif
#endif    
}
Beispiel #4
0
 /*****************************************************************************
 *  
 *   @name        TestApp_Init
 * 
 *   @brief       This function is the entry for mouse (or other usuage)
 * 
 *   @param       None
 * 
 *   @return      None
 **                
 *****************************************************************************/
void TestApp_Init(void)
{       
    //uint_8   error;
    CDC_CONFIG_STRUCT cdc_config;
    USB_CLASS_CDC_ENDPOINT * endPoint_ptr;
    
    g_curr_recv_buf = _mem_alloc_uncached(DATA_BUFF_SIZE);
    g_curr_send_buf = _mem_alloc_uncached(DATA_BUFF_SIZE);
    
    endPoint_ptr = USB_mem_alloc_zero(sizeof(USB_CLASS_CDC_ENDPOINT)*CDC_DESC_ENDPOINT_COUNT);
    cdc_config.comm_feature_data_size = COMM_FEATURE_DATA_SIZE;
    cdc_config.usb_ep_data = &usb_desc_ep;
    cdc_config.desc_endpoint_cnt = CDC_DESC_ENDPOINT_COUNT;
    cdc_config.cdc_class_cb.callback = USB_App_Callback;
    cdc_config.cdc_class_cb.arg = &g_app_handle;
    cdc_config.vendor_req_callback.callback = NULL;
    cdc_config.vendor_req_callback.arg = NULL;
    cdc_config.param_callback.callback = USB_Notif_Callback;
    cdc_config.param_callback.arg = &g_app_handle;
    cdc_config.desc_callback_ptr =  &desc_callback;
    cdc_config.ep = endPoint_ptr;
    cdc_config.cic_send_endpoint = CIC_NOTIF_ENDPOINT;
    /* Always happend in control endpoint hence hard coded in Class layer*/
    //cdc_config.cic_recv_endpoint = 
    cdc_config.dic_send_endpoint = DIC_BULK_IN_ENDPOINT;
    cdc_config.dic_recv_endpoint = DIC_BULK_OUT_ENDPOINT;
    
    if (MQX_OK != _usb_device_driver_install(USBCFG_DEFAULT_DEVICE_CONTROLLER)) {
        printf("Driver could not be installed\n");
        return;
    }

    /* Initialize the USB interface */
    g_app_handle = USB_Class_CDC_Init(&cdc_config);
    g_recv_size = 0;
    g_send_size= 0;    
  
    while (TRUE) 
    {
        /* call the periodic task function */      
        USB_CDC_Periodic_Task();           

       /*check whether enumeration is complete or not */
        if((start_app==TRUE) && (start_transactions==TRUE))
        {        
            Virtual_Com_App(); 
        }            
    }/* Endwhile */   
} 
Beispiel #5
0
/*
** ===================================================================
**     Method      :  CDC1_Init (component FSL_USB_CDC_Device)
**     Description :
**         Initializes the driver
**     Parameters  : None
**     Returns     :
**         ---             - Error code
** ===================================================================
*/
uint8_t CDC1_Init(void)
{
  uint_8 err;

  start_app = FALSE;
  start_transactions = FALSE;
  transactionOngoing = FALSE;
  Rx1_Init();
  Tx1_Init();
  err = USB_Class_CDC_Init(CONTROLLER_ID, CDC1_App_Callback, NULL, CDC1_Notify_Callback, TRUE);
  if(err != USB_OK) {
    /* Error initializing USB-CDC Class */
    return ERR_FAILED;
  }
  return ERR_OK;
}
Beispiel #6
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
}
 /**************************************************************************//*!
 *
 * @name  USB_Composite_Init
 *
 * @brief   The funtion initializes the Device and Controller layer
 *
 * @param   controller_ID               : Controller ID
 * @param   composite_callback_ptr      : Pointer to app callback  
 *
 * @return status:
 *                        USB_OK        : When Successfull
 *                        Others        : When Error
 *
 ******************************************************************************
 *This function initializes the Composite layer
 *****************************************************************************/ 
uint_8 USB_Composite_Init(
    uint_8    controller_ID,                            /* [IN] Controller ID */
    COMPOSITE_CALLBACK_STRUCT * composite_callback_ptr   /* [IN] Pointer to class info */
)
{    
    uint_8 count,status;
    DEV_ARCHITECTURE_STRUCT_PTR dev_arc_ptr;
    CLASS_ARC_STRUCT_PTR dev_class_ptr;   
    
    /* Get device architecture */
    dev_arc_ptr = (DEV_ARCHITECTURE_STRUCT *)USB_Desc_Get_Class_Architecture(controller_ID);
    
    /* Device init */
    status = _usb_device_init(controller_ID, NULL,
        (uint_8)(dev_arc_ptr->ep_count+1), TRUE);
        
    if(status == USB_OK)
    {
        /* Initialize the generic class functions */
        status = USB_Class_Init(controller_ID,USB_Composite_Event,
            USB_Composite_Other_Requests);
        if(status == USB_OK)
        {   
            for(count = 0; count < dev_arc_ptr->cl_count; count++)
            {
                dev_class_ptr = (CLASS_ARC_STRUCT_PTR)dev_arc_ptr->value[count];
                /* Initializes sub_classes */
                switch(dev_class_ptr->class_type)  
                {
#ifdef USE_HID_CLASS 
                    case HID_COMP_CC:
                        (void)USB_Class_HID_Init(
                            controller_ID,composite_callback_ptr->class_app_callback[count]->composite_class_callback,
                            composite_callback_ptr->class_app_callback[count]->vendor_req_callback,
                            composite_callback_ptr->class_app_callback[count]->param_specific_callback);   
                        break;
#endif
#ifdef USE_AUDIO_CLASS
                    case AUDIO_COMP_CC:
                        (void)USB_Class_Audio_Init(
                            controller_ID,composite_callback_ptr->class_app_callback[count]->composite_class_callback,
                            composite_callback_ptr->class_app_callback[count]->vendor_req_callback,
                            composite_callback_ptr->class_app_callback[count]->param_callback);   

                        break;
                    #endif
#ifdef USE_VIDEO_CLASS
                    case VIDEO_COMP_CC:
                        (void)USB_Class_Video_Init(
                            controller_ID,composite_callback_ptr->class_app_callback[count]->composite_class_callback,
                            composite_callback_ptr->class_app_callback[count]->vendor_req_callback,
                            composite_callback_ptr->class_app_callback[count]->param_callback);  

                        break;
#endif
#ifdef USE_CDC_CLASS
                    case CDC_COMP_CC:                            
                        (void)USB_Class_CDC_Init(
                            controller_ID,composite_callback_ptr->class_app_callback[count]->composite_class_callback,
                            composite_callback_ptr->class_app_callback[count]->vendor_req_callback,
                            composite_callback_ptr->class_app_callback[count]->param_callback, TRUE);      
                        break;
#endif
#ifdef USE_MSD_CLASS
                    case MSD_COMP_CC:
                        (void)USB_Class_MSC_Init(
                            controller_ID,composite_callback_ptr->class_app_callback[count]->composite_class_callback,
                            composite_callback_ptr->class_app_callback[count]->vendor_req_callback,
                            composite_callback_ptr->class_app_callback[count]->param_callback); 
                        break;
#endif
#ifdef USE_PHDC_CLASS
                    case PHDC_COMP_CC:
                        (void)USB_Class_PHDC_Init(
                            controller_ID,composite_callback_ptr->class_app_callback[count]->composite_class_callback,
                            composite_callback_ptr->class_app_callback[count]->vendor_req_callback); 
                        break;
#endif
#ifdef USE_DFU_CLASS
                    case DFU_COMP_CC:
                        (void)USB_Class_Dfu_Init(
                            controller_ID,composite_callback_ptr->class_app_callback[count]->composite_class_callback,
                            composite_callback_ptr->class_app_callback[count]->vendor_req_callback,
                            composite_callback_ptr->class_app_callback[count]->param_callback); 
                        break;
#endif
                    default:
                        break;
                }
            }
        }
    }
    return status;   
}