3      Copyright (C) Dean Camera, 2009. 
   5   dean [at] fourwalledcubicle [dot] com 
   6       www.fourwalledcubicle.com 
  10   Copyright 2009  Dean Camera (dean [at] fourwalledcubicle [dot] com) 
  12   Permission to use, copy, modify, and distribute this software 
  13   and its documentation for any purpose and without fee is hereby 
  14   granted, provided that the above copyright notice appear in all 
  15   copies and that both that the copyright notice and this 
  16   permission notice and warranty disclaimer appear in supporting 
  17   documentation, and that the name of the author not be used in 
  18   advertising or publicity pertaining to distribution of the 
  19   software without specific, written prior permission. 
  21   The author disclaim all warranties with regard to this 
  22   software, including all implied warranties of merchantability 
  23   and fitness.  In no event shall the author be liable for any 
  24   special, indirect or consequential damages or any damages 
  25   whatsoever resulting from loss of use, data or profits, whether 
  26   in an action of contract, negligence or other tortious action, 
  27   arising out of or in connection with the use or performance of 
  33  *  Module for host mode request processing. This module allows for the transmission of standard, class and 
  34  *  vendor control requests to the default control endpoint of an attached device while in host mode. 
  36  *  \see Chapter 9 of the USB 2.0 specification. 
  39 #ifndef __HOSTCHAPTER9_H__ 
  40 #define __HOSTCHAPTER9_H__ 
  47                 #include "../HighLevel/USBMode.h" 
  48                 #include "../HighLevel/StdRequestType.h" 
  50         /* Enable C linkage for C++ Compilers: */ 
  51                 #if defined(__cplusplus) 
  55         /* Public Interface - May be used in end-application: */ 
  57                         /** Type define for a standard USB control request. 
  59                          *  \see StdRequestType.h for information on the request type and data. 
  60                          *  \see The USB 2.0 specification for more information on standard control requests. 
  64                                 uint8_t  bmRequestType
; /**< Type of the request. */ 
  65                                 uint8_t  bRequest
; /**< Request command code. */ 
  66                                 uint16_t wValue
; /**< wValue parameter of the request. */ 
  67                                 uint16_t wIndex
; /**< wIndex parameter of the request. */ 
  68                                 uint16_t wLength
; /**< Length of the data to transfer in bytes. */ 
  69                         } USB_Host_Request_Header_t
; 
  72                         /** Enum for the USB_Host_SendControlRequest() return code, indicating the reason for the error 
  73                          *  if the transfer of the request is unsuccessful. 
  75                         enum USB_Host_SendControlErrorCodes_t
 
  77                                 HOST_SENDCONTROL_Successful       
= 0, /**< No error occurred in the request transfer. */ 
  78                                 HOST_SENDCONTROL_DeviceDisconnect 
= 1, /**< The attached device was disconnected during the 
  81                                 HOST_SENDCONTROL_PipeError        
= 2, /**< An error occurred in the pipe while sending the request. */ 
  82                                 HOST_SENDCONTROL_SetupStalled     
= 3, /**< The attached device stalled the request, usually 
  83                                                                         *   indicating that the request is unsupported on the device. 
  85                                 HOST_SENDCONTROL_SoftwareTimeOut  
= 4, /**< The request or data transfer timed out. */ 
  88                 /* Global Variables: */ 
  89                         /** Global for the request to send via the USB_Host_SendControlRequest() function. This 
  90                          *  global should be filled with the correct control request data before sending the request to 
  91                          *  the attached device while in host mode. 
  93                         extern USB_Host_Request_Header_t USB_HostRequest
; 
  95                 /* Function Prototypes: */ 
  96                         /** Sends the request stored in the USB_HostRequest global structure to the attached device, 
  97                          *  and transfers the data stored in the buffer to the device, or from the device to the buffer 
 100                          *  \param BufferPtr  Pointer to the start of the data buffer if the request has a data stage, or 
 101                          *                    NULL if the request transfers no data to or from the device. 
 103                          *  \return A value from the USB_Host_SendControlErrorCodes_t enum to indicate the result. 
 105                         uint8_t USB_Host_SendControlRequest(void* BufferPtr
); 
 107         /* Private Interface - For use in library only: */ 
 108         #if !defined(__DOXYGEN__) 
 110                         enum USB_WaitForTypes_t
 
 112                                 USB_HOST_WAITFOR_SetupSent
, 
 113                                 USB_HOST_WAITFOR_InReceived
, 
 114                                 USB_HOST_WAITFOR_OutReady
, 
 117                 /* Function Prototypes: */ 
 118                         #if defined(INCLUDE_FROM_HOSTCHAPTER9_C) 
 119                                 static uint8_t USB_Host_Wait_For_Setup_IOS(const uint8_t WaitType
); 
 123         /* Disable C linkage for C++ Compilers: */ 
 124                 #if defined(__cplusplus)