host_cnl.c 2.85 KB
/*HEADER******************************************************************
**************************************************************************
*** 
*** Copyright (c) 2001-2002 ARC International.
*** All rights reserved                                          
***                                                              
*** This software embodies materials and concepts which are      
*** confidential to ARC International and is made
*** available solely pursuant to the terms of a written license   
*** agreement with ARC International             
***
*** File: hostapi.c
***
*** Comments:      
***   This file contains the USB Host API specific functions.
***                                                               
**************************************************************************
*END*********************************************************************/
#ifdef __USB_OS_MQX__
#include "mqx.h"
#include "bsp.h"
#else
#include "types.h"
#include "vusb11.h"
#include "usb.h"
#include "hostapi.h"
#endif
#include "usbprv.h"
#include "usbhprv.h"

/*FUNCTION*-------------------------------------------------------------
*
*  Function Name  : _usb_host_cancel_transfer
*  Returned Value : error or status of the transfer before cancellation
*  Comments       :
* _usb_host_cancel_transfer is a non-blocking routine that causes a transfer to 
* be terminated. 
*
*END*-----------------------------------------------------------------*/
uint_8 _usb_host_cancel_transfer
   (
      /* [IN] the USB Host state structure */
      _usb_host_handle  handle,
      
      /* Index into the Pipe Descriptor Array */
      int_16            pipeid
   )
{ /* Body */
   uint_8  bRet;
   PIPE_DESCRIPTOR_STRUCT_PTR pipe_descr_ptr;   
   USB_HOST_STATE_STRUCT_PTR usb_host_ptr;
   
   usb_host_ptr = (USB_HOST_STATE_STRUCT_PTR)handle;

   /* Check if valid pipe id */
   if (pipeid < usb_host_ptr->MAX_PIPES) {
      pipe_descr_ptr = &usb_host_ptr->PIPE_DESCRIPTOR_BASE_PTR[pipeid];
   } else {
      return USBERR_INVALID_PIPE_ID;
   } /* Endif */   

   /* Get the current status */
   bRet = pipe_descr_ptr->STATUS;

#ifdef __USB_OS_MQX__   
   /* Cancel the transfer at low-level */
   ((USB_CALLBACK_FUNCTIONS_STRUCT_PTR)usb_host_ptr->CALLBACK_STRUCT_PTR)->\
      HOST_CANCEL(handle, pipe_descr_ptr);
#else
   _usb_hci_vusb11_cancel_transfer(handle, pipe_descr_ptr);
#endif

   /* Indicate that a transfer is not pending */
   pipe_descr_ptr->PACKETPENDING = FALSE;
   
   /* Indicate that the pipe is idle */
   pipe_descr_ptr->STATUS = USB_STATUS_IDLE;
   
   /* Update the head of the queue for a particular type */
   _usb_host_update_current_head(handle, pipe_descr_ptr->PIPETYPE);

   /* Return the status prior to the transfer cancellation */
   return bRet;
} /* Endbody */

/* EOF */