Пример #1
0
/******************************************************************************
*
*   @name        TestApp_Init
*
*   @brief       This function is the entry for the Audio generator application
*
*   @param       None
*
*   @return      None
*****************************************************************************
* This function starts the audio generator application
*****************************************************************************/
void TestApp_Init(void)
{
    uint_8   error;

    /* Disable interrupts */
    DisableInterrupts;
    
    /* Initialize the USB interface */
    error = USB_Class_Audio_Init(CONTROLLER_ID,USB_App_Callback,NULL,NULL);
    
    /* Enable interrupts */
    EnableInterrupts;
}
Пример #2
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
}
Пример #3
0
 /**************************************************************************//*!
 *
 * @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;   
}
Пример #4
0
void TestApp_Init(void)
{
   AUDIO_CONFIG_STRUCT       audio_config;
   USB_CLASS_AUDIO_ENDPOINT  * endPoint_ptr;

   /* Pointer to audio endpoint entry */  
   endPoint_ptr = USB_mem_alloc_zero(sizeof(USB_CLASS_AUDIO_ENDPOINT)*AUDIO_DESC_ENDPOINT_COUNT);
   /* USB descriptor endpoint */
   audio_config.usb_ep_data = &usb_desc_ep;
   /* USB audio unit */
   audio_config.usb_ut_data = &usb_audio_unit;
   /* Endpoint count */
   audio_config.desc_endpoint_cnt = AUDIO_DESC_ENDPOINT_COUNT;
   /* Application callback */
   audio_config.audio_class_callback.callback = USB_App_Callback;
   /* Application callback argurment */
   audio_config.audio_class_callback.arg = &g_app_handle;
   /* Vendor callback */
   audio_config.vendor_req_callback.callback = NULL;
   /* Vendor callback argurment */
   audio_config.vendor_req_callback.arg = NULL;
   /* Param callback function */
   audio_config.param_callback.callback = USB_Notif_Callback;
   /* Param callback argurment */
   audio_config.param_callback.arg = &g_app_handle;
   /* Memory param callback */
   audio_config.mem_param_callback.callback = NULL;
   /* Memory param callback argurment */
   audio_config.mem_param_callback.arg = &g_app_handle;
   /* Descriptor callback pointer */
   audio_config.desc_callback_ptr =  &desc_callback;
   /* Audio enpoint pointer */
   audio_config.ep = endPoint_ptr;

   /* Initialize timer module */
//   audio_timer_init();

//   _audio_timer_init_freq(AUDIO_TIMER, AUDIO_TIMER_CHANNEL, AUDIO_SPEAKER_FREQUENCY, AUDIO_TIMER_CLOCK, TRUE);

    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_Audio_Init(&audio_config);

   if (MQX_OK != _lwevent_create(&app_event, LWEVENT_AUTO_CLEAR)) {
      printf("\n_lwevent_create app_event failed.\n");
      _task_block();
   }
   
   if (MQX_OK != _lwevent_wait_ticks(&app_event, USB_APP_ENUM_COMPLETE_EVENT_MASK, FALSE, 0)) {
      printf("\n_lwevent_wait_ticks app_event failed.\n");
      _task_block();
   }
   
   if (MQX_OK != _lwevent_clear(&app_event, USB_APP_ENUM_COMPLETE_EVENT_MASK)) {
      printf("\n_lwevent_clear app_event failed.\n");
      _task_block();
   }
   printf("Audio speaker is working ... \r\n");
   /* Prepare buffer for first isochronous input */
   USB_Class_Audio_Recv_Data(g_app_handle,AUDIO_ISOCHRONOUS_ENDPOINT,
                  audio_data_buff0, DATA_BUFF_SIZE);

   _task_block();   
}