diff options
| author | Dean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28> | 2011-04-08 04:49:20 +0000 |
|---|---|---|
| committer | Dean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28> | 2011-04-08 04:49:20 +0000 |
| commit | 6d221c9c8267a84329271dfe5f04886978eb58a8 (patch) | |
| tree | b250bd819829b6e2807f4c85bd1342aa979eeb28 /LUFA/Drivers/USB/Core/AVR8 | |
| parent | 673cb95b174747d4f08b0a6551326dd282292c57 (diff) | |
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.
git-svn-id: http://lufa-lib.googlecode.com/svn/trunk@1729 d5102386-fcda-11dd-9fdb-3debd5008f28
Diffstat (limited to 'LUFA/Drivers/USB/Core/AVR8')
| -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 |
4 files changed, 51 insertions, 19 deletions
diff --git a/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h b/LUFA/Drivers/USB/Core/AVR8/Device_AVR8.h index 7a9c3675..77af5125 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 e4220e39..87dddd49 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 89d60ebe..deaa5e5f 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 6115ec6e..e85b67e9 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) { |
