Add in a new common Delay_MS() function, which provides a blocking delay for all architectures.
Remove use of avr-libc specific ATOMIC_BLOCK, replace with a new per-architecture set of inline functions to retrieve and manipulate the global interrupt enable bit for each architecture. Add in documentation for the USB controller common interrupt routine which must be linked to the interrupt controller in the user application on the AVR32 UC3 architecture.
This commit is contained in:
		
							parent
							
								
									0c5afda7e8
								
							
						
					
					
						commit
						70284d390f
					
				
					 17 changed files with 196 additions and 97 deletions
				
			
		| 
						 | 
				
			
			@ -199,26 +199,28 @@
 | 
			
		|||
		
 | 
			
		||||
			static inline void USB_Device_GetSerialString(uint16_t* UnicodeString)
 | 
			
		||||
			{
 | 
			
		||||
				ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
 | 
			
		||||
				uint_reg_t CurrentGlobalInt = USB_INT_GetGlobalEnableState();
 | 
			
		||||
				USB_INT_GlobalDisable();
 | 
			
		||||
				
 | 
			
		||||
				uint8_t SigReadAddress = 0x0E;
 | 
			
		||||
 | 
			
		||||
				for (uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BITS / 4); SerialCharNum++)
 | 
			
		||||
				{
 | 
			
		||||
					uint8_t SigReadAddress = 0x0E;
 | 
			
		||||
					uint8_t SerialByte = boot_signature_byte_get(SigReadAddress);
 | 
			
		||||
 | 
			
		||||
					for (uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BITS / 4); SerialCharNum++)
 | 
			
		||||
					if (SerialCharNum & 0x01)
 | 
			
		||||
					{
 | 
			
		||||
						uint8_t SerialByte = boot_signature_byte_get(SigReadAddress);
 | 
			
		||||
 | 
			
		||||
						if (SerialCharNum & 0x01)
 | 
			
		||||
						{
 | 
			
		||||
							SerialByte >>= 4;
 | 
			
		||||
							SigReadAddress++;
 | 
			
		||||
						}
 | 
			
		||||
 | 
			
		||||
						SerialByte &= 0x0F;
 | 
			
		||||
 | 
			
		||||
						UnicodeString[SerialCharNum] = cpu_to_le16((SerialByte >= 10) ?
 | 
			
		||||
						                                           (('A' - 10) + SerialByte) : ('0' + SerialByte));
 | 
			
		||||
						SerialByte >>= 4;
 | 
			
		||||
						SigReadAddress++;
 | 
			
		||||
					}
 | 
			
		||||
 | 
			
		||||
					SerialByte &= 0x0F;
 | 
			
		||||
 | 
			
		||||
					UnicodeString[SerialCharNum] = cpu_to_le16((SerialByte >= 10) ?
 | 
			
		||||
															   (('A' - 10) + SerialByte) : ('0' + SerialByte));
 | 
			
		||||
				}
 | 
			
		||||
				
 | 
			
		||||
				USB_INT_SetGlobalEnableState(CurrentGlobalInt);
 | 
			
		||||
			}
 | 
			
		||||
		
 | 
			
		||||
	#endif
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -69,7 +69,7 @@ void USB_Host_ProcessNextHostState(void)
 | 
			
		|||
		case HOST_STATE_Powered_WaitForDeviceSettle:
 | 
			
		||||
			if (WaitMSRemaining--)
 | 
			
		||||
			{
 | 
			
		||||
				_delay_ms(1);
 | 
			
		||||
				Delay_MS(1);
 | 
			
		||||
				break;
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -263,10 +263,9 @@ ISR(USB_COM_vect, ISR_BLOCK)
 | 
			
		|||
	Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
 | 
			
		||||
	USB_INT_Disable(USB_INT_RXSTPI);
 | 
			
		||||
 | 
			
		||||
	NONATOMIC_BLOCK(NONATOMIC_FORCEOFF)
 | 
			
		||||
	{
 | 
			
		||||
		USB_Device_ProcessControlRequest();
 | 
			
		||||
	}
 | 
			
		||||
	USB_INT_GlobalEnable();
 | 
			
		||||
 | 
			
		||||
	USB_Device_ProcessControlRequest();
 | 
			
		||||
 | 
			
		||||
	Endpoint_SelectEndpoint(ENDPOINT_CONTROLEP);
 | 
			
		||||
	USB_INT_Enable(USB_INT_RXSTPI);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -84,6 +84,37 @@
 | 
			
		|||
			};
 | 
			
		||||
 | 
			
		||||
		/* Inline Functions: */
 | 
			
		||||
			static inline uint_reg_t USB_INT_GetGlobalEnableState(void) ATTR_ALWAYS_INLINE ATTR_WARN_UNUSED_RESULT;
 | 
			
		||||
			static inline uint_reg_t USB_INT_GetGlobalEnableState(void)
 | 
			
		||||
			{
 | 
			
		||||
				GCC_MEMORY_BARRIER();
 | 
			
		||||
				return SREG;
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			static inline void USB_INT_SetGlobalEnableState(uint_reg_t GlobalIntState) ATTR_ALWAYS_INLINE;
 | 
			
		||||
			static inline void USB_INT_SetGlobalEnableState(uint_reg_t GlobalIntState)
 | 
			
		||||
			{
 | 
			
		||||
				GCC_MEMORY_BARRIER();
 | 
			
		||||
				SREG = GlobalIntState;
 | 
			
		||||
				GCC_MEMORY_BARRIER();
 | 
			
		||||
			}
 | 
			
		||||
		
 | 
			
		||||
			static inline void USB_INT_GlobalEnable(void) ATTR_ALWAYS_INLINE;
 | 
			
		||||
			static inline void USB_INT_GlobalEnable(void)
 | 
			
		||||
			{
 | 
			
		||||
				GCC_MEMORY_BARRIER();
 | 
			
		||||
				sei();
 | 
			
		||||
				GCC_MEMORY_BARRIER();
 | 
			
		||||
			}		
 | 
			
		||||
 | 
			
		||||
			static inline void USB_INT_GlobalDisable(void) ATTR_ALWAYS_INLINE;
 | 
			
		||||
			static inline void USB_INT_GlobalDisable(void)
 | 
			
		||||
			{
 | 
			
		||||
				GCC_MEMORY_BARRIER();
 | 
			
		||||
				cli();
 | 
			
		||||
				GCC_MEMORY_BARRIER();
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			static inline void USB_INT_Enable(const uint8_t Interrupt) ATTR_ALWAYS_INLINE;
 | 
			
		||||
			static inline void USB_INT_Enable(const uint8_t Interrupt)
 | 
			
		||||
			{
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue