Add double banking property to LUFA powered projects in the Projects directory. Add guards to macro parameters to ensure that formulas passed as parameters don't mess up the internal macro structure.
This commit is contained in:
		
							parent
							
								
									f7ab433c67
								
							
						
					
					
						commit
						f29fc1abc4
					
				
					 13 changed files with 60 additions and 48 deletions
				
			
		| 
						 | 
				
			
			@ -68,12 +68,12 @@
 | 
			
		|||
			/** Macro for calculating the baud value from a given baud rate when the U2X (double speed) bit is
 | 
			
		||||
			 *  not set.
 | 
			
		||||
			 */
 | 
			
		||||
			#define SERIAL_UBBRVAL(baud)    (((F_CPU / 16) / baud) - 1)
 | 
			
		||||
			#define SERIAL_UBBRVAL(baud)    (((F_CPU / 16) / (baud)) - 1)
 | 
			
		||||
 | 
			
		||||
			/** Macro for calculating the baud value from a given baud rate when the U2X (double speed) bit is
 | 
			
		||||
			 *  set.
 | 
			
		||||
			 */
 | 
			
		||||
			#define SERIAL_2X_UBBRVAL(baud) (((F_CPU / 8) / baud) - 1)
 | 
			
		||||
			#define SERIAL_2X_UBBRVAL(baud) (((F_CPU / 8) / (baud)) - 1)
 | 
			
		||||
 | 
			
		||||
		/* Pseudo-Function Macros: */
 | 
			
		||||
			#if defined(__DOXYGEN__)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -95,7 +95,7 @@ void HID_Device_ProcessControlRequest(USB_ClassInfo_HID_Device_t* const HIDInter
 | 
			
		|||
			{
 | 
			
		||||
				Endpoint_ClearSETUP();
 | 
			
		||||
 | 
			
		||||
				HIDInterfaceInfo->State.UsingReportProtocol = (USB_ControlRequest.wValue != 0x0000);
 | 
			
		||||
				HIDInterfaceInfo->State.UsingReportProtocol = ((USB_ControlRequest.wValue & 0xFF) != 0x00);
 | 
			
		||||
				
 | 
			
		||||
				Endpoint_ClearStatusStage();
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -97,7 +97,8 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo
 | 
			
		|||
			if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
 | 
			
		||||
			{							   
 | 
			
		||||
				Pipe_ConfigurePipe(CDCInterfaceInfo->Config.NotificationPipeNumber, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN,
 | 
			
		||||
								   EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE);
 | 
			
		||||
								   EndpointData->EndpointAddress, EndpointData->EndpointSize,
 | 
			
		||||
								   CDCInterfaceInfo->Config.NotificationPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
 | 
			
		||||
				CDCInterfaceInfo->State.NotificationPipeSize = EndpointData->EndpointSize;
 | 
			
		||||
 | 
			
		||||
				Pipe_SetInterruptPeriod(EndpointData->PollingIntervalMS);
 | 
			
		||||
| 
						 | 
				
			
			@ -110,7 +111,8 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo
 | 
			
		|||
			if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
 | 
			
		||||
			{
 | 
			
		||||
				Pipe_ConfigurePipe(CDCInterfaceInfo->Config.DataINPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_IN,
 | 
			
		||||
								   EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE);
 | 
			
		||||
								   EndpointData->EndpointAddress, EndpointData->EndpointSize, 
 | 
			
		||||
								   CDCInterfaceInfo->Config.DataINPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
 | 
			
		||||
				CDCInterfaceInfo->State.DataINPipeSize = EndpointData->EndpointSize;
 | 
			
		||||
 | 
			
		||||
				FoundEndpoints |= CDC_FOUND_DATAPIPE_IN;
 | 
			
		||||
| 
						 | 
				
			
			@ -118,7 +120,8 @@ uint8_t CDC_Host_ConfigurePipes(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo
 | 
			
		|||
			else
 | 
			
		||||
			{
 | 
			
		||||
				Pipe_ConfigurePipe(CDCInterfaceInfo->Config.DataOUTPipeNumber, EP_TYPE_BULK, PIPE_TOKEN_OUT,
 | 
			
		||||
								   EndpointData->EndpointAddress, EndpointData->EndpointSize, PIPE_BANK_SINGLE);
 | 
			
		||||
								   EndpointData->EndpointAddress, EndpointData->EndpointSize, 
 | 
			
		||||
								   CDCInterfaceInfo->Config.DataOUTPipeDoubleBank ? PIPE_BANK_DOUBLE : PIPE_BANK_SINGLE);
 | 
			
		||||
				CDCInterfaceInfo->State.DataOUTPipeSize = EndpointData->EndpointSize;
 | 
			
		||||
				
 | 
			
		||||
				FoundEndpoints |= CDC_FOUND_DATAPIPE_OUT;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -78,7 +78,7 @@
 | 
			
		|||
			 *  // Can now access elements of the configuration header struct using the -> indirection operator
 | 
			
		||||
			 *  \endcode
 | 
			
		||||
			 */
 | 
			
		||||
			#define DESCRIPTOR_PCAST(DescriptorPtr, Type) ((Type*)DescriptorPtr)
 | 
			
		||||
			#define DESCRIPTOR_PCAST(DescriptorPtr, Type) ((Type*)(DescriptorPtr))
 | 
			
		||||
 | 
			
		||||
			/** Casts a pointer to a descriptor inside the configuration descriptor into the given descriptor
 | 
			
		||||
			 *  type (as an actual struct instance rather than a pointer to a struct).
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -351,12 +351,12 @@
 | 
			
		|||
				#endif
 | 
			
		||||
				
 | 
			
		||||
				#if !defined(CONTROL_ONLY_DEVICE)
 | 
			
		||||
					#define Endpoint_SelectEndpoint(epnum)    MACROS{ UENUM = epnum; }MACROE
 | 
			
		||||
					#define Endpoint_SelectEndpoint(epnum)    MACROS{ UENUM = (epnum); }MACROE
 | 
			
		||||
				#else
 | 
			
		||||
					#define Endpoint_SelectEndpoint(epnum)    (void)epnum
 | 
			
		||||
				#endif
 | 
			
		||||
 | 
			
		||||
				#define Endpoint_ResetFIFO(epnum)             MACROS{ UERST = (1 << epnum); UERST = 0; }MACROE
 | 
			
		||||
				#define Endpoint_ResetFIFO(epnum)             MACROS{ UERST = (1 << (epnum)); UERST = 0; }MACROE
 | 
			
		||||
 | 
			
		||||
				#define Endpoint_EnableEndpoint()             MACROS{ UECONX |= (1 << EPEN); }MACROE
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -372,7 +372,7 @@
 | 
			
		|||
 | 
			
		||||
				#define Endpoint_GetEndpointInterrupts()      UEINT
 | 
			
		||||
 | 
			
		||||
				#define Endpoint_HasEndpointInterrupted(n)    ((UEINT & (1 << n)) ? true : false)
 | 
			
		||||
				#define Endpoint_HasEndpointInterrupted(n)    ((UEINT & (1 << (n))) ? true : false)
 | 
			
		||||
				
 | 
			
		||||
				#define Endpoint_IsINReady()                  ((UEINTX & (1 << TXINI))  ? true : false)
 | 
			
		||||
				
 | 
			
		||||
| 
						 | 
				
			
			@ -406,7 +406,7 @@
 | 
			
		|||
				
 | 
			
		||||
				#define Endpoint_GetEndpointDirection()       (UECFG0X & ENDPOINT_DIR_IN)
 | 
			
		||||
				
 | 
			
		||||
				#define Endpoint_SetEndpointDirection(dir)    MACROS{ UECFG0X = ((UECFG0X & ~ENDPOINT_DIR_IN) | dir); }MACROE
 | 
			
		||||
				#define Endpoint_SetEndpointDirection(dir)    MACROS{ UECFG0X = ((UECFG0X & ~ENDPOINT_DIR_IN) | (dir)); }MACROE
 | 
			
		||||
			#endif
 | 
			
		||||
 | 
			
		||||
		/* Enums: */
 | 
			
		||||
| 
						 | 
				
			
			@ -1179,11 +1179,11 @@
 | 
			
		|||
			#endif
 | 
			
		||||
 | 
			
		||||
			#define Endpoint_ConfigureEndpoint(Number, Type, Direction, Size, Banks)            \
 | 
			
		||||
			                                    Endpoint_ConfigureEndpoint_Prv(Number,          \
 | 
			
		||||
			                                              ((Type << EPTYPE0) | Direction),      \
 | 
			
		||||
			                                              ((1 << ALLOC) | Banks |               \
 | 
			
		||||
			                                    Endpoint_ConfigureEndpoint_Prv((Number),        \
 | 
			
		||||
			                                              (((Type) << EPTYPE0) | (Direction)),  \
 | 
			
		||||
			                                              ((1 << ALLOC) | (Banks) |             \
 | 
			
		||||
			                                                (__builtin_constant_p(Size) ?       \
 | 
			
		||||
			                                                 Endpoint_BytesToEPSizeMask(Size) :  \
 | 
			
		||||
			                                                 Endpoint_BytesToEPSizeMask(Size) : \
 | 
			
		||||
			                                                 Endpoint_BytesToEPSizeMaskDynamic(Size))))
 | 
			
		||||
													
 | 
			
		||||
		/* Function Prototypes: */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -366,7 +366,7 @@
 | 
			
		|||
			#define USB_Host_VBUS_Auto_Off()        MACROS{ OTGCON |=  (1 << VBUSRQC);        }MACROE
 | 
			
		||||
			#define USB_Host_VBUS_Manual_Off()      MACROS{ PORTE  &= ~(1 << 7);              }MACROE
 | 
			
		||||
 | 
			
		||||
			#define USB_Host_SetDeviceAddress(addr) MACROS{ UHADDR  =  (addr & 0x7F);         }MACROE
 | 
			
		||||
			#define USB_Host_SetDeviceAddress(addr) MACROS{ UHADDR  =  ((addr) & 0x7F);       }MACROE
 | 
			
		||||
 | 
			
		||||
		/* Enums: */
 | 
			
		||||
			enum USB_Host_WaitMSErrorCodes_t
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -118,7 +118,7 @@
 | 
			
		|||
				
 | 
			
		||||
				#define USB_OTG_Host_IsHNPReceived()              ((OTGCON &   (1 << HNPREQ)) ? true : false)
 | 
			
		||||
				
 | 
			
		||||
				#define USB_OTG_Device_InitiateSRP(type)    MACROS{ OTGCON = ((OTGCON & ~(1 << SRPSEL)) | (type | (1 << SRPREQ))); }MACROE
 | 
			
		||||
				#define USB_OTG_Device_InitiateSRP(type)    MACROS{ OTGCON = ((OTGCON & ~(1 << SRPSEL)) | ((type) | (1 << SRPREQ))); }MACROE
 | 
			
		||||
			#endif
 | 
			
		||||
	
 | 
			
		||||
#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -420,9 +420,9 @@
 | 
			
		|||
 | 
			
		||||
				#define Pipe_GetCurrentPipe()          (UPNUM & PIPE_PIPENUM_MASK)
 | 
			
		||||
 | 
			
		||||
				#define Pipe_SelectPipe(pipenum)       MACROS{ UPNUM = pipenum; }MACROE
 | 
			
		||||
				#define Pipe_SelectPipe(pipenum)       MACROS{ UPNUM = (pipenum); }MACROE
 | 
			
		||||
				
 | 
			
		||||
				#define Pipe_ResetPipe(pipenum)        MACROS{ UPRST = (1 << pipenum); UPRST = 0; }MACROE
 | 
			
		||||
				#define Pipe_ResetPipe(pipenum)        MACROS{ UPRST = (1 << (pipenum)); UPRST = 0; }MACROE
 | 
			
		||||
 | 
			
		||||
				#define Pipe_EnablePipe()              MACROS{ UPCONX |= (1 << PEN); }MACROE
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -432,21 +432,21 @@
 | 
			
		|||
 | 
			
		||||
				#define Pipe_GetPipeToken()            (UPCFG0X & PIPE_TOKEN_MASK)
 | 
			
		||||
 | 
			
		||||
				#define Pipe_SetToken(token)           MACROS{ UPCFG0X = ((UPCFG0X & ~PIPE_TOKEN_MASK) | token); }MACROE
 | 
			
		||||
				#define Pipe_SetToken(token)           MACROS{ UPCFG0X = ((UPCFG0X & ~PIPE_TOKEN_MASK) | (token)); }MACROE
 | 
			
		||||
				
 | 
			
		||||
				#define Pipe_SetInfiniteINRequests()   MACROS{ UPCONX |= (1 << INMODE); }MACROE
 | 
			
		||||
 | 
			
		||||
				#define Pipe_SetFiniteINRequests(n)    MACROS{ UPCONX &= ~(1 << INMODE); UPINRQX = n; }MACROE
 | 
			
		||||
				#define Pipe_SetFiniteINRequests(n)    MACROS{ UPCONX &= ~(1 << INMODE); UPINRQX = (n); }MACROE
 | 
			
		||||
 | 
			
		||||
				#define Pipe_IsConfigured()            ((UPSTAX  & (1 << CFGOK)) ? true : false)
 | 
			
		||||
 | 
			
		||||
				#define Pipe_BoundEndpointNumber()     ((UPCFG0X >> PEPNUM0) & PIPE_EPNUM_MASK)
 | 
			
		||||
				
 | 
			
		||||
				#define Pipe_SetInterruptPeriod(ms)    MACROS{ UPCFG2X = ms; }MACROE
 | 
			
		||||
				#define Pipe_SetInterruptPeriod(ms)    MACROS{ UPCFG2X = (ms); }MACROE
 | 
			
		||||
 | 
			
		||||
				#define Pipe_GetPipeInterrupts()       UPINT
 | 
			
		||||
 | 
			
		||||
				#define Pipe_HasPipeInterrupted(n)     ((UPINT & (1 << n)) ? true : false)
 | 
			
		||||
				#define Pipe_HasPipeInterrupted(n)     ((UPINT & (1 << (n))) ? true : false)
 | 
			
		||||
 | 
			
		||||
				#define Pipe_Unfreeze()                MACROS{ UPCONX &= ~(1 << PFREEZE); }MACROE
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue