Example #1
0
/*FUNCTION*----------------------------------------------------------------
 *
 * Function Name  : usb_class_audio_endpoint_command
 * Returned Value : USB_OK if command has been passed on USB
 * Comments       :
 *     This function is called by the application to performs services
 *      for endpoint
 *END*--------------------------------------------------------------------*/
usb_status usb_class_audio_endpoint_command
(
/* [IN] Class Interface structure void*  */
audio_command_t* com_ptr,

/* [IN] Buffer to receive data */
void* buf,
/* [IN] The command to perform */
uint32_t cmd
)
{
    uint8_t Endp_num;
    audio_stream_struct_t* if_ptr;
    usb_status status = USBERR_ERROR;
    uint16_t request_value;
    usb_audio_command_t* p_endpoint_command;

    if_ptr = (audio_stream_struct_t*)com_ptr->class_stream_handle;

    /* pointer to command */
    p_endpoint_command = &(usb_audio_endpoint_commands[cmd]);
    /* get request value */
    request_value = (uint16_t)((uint16_t)((uint16_t)p_endpoint_command->request_value << 8));

    /* Check whether this attribute valid or not */
    status = check_valid_ep(if_ptr->iso_endp_spec_desc,p_endpoint_command->control_mask);

    if (USB_OK == status)
    {
        /* Any isochronous pipe is supported? */
        if ((NULL == if_ptr->iso_in_pipe) && (NULL == if_ptr->iso_out_pipe))
        {
            return USBERR_INVALID_NUM_OF_ENDPOINTS;
        }
        else if (NULL!=if_ptr->iso_in_pipe)
        {

            Endp_num = (if_ptr->iso_ep_num | 0x80);
        }
        else
        {
            Endp_num = if_ptr->iso_ep_num;
        }/* Endif */

        status = usb_class_audio_cntrl_common(com_ptr,
        p_endpoint_command->request_type,
        p_endpoint_command->request_code,
        request_value,
        (uint16_t)Endp_num,
        p_endpoint_command->length,
        (uint8_t *)buf);
    }

    return status;
}
/*FUNCTION*----------------------------------------------------------------
*
* Function Name  : usb_class_audio_endpoint_command
* Returned Value : USB_OK if command has been passed on USB
* Comments       :
*     This function is called by the application to performs services
*      for endpoint
*END*--------------------------------------------------------------------*/
USB_STATUS usb_class_audio_endpoint_command
(
    /* [IN] Class Interface structure pointer */
    AUDIO_COMMAND_PTR            com_ptr,

    /* [IN] Buffer to receive data */
    void                        *buf,
    /* [IN] The command to perform */
    uint32_t                      cmd
)
{
    uint8_t Endp_num;
    AUDIO_STREAM_INTERFACE_STRUCT_PTR     if_ptr;
    USB_STATUS status = USBERR_ERROR;
    uint16_t request_value;
    USB_AUDIO_COMMAND_PTR p_endpoint_command;

    if_ptr = (AUDIO_STREAM_INTERFACE_STRUCT_PTR)com_ptr->CLASS_PTR->class_intf_handle;
    
    /* pointer to command */
    p_endpoint_command = &(usb_audio_endpoint_commands[cmd]);
    /* get request value */
    request_value     = (uint16_t)((p_endpoint_command->request_value << 8));
    
    /* Check whether this attribute valid or not */
    status = check_valid_ep(if_ptr->iso_endp_spec_desc,p_endpoint_command->control_mask);

    if (USB_OK == status)
    {
        /* Any isochronous pipe is supported? */
        if ((NULL == if_ptr->iso_in_pipe) && (NULL == if_ptr->iso_out_pipe))
        {
            return USBERR_INVALID_NUM_OF_ENDPOINTS;
        }
        else if (NULL!=if_ptr->iso_in_pipe)
        {
            Endp_num = (if_ptr->iso_in_pipe->ENDPOINT_NUMBER | 0x80);
        }
        else
        {
            Endp_num = if_ptr->iso_out_pipe->ENDPOINT_NUMBER;
        }/* Endif */

        status = usb_class_audio_cntrl_common(com_ptr,
                                              p_endpoint_command->request_type,
                                              p_endpoint_command->request_code,
                                              request_value,
                                              (uint16_t)Endp_num,
                                              p_endpoint_command->length,
                                              buf);
    }

    return status;
}