Changed per-device controller preprocessor checks over to per-device series for better device control.
Fixed error in Endpoint.c using HSOFI rather than SOFI for counting elapsed milliseconds.
This commit is contained in:
		
							parent
							
								
									9798440ca4
								
							
						
					
					
						commit
						4d3a594f3e
					
				
					 21 changed files with 77 additions and 65 deletions
				
			
		| 
						 | 
				
			
			@ -179,8 +179,8 @@ static void USB_Device_GetDescriptor(void)
 | 
			
		|||
	void*    DescriptorPointer;
 | 
			
		||||
	uint16_t DescriptorSize;
 | 
			
		||||
	
 | 
			
		||||
	if ((DescriptorSize = CALLBACK_USB_GetDescriptor(USB_ControlRequest.wValue,
 | 
			
		||||
	                                                 USB_ControlRequest.wIndex, &DescriptorPointer)) == NO_DESCRIPTOR)
 | 
			
		||||
	if ((DescriptorSize = CALLBACK_USB_GetDescriptor(USB_ControlRequest.wValue, USB_ControlRequest.wIndex,
 | 
			
		||||
	                                                 &DescriptorPointer)) == NO_DESCRIPTOR)
 | 
			
		||||
	{
 | 
			
		||||
		return;
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			@ -209,7 +209,7 @@ static void USB_Device_GetDescriptor(void)
 | 
			
		|||
		while (USB_ControlRequest.wLength && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))
 | 
			
		||||
		{
 | 
			
		||||
			#if defined (USE_EEPROM_DESCRIPTORS)
 | 
			
		||||
			Endpoint_Write_Byte(eeprom_read_byte(DescriptorPointer++));			
 | 
			
		||||
			Endpoint_Write_Byte(eeprom_read_byte(DescriptorPointer++));		
 | 
			
		||||
			#else
 | 
			
		||||
			Endpoint_Write_Byte(pgm_read_byte(DescriptorPointer++));
 | 
			
		||||
			#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -48,9 +48,14 @@
 | 
			
		|||
		#include "../HighLevel/StdDescriptors.h"
 | 
			
		||||
		#include "Endpoint.h"
 | 
			
		||||
 | 
			
		||||
	/* Preprocessor Checks: */
 | 
			
		||||
		#if (defined(USE_RAM_DESCRIPTORS) && defined(USE_EEPROM_DESCRIPTORS))
 | 
			
		||||
			#error USE_RAM_DESCRIPTORS and USE_EEPROM_DESCRIPTORS are mutually exclusive.
 | 
			
		||||
		#endif
 | 
			
		||||
			
 | 
			
		||||
	/* Public Interface - May be used in end-application: */
 | 
			
		||||
		/* Macros: */
 | 
			
		||||
			#if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER) || defined(__DOXYGEN__)
 | 
			
		||||
			#if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)
 | 
			
		||||
				/** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the
 | 
			
		||||
				 *  USB interface should be initialized in low speed (1.5Mb/s) mode.
 | 
			
		||||
				 *
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -98,9 +98,9 @@ uint8_t Endpoint_WaitUntilReady(void)
 | 
			
		|||
		else if (Endpoint_IsStalled())
 | 
			
		||||
		  return ENDPOINT_READYWAIT_EndpointStalled;
 | 
			
		||||
			  
 | 
			
		||||
		if (USB_INT_HasOccurred(USB_INT_HSOFI))
 | 
			
		||||
		if (USB_INT_HasOccurred(USB_INT_SOFI))
 | 
			
		||||
		{
 | 
			
		||||
			USB_INT_Clear(USB_INT_HSOFI);
 | 
			
		||||
			USB_INT_Clear(USB_INT_SOFI);
 | 
			
		||||
 | 
			
		||||
			if (!(TimeoutMSRem--))
 | 
			
		||||
			  return ENDPOINT_READYWAIT_Timeout;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -128,7 +128,7 @@
 | 
			
		|||
			#define ENDPOINT_DOUBLEBANK_SUPPORTED(n)      _ENDPOINT_GET_DOUBLEBANK(n)
 | 
			
		||||
 | 
			
		||||
			#if !defined(CONTROL_ONLY_DEVICE)
 | 
			
		||||
				#if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER) || defined(__DOXYGEN__)
 | 
			
		||||
				#if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)
 | 
			
		||||
					/** Total number of endpoints (including the default control endpoint at address 0) which may
 | 
			
		||||
					 *  be used in the device. Different USB AVR models support different amounts of endpoints,
 | 
			
		||||
					 *  this value reflects the maximum number of endpoints for the currently selected AVR model.
 | 
			
		||||
| 
						 | 
				
			
			@ -316,7 +316,7 @@
 | 
			
		|||
				 */
 | 
			
		||||
				static inline uint8_t Endpoint_GetEndpointDirection(void);
 | 
			
		||||
			#else
 | 
			
		||||
				#if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER) || defined(__DOXYGEN__)
 | 
			
		||||
				#if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)
 | 
			
		||||
					#define Endpoint_BytesInEndpoint()        UEBCX
 | 
			
		||||
				#else
 | 
			
		||||
					#define Endpoint_BytesInEndpoint()        UEBCLX
 | 
			
		||||
| 
						 | 
				
			
			@ -933,7 +933,7 @@
 | 
			
		|||
			#define _ENDPOINT_GET_DOUBLEBANK2(details)     _ENDPOINT_GET_DOUBLEBANK3(details)
 | 
			
		||||
			#define _ENDPOINT_GET_DOUBLEBANK3(maxsize, db) db
 | 
			
		||||
			
 | 
			
		||||
			#if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER)
 | 
			
		||||
			#if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
 | 
			
		||||
				#define ENDPOINT_DETAILS_EP0               64,  true
 | 
			
		||||
				#define ENDPOINT_DETAILS_EP1               256, true
 | 
			
		||||
				#define ENDPOINT_DETAILS_EP2               64,  true
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -68,7 +68,7 @@ void USB_Init(
 | 
			
		|||
	USB_ControlPipeSize = PIPE_CONTROLPIPE_DEFAULT_SIZE;
 | 
			
		||||
	#endif
 | 
			
		||||
	
 | 
			
		||||
	#if defined(USB_DEVICE_ONLY) && defined(USB_FULL_CONTROLLER)
 | 
			
		||||
	#if defined(USB_DEVICE_ONLY) && (defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
 | 
			
		||||
	UHWCON |= (1 << UIMOD);
 | 
			
		||||
	#elif defined(USB_HOST_ONLY)
 | 
			
		||||
	UHWCON &= ~(1 << UIMOD);
 | 
			
		||||
| 
						 | 
				
			
			@ -99,7 +99,7 @@ void USB_Init(
 | 
			
		|||
	
 | 
			
		||||
	USB_ResetInterface();
 | 
			
		||||
 | 
			
		||||
	#if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER)
 | 
			
		||||
	#if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
 | 
			
		||||
	USB_OTGPAD_On();
 | 
			
		||||
	#endif
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -136,7 +136,7 @@ void USB_ShutDown(void)
 | 
			
		|||
	USB_Interface_Disable();
 | 
			
		||||
	USB_PLL_Off();
 | 
			
		||||
	
 | 
			
		||||
	#if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER)
 | 
			
		||||
	#if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
 | 
			
		||||
	USB_OTGPAD_Off();
 | 
			
		||||
	#endif
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -165,7 +165,7 @@ void USB_ResetInterface(void)
 | 
			
		|||
	
 | 
			
		||||
	if (!(USB_Options & USB_OPT_MANUAL_PLL))
 | 
			
		||||
	{
 | 
			
		||||
		#if defined(USB_MODIFIED_FULL_CONTROLLER)
 | 
			
		||||
		#if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
 | 
			
		||||
		PLLFRQ = ((1 << PLLUSB) | (1 << PDIV3) | (1 << PDIV1));
 | 
			
		||||
		#endif
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -189,7 +189,7 @@ void USB_ResetInterface(void)
 | 
			
		|||
	
 | 
			
		||||
	USB_CLK_Unfreeze();
 | 
			
		||||
 | 
			
		||||
	#if (defined(USB_CAN_BE_DEVICE) && (defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER)))
 | 
			
		||||
	#if (defined(USB_CAN_BE_DEVICE) && (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)))
 | 
			
		||||
	if (USB_CurrentMode == USB_MODE_DEVICE)
 | 
			
		||||
	{
 | 
			
		||||
		if (USB_Options & USB_DEVICE_OPT_LOWSPEED)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -77,22 +77,22 @@
 | 
			
		|||
		#if (F_CLOCK == 8000000)
 | 
			
		||||
			#if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__))
 | 
			
		||||
				#define USB_PLL_PSC                0
 | 
			
		||||
			#elif (defined(__AVR_AT90USB646__)  || defined(__AVR_AT90USB647__)  || \
 | 
			
		||||
			       defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__) || \
 | 
			
		||||
				   defined(__AVR_ATmega32U6__))
 | 
			
		||||
				#define USB_PLL_PSC                ((1 << PLLP1) | (1 << PLLP0))
 | 
			
		||||
			#elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
 | 
			
		||||
				#define USB_PLL_PSC                0
 | 
			
		||||
			#elif (defined(__AVR_AT90USB646__)  || defined(__AVR_AT90USB1286__) || defined(__AVR_ATmega32U6__))
 | 
			
		||||
				#define USB_PLL_PSC                ((1 << PLLP1) | (1 << PLLP0))
 | 
			
		||||
			#elif (defined(__AVR_AT90USB647__)  || defined(__AVR_AT90USB1287__))
 | 
			
		||||
				#define USB_PLL_PSC                ((1 << PLLP1) | (1 << PLLP0))
 | 
			
		||||
			#endif
 | 
			
		||||
		#elif (F_CLOCK == 16000000)
 | 
			
		||||
			#if (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_ATmega32U6__))
 | 
			
		||||
				#define USB_PLL_PSC                ((1 << PLLP2) | (1 << PLLP1))
 | 
			
		||||
			#elif (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__))
 | 
			
		||||
				#define USB_PLL_PSC                ((1 << PLLP2) | (1 << PLLP0))
 | 
			
		||||
			#elif (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__))
 | 
			
		||||
			#if (defined(__AVR_AT90USB82__) || defined(__AVR_AT90USB162__))
 | 
			
		||||
				#define USB_PLL_PSC                (1 << PLLP0)
 | 
			
		||||
			#elif (defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__))
 | 
			
		||||
				#define USB_PLL_PSC                (1 << PINDIV)
 | 
			
		||||
			#elif (defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB647__) || defined(__AVR_ATmega32U6__))
 | 
			
		||||
				#define USB_PLL_PSC                ((1 << PLLP2) | (1 << PLLP1))
 | 
			
		||||
			#elif (defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1287__))
 | 
			
		||||
				#define USB_PLL_PSC                ((1 << PLLP2) | (1 << PLLP0))
 | 
			
		||||
			#endif
 | 
			
		||||
		#endif
 | 
			
		||||
		
 | 
			
		||||
| 
						 | 
				
			
			@ -107,11 +107,13 @@
 | 
			
		|||
			 */
 | 
			
		||||
			#define USB_MODE_NONE                      0
 | 
			
		||||
 | 
			
		||||
			/** Mode mask for the \ref USB_CurrentMode global and the \ref USB_Init() function. This indicates that the
 | 
			
		||||
			 *  USB interface is or should be initialized in the USB device mode.
 | 
			
		||||
			 */
 | 
			
		||||
			#define USB_MODE_DEVICE                    1
 | 
			
		||||
 | 
			
		||||
			#if defined(USB_CAN_BE_DEVICE) || defined(__DOXYGEN__)
 | 
			
		||||
				/** Mode mask for the \ref USB_CurrentMode global and the \ref USB_Init() function. This indicates that the
 | 
			
		||||
				 *  USB interface is or should be initialized in the USB device mode.
 | 
			
		||||
				 */
 | 
			
		||||
				#define USB_MODE_DEVICE                    1
 | 
			
		||||
			#endif
 | 
			
		||||
			
 | 
			
		||||
			#if defined(USB_CAN_BE_HOST) || defined(__DOXYGEN__)
 | 
			
		||||
				/** Mode mask for the \ref USB_CurrentMode global and the \ref USB_Init() function. This indicates that the
 | 
			
		||||
				 *  USB interface is or should be initialized in the USB host mode.
 | 
			
		||||
| 
						 | 
				
			
			@ -181,7 +183,7 @@
 | 
			
		|||
			 */
 | 
			
		||||
			#define EP_TYPE_INTERRUPT                  0x03
 | 
			
		||||
 | 
			
		||||
			#if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER) || defined(__DOXYGEN__)
 | 
			
		||||
			#if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)
 | 
			
		||||
				/** Returns boolean true if the VBUS line is currently high (i.e. the USB host is supplying power),
 | 
			
		||||
				 *  otherwise returns false.
 | 
			
		||||
				 *
 | 
			
		||||
| 
						 | 
				
			
			@ -320,7 +322,7 @@
 | 
			
		|||
			#define USB_PLL_Off()              MACROS{ PLLCSR   =  0;                           }MACROE
 | 
			
		||||
			#define USB_PLL_IsReady()                ((PLLCSR  &   (1 << PLOCK)) ? true : false)
 | 
			
		||||
 | 
			
		||||
			#if defined(USB_FULL_CONTROLLER) || defined(USB_MODIFIED_FULL_CONTROLLER)		
 | 
			
		||||
			#if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
 | 
			
		||||
				#define USB_REG_On()           MACROS{ UHWCON  |=  (1 << UVREGE);               }MACROE
 | 
			
		||||
				#define USB_REG_Off()          MACROS{ UHWCON  &= ~(1 << UVREGE);               }MACROE
 | 
			
		||||
			#else
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue