Added new USB_Host_GetDeviceConfiguration() and USB_Host_GetInterfaceAltSetting() functions.
This commit is contained in:
		
							parent
							
								
									7f8dbb4908
								
							
						
					
					
						commit
						e915d968a5
					
				
					 5 changed files with 71 additions and 11 deletions
				
			
		| 
						 | 
				
			
			@ -112,15 +112,15 @@
 | 
			
		|||
				 *  identical name (in which case the weak reference is discarded at link time).
 | 
			
		||||
				 */
 | 
			
		||||
				#define ATTR_WEAK                   __attribute__ ((weak))
 | 
			
		||||
 | 
			
		||||
				/** Forces the compiler to not automatically zero the given global variable on startup, so that the
 | 
			
		||||
				 *  current RAM contents is retained. Under most conditions this value will be random due to the
 | 
			
		||||
				 *  behaviour of volatile memory once power is removed, but may be used in some specific circumstances,
 | 
			
		||||
				 *  like the passing of values back after a system watchdog reset.
 | 
			
		||||
				 */
 | 
			
		||||
				#define ATTR_NO_INIT                __attribute__ ((section (".noinit")))
 | 
			
		||||
			#endif
 | 
			
		||||
 | 
			
		||||
			/** Forces the compiler to not automatically zero the given global variable on startup, so that the
 | 
			
		||||
			 *  current RAM contents is retained. Under most conditions this value will be random due to the
 | 
			
		||||
			 *  behaviour of volatile memory once power is removed, but may be used in some specific circumstances,
 | 
			
		||||
			 *  like the passing of values back after a system watchdog reset.
 | 
			
		||||
			 */
 | 
			
		||||
			#define ATTR_NO_INIT                    __attribute__ ((section (".noinit")))
 | 
			
		||||
 | 
			
		||||
			/** Places the function in one of the initialization sections, which execute before the main function
 | 
			
		||||
			 *  of the application. Refer to the avr-libc manual for more information on the initialization sections.
 | 
			
		||||
			 *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,6 +13,7 @@
 | 
			
		|||
  *   - Added support for the new B series XMEGA devices
 | 
			
		||||
  *   - Added support for version 2 of the Teensy boards (thanks to Christoph Redecker)
 | 
			
		||||
  *   - Added new Android Accessory Host class driver
 | 
			
		||||
  *   - Added new USB_Host_GetDeviceConfiguration() and USB_Host_GetInterfaceAltSetting() functions
 | 
			
		||||
  *  - Library Applications:
 | 
			
		||||
  *   - Added User Application APIs to the CDC and DFU class bootloaders
 | 
			
		||||
  *   - Added INVERTED_ISP_MISO compile time option to the AVRISP-MKII clone project (thanks to Chuck Rohs)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -24,8 +24,6 @@
 | 
			
		|||
  *      -# Abstract out Mass Storage byte send/receive to prevent low level API use in projects
 | 
			
		||||
  *      -# Consider switch from endpoint numbers to full endpoint addresses to ease future architecture expansion
 | 
			
		||||
  *      -# Fix HID report parser usage support for array types
 | 
			
		||||
  *      -# Add additional standard request helper functions to host mode
 | 
			
		||||
  *      -# Add Dataflash_SendCommand()
 | 
			
		||||
  *      -# Make HOST_DEVICE_SETTLE_DELAY_MS a global variable that can be changed
 | 
			
		||||
  *      -# Add MANDATORY_EVENT_FUNCTIONS compile time option
 | 
			
		||||
  *      -# Add watchdog support to the library and apps/bootloaders
 | 
			
		||||
| 
						 | 
				
			
			@ -40,7 +38,6 @@
 | 
			
		|||
  *      -# Add class driver support for Test and Measurement class
 | 
			
		||||
  *      -# Add class driver support for EEM class
 | 
			
		||||
  *      -# Add class driver support for ECM class
 | 
			
		||||
  *      -# Add class driver support for the Android Accessory Host class
 | 
			
		||||
  *      -# Port all demos to multiple architectures
 | 
			
		||||
  *  - Ports
 | 
			
		||||
  *      -# Finish USB XMEGA port
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -211,6 +211,22 @@ uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber)
 | 
			
		|||
	return ErrorCode;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint8_t USB_Host_GetDeviceConfiguration(uint8_t* const ConfigNumber)
 | 
			
		||||
{
 | 
			
		||||
	USB_ControlRequest = (USB_Request_Header_t)
 | 
			
		||||
		{
 | 
			
		||||
			.bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),
 | 
			
		||||
			.bRequest      = REQ_GetConfiguration,
 | 
			
		||||
			.wValue        = 0,
 | 
			
		||||
			.wIndex        = 0,
 | 
			
		||||
			.wLength       = sizeof(uint8_t),
 | 
			
		||||
		};
 | 
			
		||||
 | 
			
		||||
	Pipe_SelectPipe(PIPE_CONTROLPIPE);
 | 
			
		||||
 | 
			
		||||
	return USB_Host_SendControlRequest(ConfigNumber);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint8_t USB_Host_GetDeviceDescriptor(void* const DeviceDescriptorPtr)
 | 
			
		||||
{
 | 
			
		||||
	USB_ControlRequest = (USB_Request_Header_t)
 | 
			
		||||
| 
						 | 
				
			
			@ -235,7 +251,7 @@ uint8_t USB_Host_GetDeviceStringDescriptor(const uint8_t Index,
 | 
			
		|||
		{
 | 
			
		||||
			.bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),
 | 
			
		||||
			.bRequest      = REQ_GetDescriptor,
 | 
			
		||||
			.wValue        = (DTYPE_String << 8) | Index,
 | 
			
		||||
			.wValue        = ((DTYPE_String << 8) | Index),
 | 
			
		||||
			.wIndex        = 0,
 | 
			
		||||
			.wLength       = BufferLength,
 | 
			
		||||
		};
 | 
			
		||||
| 
						 | 
				
			
			@ -294,5 +310,22 @@ uint8_t USB_Host_SetInterfaceAltSetting(const uint8_t InterfaceIndex,
 | 
			
		|||
	return USB_Host_SendControlRequest(NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
uint8_t USB_Host_GetInterfaceAltSetting(const uint8_t InterfaceIndex,
 | 
			
		||||
                                        uint8_t* const AltSetting)
 | 
			
		||||
{
 | 
			
		||||
	USB_ControlRequest = (USB_Request_Header_t)
 | 
			
		||||
		{
 | 
			
		||||
			.bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE),
 | 
			
		||||
			.bRequest      = REQ_GetInterface,
 | 
			
		||||
			.wValue        = 0,
 | 
			
		||||
			.wIndex        = InterfaceIndex,
 | 
			
		||||
			.wLength       = sizeof(uint8_t),
 | 
			
		||||
		};
 | 
			
		||||
 | 
			
		||||
	Pipe_SelectPipe(PIPE_CONTROLPIPE);
 | 
			
		||||
 | 
			
		||||
	return USB_Host_SendControlRequest(AltSetting);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -130,6 +130,19 @@
 | 
			
		|||
			 *  \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.
 | 
			
		||||
			 */
 | 
			
		||||
			uint8_t USB_Host_SetDeviceConfiguration(const uint8_t ConfigNumber);
 | 
			
		||||
			
 | 
			
		||||
			/** Sends a GET CONFIGURATION standard request to the attached device, to retrieve the currently selected
 | 
			
		||||
			 *  device configuration index.
 | 
			
		||||
			 *
 | 
			
		||||
			 *  \note After this routine returns, the control pipe will be selected.
 | 
			
		||||
			 *
 | 
			
		||||
			 *  \ingroup Group_PipeControlReq
 | 
			
		||||
			 *
 | 
			
		||||
			 *  \param[out] ConfigNumber  Pointer to a location where the retrieved configuration index should be stored.
 | 
			
		||||
			 *
 | 
			
		||||
			 *  \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.
 | 
			
		||||
			 */
 | 
			
		||||
			uint8_t USB_Host_GetDeviceConfiguration(uint8_t* const ConfigNumber) ATTR_NON_NULL_PTR_ARG(1);
 | 
			
		||||
 | 
			
		||||
			/** Sends a GET DESCRIPTOR standard request to the attached device, requesting the device descriptor.
 | 
			
		||||
			 *  This can be used to easily retrieve information about the device such as its VID, PID and power
 | 
			
		||||
| 
						 | 
				
			
			@ -206,6 +219,22 @@
 | 
			
		|||
			uint8_t USB_Host_SetInterfaceAltSetting(const uint8_t InterfaceIndex,
 | 
			
		||||
													const uint8_t AltSetting);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
			/** Retrieves the current alternative setting for the specified interface, via a GET INTERFACE standard request to
 | 
			
		||||
			 *  the attached device.
 | 
			
		||||
			 *
 | 
			
		||||
			 *  \note After this routine returns, the control pipe will be selected.
 | 
			
		||||
			 *
 | 
			
		||||
			 *  \ingroup Group_PipeControlReq
 | 
			
		||||
			 *
 | 
			
		||||
			 *  \param[in]  InterfaceIndex  Index of the interface whose alternative setting is to be altered.
 | 
			
		||||
			 *  \param[out] AltSetting      Pointer to a location where the retrieved alternative setting value should be stored.
 | 
			
		||||
			 *
 | 
			
		||||
			 *  \return A value from the \ref USB_Host_SendControlErrorCodes_t enum to indicate the result.
 | 
			
		||||
			 */
 | 
			
		||||
			uint8_t USB_Host_GetInterfaceAltSetting(const uint8_t InterfaceIndex,
 | 
			
		||||
			                                        uint8_t* const AltSetting) ATTR_NON_NULL_PTR_ARG(2);
 | 
			
		||||
										
 | 
			
		||||
	/* Private Interface - For use in library only: */
 | 
			
		||||
	#if !defined(__DOXYGEN__)
 | 
			
		||||
		/* Enums: */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue