diff options
Diffstat (limited to 'LUFA/Drivers/USB')
-rw-r--r-- | LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h | 30 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c | 2 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c | 7 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.h | 31 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/DeviceStandardReq.c | 20 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/UC3/Device_UC3.h | 30 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.h | 14 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/UC3/Host_UC3.c | 2 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/UC3/Pipe_UC3.h | 2 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.c | 2 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.h | 49 |
11 files changed, 133 insertions, 56 deletions
diff --git a/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h b/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h index 7a9c3675d..77af51255 100644 --- a/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h +++ b/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h @@ -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 >>= 4; + SigReadAddress++; + } - SerialByte &= 0x0F; + SerialByte &= 0x0F; - UnicodeString[SerialCharNum] = cpu_to_le16((SerialByte >= 10) ? - (('A' - 10) + SerialByte) : ('0' + SerialByte)); - } + UnicodeString[SerialCharNum] = cpu_to_le16((SerialByte >= 10) ? + (('A' - 10) + SerialByte) : ('0' + SerialByte)); } + + USB_INT_SetGlobalEnableState(CurrentGlobalInt); } #endif diff --git a/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c b/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c index e4220e395..87dddd49d 100644 --- a/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c +++ b/LUFA/Drivers/USB/Core/AVR8/Host_AVR8.c @@ -69,7 +69,7 @@ void USB_Host_ProcessNextHostState(void) case HOST_STATE_Powered_WaitForDeviceSettle: if (WaitMSRemaining--) { - _delay_ms(1); + Delay_MS(1); break; } else diff --git a/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c b/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c index 89d60ebe0..deaa5e5fb 100644 --- a/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c +++ b/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c @@ -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); diff --git a/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.h b/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.h index 6115ec6e3..e85b67e92 100644 --- a/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.h +++ b/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.h @@ -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) { diff --git a/LUFA/Drivers/USB/Core/DeviceStandardReq.c b/LUFA/Drivers/USB/Core/DeviceStandardReq.c index e36820387..a502c0949 100644 --- a/LUFA/Drivers/USB/Core/DeviceStandardReq.c +++ b/LUFA/Drivers/USB/Core/DeviceStandardReq.c @@ -114,20 +114,20 @@ void USB_Device_ProcessControlRequest(void) static void USB_Device_SetAddress(void) { - uint8_t DeviceAddress = (USB_ControlRequest.wValue & 0x7F); - - ATOMIC_BLOCK(ATOMIC_RESTORESTATE) - { - Endpoint_ClearSETUP(); + uint8_t DeviceAddress = (USB_ControlRequest.wValue & 0x7F); + uint_reg_t CurrentGlobalInt = USB_INT_GetGlobalEnableState(); + USB_INT_GlobalDisable(); + + Endpoint_ClearSETUP(); - Endpoint_ClearStatusStage(); + Endpoint_ClearStatusStage(); - while (!(Endpoint_IsINReady())); + while (!(Endpoint_IsINReady())); - USB_Device_SetDeviceAddress(DeviceAddress); - } - + USB_Device_SetDeviceAddress(DeviceAddress); USB_DeviceState = (DeviceAddress) ? DEVICE_STATE_Addressed : DEVICE_STATE_Default; + + USB_INT_SetGlobalEnableState(CurrentGlobalInt); } static void USB_Device_SetConfiguration(void) diff --git a/LUFA/Drivers/USB/Core/UC3/Device_UC3.h b/LUFA/Drivers/USB/Core/UC3/Device_UC3.h index 8389d62dc..150b18860 100644 --- a/LUFA/Drivers/USB/Core/UC3/Device_UC3.h +++ b/LUFA/Drivers/USB/Core/UC3/Device_UC3.h @@ -187,26 +187,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 = (uint8_t*)0x80800204;
+
+ for (uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BITS / 4); SerialCharNum++)
{
- uint8_t* SigReadAddress = (uint8_t*)0x80800204;
+ uint8_t SerialByte = *SigReadAddress;
- for (uint8_t SerialCharNum = 0; SerialCharNum < (INTERNAL_SERIAL_LENGTH_BITS / 4); SerialCharNum++)
+ if (SerialCharNum & 0x01)
{
- uint8_t SerialByte = *SigReadAddress;
-
- if (SerialCharNum & 0x01)
- {
- SerialByte >>= 4;
- SigReadAddress++;
- }
+ SerialByte >>= 4;
+ SigReadAddress++;
+ }
- SerialByte &= 0x0F;
+ SerialByte &= 0x0F;
- UnicodeString[SerialCharNum] = cpu_to_le16((SerialByte >= 10) ?
- (('A' - 10) + SerialByte) : ('0' + SerialByte));
- }
+ UnicodeString[SerialCharNum] = cpu_to_le16((SerialByte >= 10) ?
+ (('A' - 10) + SerialByte) : ('0' + SerialByte));
}
+
+ USB_INT_SetGlobalEnableState(CurrentGlobalInt);
}
#endif
diff --git a/LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.h b/LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.h index 4c3aa09b7..2fe42aa30 100644 --- a/LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.h +++ b/LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.h @@ -90,13 +90,13 @@ /* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Macros: */
- #define _ENDPOINT_GET_MAXSIZE(EPIndex) _ENDPOINT_GET_MAXSIZE2(ENDPOINT_DETAILS_EP ## EPIndex)
- #define _ENDPOINT_GET_MAXSIZE2(EPDetails) _ENDPOINT_GET_MAXSIZE3(EPDetails)
- #define _ENDPOINT_GET_MAXSIZE3(MaxSize, Banks) (MaxSize)
+ #define _ENDPOINT_GET_MAXSIZE(EPIndex) _ENDPOINT_GET_MAXSIZE2(ENDPOINT_DETAILS_EP ## EPIndex)
+ #define _ENDPOINT_GET_MAXSIZE2(EPDetails) _ENDPOINT_GET_MAXSIZE3(EPDetails)
+ #define _ENDPOINT_GET_MAXSIZE3(MaxSize, Banks) (MaxSize)
- #define _ENDPOINT_GET_BANKS(EPIndex) _ENDPOINT_GET_BANKS2(ENDPOINT_DETAILS_EP ## EPIndex)
- #define _ENDPOINT_GET_BANKS2(EPDetails) _ENDPOINT_GET_BANKS3(EPDetails)
- #define _ENDPOINT_GET_BANKS3(MaxSize, Banks) (Banks)
+ #define _ENDPOINT_GET_BANKS(EPIndex) _ENDPOINT_GET_BANKS2(ENDPOINT_DETAILS_EP ## EPIndex)
+ #define _ENDPOINT_GET_BANKS2(EPDetails) _ENDPOINT_GET_BANKS3(EPDetails)
+ #define _ENDPOINT_GET_BANKS3(MaxSize, Banks) (Banks)
#if defined(USB_SERIES_UC3A0_AVR) || defined(USB_SERIES_UC3A1_AVR)
#define ENDPOINT_DETAILS_MAXEP 7
@@ -130,7 +130,7 @@ #define ENDPOINT_DETAILS_EP6 256, 2
#endif
- #define ENDPOINT_HSB_ADDRESS_SPACE_SIZE (64 * 1024UL)
+ #define ENDPOINT_HSB_ADDRESS_SPACE_SIZE (64 * 1024UL)
/* Inline Functions: */
static inline uint32_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST
diff --git a/LUFA/Drivers/USB/Core/UC3/Host_UC3.c b/LUFA/Drivers/USB/Core/UC3/Host_UC3.c index 6d49abbb2..b557ff0ed 100644 --- a/LUFA/Drivers/USB/Core/UC3/Host_UC3.c +++ b/LUFA/Drivers/USB/Core/UC3/Host_UC3.c @@ -69,7 +69,7 @@ void USB_Host_ProcessNextHostState(void) case HOST_STATE_Powered_WaitForDeviceSettle:
if (WaitMSRemaining--)
{
- _delay_ms(1);
+ Delay_MS(1);
break;
}
else
diff --git a/LUFA/Drivers/USB/Core/UC3/Pipe_UC3.h b/LUFA/Drivers/USB/Core/UC3/Pipe_UC3.h index d7a7da2a9..045aaad1d 100644 --- a/LUFA/Drivers/USB/Core/UC3/Pipe_UC3.h +++ b/LUFA/Drivers/USB/Core/UC3/Pipe_UC3.h @@ -99,7 +99,7 @@ /* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Macros: */
- #define PIPE_HSB_ADDRESS_SPACE_SIZE (64 * 1024UL)
+ #define PIPE_HSB_ADDRESS_SPACE_SIZE (64 * 1024UL)
/* External Variables: */
extern volatile uint8_t USB_SelectedPipe;
diff --git a/LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.c b/LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.c index 76f4ef022..76386649a 100644 --- a/LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.c +++ b/LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.c @@ -49,7 +49,7 @@ void USB_INT_ClearAllInterrupts(void) AVR32_USBB.udintclr = 0xFFFFFFFF;
}
-ISR(USB_GEN_vect)
+LUFA_ISR(USB_GEN_vect)
{
#if defined(USB_CAN_BE_DEVICE)
#if !defined(NO_SOF_EVENTS)
diff --git a/LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.h b/LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.h index 119243360..95a85cf69 100644 --- a/LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.h +++ b/LUFA/Drivers/USB/Core/UC3/USBInterrupt_UC3.h @@ -57,6 +57,9 @@ /* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Macros: */
+ #define LUFA_ISR(Name) void Name (void) __attribute__((__interrupt__)); void Name (void)
+
+ /* Enums: */
enum USB_Interrupts_t
{
USB_INT_VBUSTI = 0,
@@ -79,10 +82,38 @@ #endif
};
- /* ISR Prototypes: */
- ISR(USB_GEN_vect);
-
/* 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 (__builtin_mfsr(AVR32_SR) & AVR32_SR_GM);
+ }
+
+ 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();
+ __builtin_ssrf(AVR32_SR_GM_OFFSET, GlobalIntState);
+ GCC_MEMORY_BARRIER();
+ }
+
+ static inline void USB_INT_GlobalEnable(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_INT_GlobalEnable(void)
+ {
+ GCC_MEMORY_BARRIER();
+ __builtin_csrf(AVR32_SR_GM_OFFSET);
+ GCC_MEMORY_BARRIER();
+ }
+
+ static inline void USB_INT_GlobalDisable(void) ATTR_ALWAYS_INLINE;
+ static inline void USB_INT_GlobalDisable(void)
+ {
+ GCC_MEMORY_BARRIER();
+ __builtin_ssrf(AVR32_SR_GM_OFFSET);
+ 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)
{
@@ -335,6 +366,18 @@ void USB_INT_DisableAllInterrupts(void);
#endif
+ /* Public Interface - May be used in end-application: */
+ /* ISR Prototypes: */
+ #if defined(__DOXYGEN__)
+ /** Interrupt service routine handler for the USB controller ISR group. This interrupt routine <b>must</b> be
+ * linked to the entire USB controller ISR vector group inside the AVR32's interrupt controller peripheral,
+ * using the user application's preferred USB controller driver.
+ */
+ void USB_GEN_vect(void);
+ #else
+ LUFA_ISR(USB_GEN_vect);
+ #endif
+
/* Disable C linkage for C++ Compilers: */
#if defined(__cplusplus)
}
|