vusbd11st.c 3 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: vusbd11.c
***
*** Comments:      
***   This file contains the low-level VUSB1.1 routines.
***                                                               
**************************************************************************
*END*********************************************************************/
#ifdef __USB_OS_MQX__
#include "mqx.h"
#include "bsp.h"
#else
#include "devapi.h"
#include "usb.h"
#include "vusb11.h"
#endif
#include "usbprv.h"
#include "usbdprv.h"

/*FUNCTION*----------------------------------------------------------------
* 
* Function Name  : _usb_dci_vusb11_get_endpoint_status
* Returned Value : None
* Comments       :
*     Gets the endpoint status
* 
*END*--------------------------------------------------------------------*/
uint_8 _usb_dci_vusb11_get_endpoint_status
   (
      /* [IN] Handle to the USB device */
      _usb_device_handle handle,
      
      /* [IN] Endpoint to get */
      uint_8             ep
   )
{ /* Body */
   USB_DEV_STATE_STRUCT_PTR usb_dev_ptr;
   
   usb_dev_ptr = (USB_DEV_STATE_STRUCT_PTR)handle;
   
   return ((usb_dev_ptr->ENDPT_REGS[ep] & VUSB_EP_CTRL_STALL) ? 1 : 0);
} /* EndBody */

/*FUNCTION*----------------------------------------------------------------
* 
* Function Name  : _usb_dci_vusb11_set_endpoint_status
* Returned Value : None
* Comments       :
*     Sets the endpoint registers e.g. to enable TX, RX, control
* 
*END*--------------------------------------------------------------------*/
void _usb_dci_vusb11_set_endpoint_status
   (
      /* [IN] Handle to the USB device */
      _usb_device_handle handle,
      
      /* [IN] Endpoint to set */
      uint_8             ep,
      
      /* [IN] Endpoint characteristics */
      uint_8             stall
   )
{
      USB_DEV_STATE_STRUCT_PTR usb_dev_ptr;
      
      usb_dev_ptr = (USB_DEV_STATE_STRUCT_PTR)handle;

      if (stall) {
         /* the CTL byte is updated */
         usb_dev_ptr->XDSEND[ep].CTL |= VUSB_EP_CTRL_STALL;
         usb_dev_ptr->XDRECV[ep].CTL |= VUSB_EP_CTRL_STALL;
         usb_dev_ptr->ENDPT_REGS[ep] |= VUSB_EP_CTRL_STALL;
      } else {
         /* the CTL byte is updated */
         usb_dev_ptr->XDSEND[ep].CTL &= ~VUSB_EP_CTRL_STALL;
         usb_dev_ptr->XDRECV[ep].CTL &= ~VUSB_EP_CTRL_STALL;
         usb_dev_ptr->ENDPT_REGS[ep] &= ~VUSB_EP_CTRL_STALL;
      } /* Endif */      
      
} /* Endif */

/* EOF */