Commit f3f48118 authored by Dean Camera's avatar Dean Camera
Browse files

More AVR32 UC3B architecture ports - USB device mode applications can now be...

More AVR32 UC3B architecture ports - USB device mode applications can now be sucessfully compiled, although they will be currently non-functional.
parent cf241143
This diff is collapsed.
...@@ -92,6 +92,18 @@ ...@@ -92,6 +92,18 @@
typedef uint32_t uint_reg_t; typedef uint32_t uint_reg_t;
#define EEMEM
#define PROGMEM const
#define ISR(Name) void Name (void)
#define ATOMIC_BLOCK(x) if (1)
#define ATOMIC_RESTORESTATE
#define pgm_read_byte(x) *x
#define eeprom_read_byte(x) *x
#define eeprom_update_byte(x, y) *x = y
#define eeprom_write_byte(x, y) *x = y
#define memcmp_P(...) memcmp(__VA_ARGS__)
#define memcpy_P(...) memcpy(__VA_ARGS__)
#warning The UC3B architecture support is currently experimental and incomplete! #warning The UC3B architecture support is currently experimental and incomplete!
#endif #endif
......
...@@ -37,11 +37,6 @@ ...@@ -37,11 +37,6 @@
#define __INCLUDE_FROM_CDC_DEVICE_C #define __INCLUDE_FROM_CDC_DEVICE_C
#include "CDC.h" #include "CDC.h"
void CDC_Device_Event_Stub(void)
{
}
void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) void CDC_Device_ProcessControlRequest(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
{ {
if (!(Endpoint_IsSETUPReceived())) if (!(Endpoint_IsSETUPReceived()))
...@@ -293,6 +288,7 @@ void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_Device_t* const CDC ...@@ -293,6 +288,7 @@ void CDC_Device_SendControlLineStateChange(USB_ClassInfo_CDC_Device_t* const CDC
Endpoint_ClearIN(); Endpoint_ClearIN();
} }
#if defined(FDEV_SETUP_STREAM)
void CDC_Device_CreateStream(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo, void CDC_Device_CreateStream(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo,
FILE* const Stream) FILE* const Stream)
{ {
...@@ -338,6 +334,12 @@ static int CDC_Device_getchar_Blocking(FILE* Stream) ...@@ -338,6 +334,12 @@ static int CDC_Device_getchar_Blocking(FILE* Stream)
return ReceivedByte; return ReceivedByte;
} }
#endif
void CDC_Device_Event_Stub(void)
{
}
#endif #endif
...@@ -305,6 +305,9 @@ ...@@ -305,6 +305,9 @@
* *
* \note The created stream can be given as stdout if desired to direct the standard output from all <stdio.h> functions * \note The created stream can be given as stdout if desired to direct the standard output from all <stdio.h> functions
* to the given CDC interface. * to the given CDC interface.
* \n\n
*
* \note This function is not available on all microcontroller architectures.
* *
* \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
* \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed. * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed.
...@@ -315,6 +318,8 @@ ...@@ -315,6 +318,8 @@
/** Identical to \ref CDC_Device_CreateStream(), except that reads are blocking until the calling stream function terminates /** Identical to \ref CDC_Device_CreateStream(), except that reads are blocking until the calling stream function terminates
* the transfer. While blocking, the USB and CDC service tasks are called repeatedly to maintain USB communications. * the transfer. While blocking, the USB and CDC service tasks are called repeatedly to maintain USB communications.
* *
* \note This function is not available on all microcontroller architectures.
*
* \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
* \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed. * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed.
*/ */
...@@ -325,10 +330,12 @@ ...@@ -325,10 +330,12 @@
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
/* Function Prototypes: */ /* Function Prototypes: */
#if defined(__INCLUDE_FROM_CDC_DEVICE_C) #if defined(__INCLUDE_FROM_CDC_DEVICE_C)
#if defined(FDEV_SETUP_STREAM)
static int CDC_Device_putchar(char c, static int CDC_Device_putchar(char c,
FILE* Stream) ATTR_NON_NULL_PTR_ARG(2); FILE* Stream) ATTR_NON_NULL_PTR_ARG(2);
static int CDC_Device_getchar(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1); static int CDC_Device_getchar(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1);
static int CDC_Device_getchar_Blocking(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1); static int CDC_Device_getchar_Blocking(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1);
#endif
void CDC_Device_Event_Stub(void) ATTR_CONST; void CDC_Device_Event_Stub(void) ATTR_CONST;
void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo)
......
...@@ -456,6 +456,7 @@ uint8_t CDC_Host_Flush(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) ...@@ -456,6 +456,7 @@ uint8_t CDC_Host_Flush(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)
return PIPE_READYWAIT_NoError; return PIPE_READYWAIT_NoError;
} }
#if defined(FDEV_SETUP_STREAM)
void CDC_Host_CreateStream(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo, void CDC_Host_CreateStream(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo,
FILE* const Stream) FILE* const Stream)
{ {
...@@ -501,6 +502,7 @@ static int CDC_Host_getchar_Blocking(FILE* Stream) ...@@ -501,6 +502,7 @@ static int CDC_Host_getchar_Blocking(FILE* Stream)
return ReceivedByte; return ReceivedByte;
} }
#endif
void CDC_Host_Event_Stub(void) void CDC_Host_Event_Stub(void)
{ {
......
...@@ -295,6 +295,9 @@ ...@@ -295,6 +295,9 @@
* *
* \note The created stream can be given as stdout if desired to direct the standard output from all \c <stdio.h> functions * \note The created stream can be given as stdout if desired to direct the standard output from all \c <stdio.h> functions
* to the given CDC interface. * to the given CDC interface.
* \n\n
*
* \note This function is not available on all microcontroller architectures.
* *
* \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
* \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed. * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed.
...@@ -305,6 +308,8 @@ ...@@ -305,6 +308,8 @@
/** Identical to \ref CDC_Host_CreateStream(), except that reads are blocking until the calling stream function terminates /** Identical to \ref CDC_Host_CreateStream(), except that reads are blocking until the calling stream function terminates
* the transfer. While blocking, the USB and CDC service tasks are called repeatedly to maintain USB communications. * the transfer. While blocking, the USB and CDC service tasks are called repeatedly to maintain USB communications.
* *
* \note This function is not available on all microcontroller architectures.
*
* \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state. * \param[in,out] CDCInterfaceInfo Pointer to a structure containing a CDC Class configuration and state.
* \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed. * \param[in,out] Stream Pointer to a FILE structure where the created stream should be placed.
*/ */
...@@ -325,10 +330,12 @@ ...@@ -325,10 +330,12 @@
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
/* Function Prototypes: */ /* Function Prototypes: */
#if defined(__INCLUDE_FROM_CDC_HOST_C) #if defined(__INCLUDE_FROM_CDC_HOST_C)
#if defined(FDEV_SETUP_STREAM)
static int CDC_Host_putchar(char c, static int CDC_Host_putchar(char c,
FILE* Stream) ATTR_NON_NULL_PTR_ARG(2); FILE* Stream) ATTR_NON_NULL_PTR_ARG(2);
static int CDC_Host_getchar(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1); static int CDC_Host_getchar(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1);
static int CDC_Host_getchar_Blocking(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1); static int CDC_Host_getchar_Blocking(FILE* Stream) ATTR_NON_NULL_PTR_ARG(1);
#endif
void CDC_Host_Event_Stub(void) ATTR_CONST; void CDC_Host_Event_Stub(void) ATTR_CONST;
void EVENT_CDC_Host_ControLineStateChanged(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo) void EVENT_CDC_Host_ControLineStateChanged(USB_ClassInfo_CDC_Host_t* const CDCInterfaceInfo)
......
...@@ -96,7 +96,7 @@ ...@@ -96,7 +96,7 @@
* a unique serial number internally, and setting the device descriptors serial number string index to this value * a unique serial number internally, and setting the device descriptors serial number string index to this value
* will cause it to use the internal serial number. * will cause it to use the internal serial number.
* *
* On unsupported devices, this will evaluate to NO_DESCRIPTOR and so will force the host to create a pseudo-serial * On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR and so will force the host to create a pseudo-serial
* number for the device. * number for the device.
*/ */
#define USE_INTERNAL_SERIAL 0xDC #define USE_INTERNAL_SERIAL 0xDC
......
...@@ -37,16 +37,10 @@ ...@@ -37,16 +37,10 @@
void USB_Device_SendRemoteWakeup(void) void USB_Device_SendRemoteWakeup(void)
{ {
if (!(USB_Options & USB_OPT_MANUAL_PLL))
{
USB_PLL_On();
while (!(USB_PLL_IsReady()));
}
USB_CLK_Unfreeze(); USB_CLK_Unfreeze();
AVR32_USBB.UDCON.rmwakeup = true; AVR32_USBB.UDCON.rmwkup = true;
while (AVR32_USBB.UDCON.rmwakeup); while (AVR32_USBB.UDCON.rmwkup);
} }
#endif #endif
......
...@@ -82,23 +82,16 @@ ...@@ -82,23 +82,16 @@
#define USB_DEVICE_OPT_FULLSPEED (0 << 0) #define USB_DEVICE_OPT_FULLSPEED (0 << 0)
//@} //@}
#if (!defined(NO_INTERNAL_SERIAL) && \
(defined(__AVR_AT90USB647__) || defined(__AVR_AT90USB1287__) || \
defined(__AVR_ATmega32U6__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB1286__) || \
defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__)))
/** String descriptor index for the device's unique serial number string descriptor within the device. /** String descriptor index for the device's unique serial number string descriptor within the device.
* This unique serial number is used by the host to associate resources to the device (such as drivers or COM port * This unique serial number is used by the host to associate resources to the device (such as drivers or COM port
* number allocations) to a device regardless of the port it is plugged in to on the host. Some USB AVRs contain * number allocations) to a device regardless of the port it is plugged in to on the host. Some USB AVRs contain
* a unique serial number internally, and setting the device descriptors serial number string index to this value * a unique serial number internally, and setting the device descriptors serial number string index to this value
* will cause it to use the internal serial number. * will cause it to use the internal serial number.
* *
* On unsupported devices, this will evaluate to NO_DESCRIPTOR and so will force the host to create a pseudo-serial * On unsupported devices, this will evaluate to \ref NO_DESCRIPTOR and so will force the host to create a pseudo-serial
* number for the device. * number for the device.
*/ */
#define USE_INTERNAL_SERIAL 0xDC
#else
#define USE_INTERNAL_SERIAL NO_DESCRIPTOR #define USE_INTERNAL_SERIAL NO_DESCRIPTOR
#endif
/* Function Prototypes: */ /* Function Prototypes: */
/** Sends a Remote Wakeup request to the host. This signals to the host that the device should /** Sends a Remote Wakeup request to the host. This signals to the host that the device should
...@@ -205,7 +198,7 @@ ...@@ -205,7 +198,7 @@
static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE; static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;
static inline void USB_Device_SetDeviceAddress(const uint8_t Address) static inline void USB_Device_SetDeviceAddress(const uint8_t Address)
{ {
AVR32_USBB.udcon = (AVR32_USBB.udcon & ~AVR32_USBB_UADD_MASK) | Address; AVR32_USBB.UDCON.uadd = Address;
AVR32_USBB.UDCON.adden = true; AVR32_USBB.UDCON.adden = true;
} }
......
...@@ -48,20 +48,19 @@ bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number, ...@@ -48,20 +48,19 @@ bool Endpoint_ConfigureEndpoint_Prv(const uint8_t Number,
Endpoint_SelectEndpoint(Number); Endpoint_SelectEndpoint(Number);
Endpoint_EnableEndpoint(); Endpoint_EnableEndpoint();
*((uint32_t*)AVR32_USBB_UECFG0)[USB_SelectedEndpoint] = 0; ((uint32_t*)AVR32_USBB_UECFG0)[USB_SelectedEndpoint] = 0;
*((uint32_t*)AVR32_USBB_UECFG0)[USB_SelectedEndpoint] = UECFGXData; ((uint32_t*)AVR32_USBB_UECFG0)[USB_SelectedEndpoint] = UECFGXData;
return Endpoint_IsConfigured(); return Endpoint_IsConfigured();
} }
void Endpoint_ClearEndpoints(void) void Endpoint_ClearEndpoints(void)
{ {
UEINT = 0;
for (uint8_t EPNum = 0; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++) for (uint8_t EPNum = 0; EPNum < ENDPOINT_TOTAL_ENDPOINTS; EPNum++)
{ {
Endpoint_SelectEndpoint(EPNum); Endpoint_SelectEndpoint(EPNum);
*((uint32_t*)AVR32_USBB_UECFG0)[USB_SelectedEndpoint] = 0; ((uint32_t*)AVR32_USBB_UECFG0)[USB_SelectedEndpoint] = 0;
((uint32_t*)AVR32_USBB_UECON0CLR)[USB_SelectedEndpoint] = 0xFFFFFFFF;
Endpoint_DisableEndpoint(); Endpoint_DisableEndpoint();
} }
} }
......
...@@ -166,21 +166,21 @@ ...@@ -166,21 +166,21 @@
* in slower transfers as only one USB device (the AVR or the host) can access the endpoint's * in slower transfers as only one USB device (the AVR or the host) can access the endpoint's
* bank at the one time. * bank at the one time.
*/ */
#define ENDPOINT_BANK_SINGLE AVR32_USBB_UECFG0_EPBK0_SINGLE #define ENDPOINT_BANK_SINGLE AVR32_USBB_UECFG0_EPBK_SINGLE
/** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates /** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates
* that the endpoint should have two banks, which requires more USB FIFO memory but results * that the endpoint should have two banks, which requires more USB FIFO memory but results
* in faster transfers as one USB device (the AVR or the host) can access one bank while the other * in faster transfers as one USB device (the AVR or the host) can access one bank while the other
* accesses the second bank. * accesses the second bank.
*/ */
#define ENDPOINT_BANK_DOUBLE AVR32_USBB_UECFG0_EPBK0_DOUBLE #define ENDPOINT_BANK_DOUBLE AVR32_USBB_UECFG0_EPBK_DOUBLE
/** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates /** Mask for the bank mode selection for the \ref Endpoint_ConfigureEndpoint() macro. This indicates
* that the endpoint should have three banks, which requires more USB FIFO memory but results * that the endpoint should have three banks, which requires more USB FIFO memory but results
* in faster transfers as one USB device (the AVR or the host) can access one bank while the other * in faster transfers as one USB device (the AVR or the host) can access one bank while the other
* accesses the remaining banks. * accesses the remaining banks.
*/ */
#define ENDPOINT_BANK_TRIPLE AVR32_USBB_UECFG0_TRIPLE #define ENDPOINT_BANK_TRIPLE AVR32_USBB_UECFG0_EPBK_TRIPLE
//@} //@}
/** Endpoint address for the default control endpoint, which always resides in address 0. This is /** Endpoint address for the default control endpoint, which always resides in address 0. This is
......
...@@ -48,8 +48,8 @@ bool Pipe_ConfigurePipe(const uint8_t Number, ...@@ -48,8 +48,8 @@ bool Pipe_ConfigurePipe(const uint8_t Number,
Pipe_SelectPipe(Number); Pipe_SelectPipe(Number);
Pipe_EnablePipe(); Pipe_EnablePipe();
*((uint32_t*)AVR32_USBB_UPCFG0)[USB_SelectedPipe] = 0; ((uint32_t*)AVR32_USBB_UPCFG0)[USB_SelectedPipe] = 0;
*((uint32_t*)AVR32_USBB_UPCFG0)[USB_SelectedPipe] = (AVR32_USBB_ALLOC_MASK | ((uint32_t*)AVR32_USBB_UPCFG0)[USB_SelectedPipe] = (AVR32_USBB_ALLOC_MASK |
((uint32_t)Type << AVR32_USBB_PTYPE_OFFSET) | ((uint32_t)Type << AVR32_USBB_PTYPE_OFFSET) |
((uint32_t)Token << AVR32_USBB_PTOKEN_OFFSET) | ((uint32_t)Token << AVR32_USBB_PTOKEN_OFFSET) |
((uint32_t)Banks << AVR32_USBB_PBK_OFFSET) | ((uint32_t)Banks << AVR32_USBB_PBK_OFFSET) |
...@@ -62,12 +62,11 @@ bool Pipe_ConfigurePipe(const uint8_t Number, ...@@ -62,12 +62,11 @@ bool Pipe_ConfigurePipe(const uint8_t Number,
void Pipe_ClearPipes(void) void Pipe_ClearPipes(void)
{ {
UPINT = 0;
for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++) for (uint8_t PNum = 0; PNum < PIPE_TOTAL_PIPES; PNum++)
{ {
Pipe_SelectPipe(PNum); Pipe_SelectPipe(PNum);
*((uint32_t*)AVR32_USBB_UPCFG0)[USB_SelectedPipe] = 0; ((uint32_t*)AVR32_USBB_UPCFG0)[USB_SelectedPipe] = 0;
((uint32_t*)AVR32_USBB_UPCON0CLR)[USB_SelectedPipe] = 0xFFFFFFFF;
Pipe_DisablePipe(); Pipe_DisablePipe();
} }
} }
......
...@@ -121,6 +121,18 @@ ...@@ -121,6 +121,18 @@
#endif #endif
/* Inline Functions: */ /* Inline Functions: */
/** Determines if the VBUS line is currently high (i.e. the USB host is supplying power).
*
* \note This function is not available on some AVR models which do not support hardware VBUS monitoring.
*
* \return Boolean \c true if the VBUS line is currently detecting power from a host, \c false otherwise.
*/
static inline bool USB_VBUS_GetStatus(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
static inline bool USB_VBUS_GetStatus(void)
{
return AVR32_USBB.USBSTA.vbus;
}
/** Detaches the device from the USB bus. This has the effect of removing the device from any /** Detaches the device from the USB bus. This has the effect of removing the device from any
* attached host, ceasing USB communications. If no host is present, this prevents any host from * attached host, ceasing USB communications. If no host is present, this prevents any host from
* enumerating the device once attached until \ref USB_Attach() is called. * enumerating the device once attached until \ref USB_Attach() is called.
...@@ -278,7 +290,6 @@ ...@@ -278,7 +290,6 @@
#endif #endif
/* Inline Functions: */ /* Inline Functions: */
#if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
static inline void USB_OTGPAD_On(void) ATTR_ALWAYS_INLINE; static inline void USB_OTGPAD_On(void) ATTR_ALWAYS_INLINE;
static inline void USB_OTGPAD_On(void) static inline void USB_OTGPAD_On(void)
{ {
...@@ -290,7 +301,6 @@ ...@@ -290,7 +301,6 @@
{ {
AVR32_USBB.USBCON.otgpade = false; AVR32_USBB.USBCON.otgpade = false;
} }
#endif
static inline void USB_CLK_Freeze(void) ATTR_ALWAYS_INLINE; static inline void USB_CLK_Freeze(void) ATTR_ALWAYS_INLINE;
static inline void USB_CLK_Freeze(void) static inline void USB_CLK_Freeze(void)
......
...@@ -33,45 +33,23 @@ ...@@ -33,45 +33,23 @@
void USB_INT_DisableAllInterrupts(void) void USB_INT_DisableAllInterrupts(void)
{ {
#if defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) AVR32_USBB.USBCON.vbuste = false;
USBCON &= ~((1 << VBUSTE) | (1 << IDTE)); AVR32_USBB.USBCON.idte = false;
#elif defined(USB_SERIES_4_AVR)
USBCON &= ~(1 << VBUSTE);
#endif
#if defined(USB_CAN_BE_BOTH)
OTGIEN = 0;
#endif
#if defined(USB_CAN_BE_HOST)
UHIEN = 0;
#endif
#if defined(USB_CAN_BE_DEVICE) AVR32_USBB.uhinteclr = 0xFFFFFFFF;
UDIEN = 0; AVR32_USBB.udinteclr = 0xFFFFFFFF;
#endif
} }
void USB_INT_ClearAllInterrupts(void) void USB_INT_ClearAllInterrupts(void)
{ {
#if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) AVR32_USBB.USBSTACLR.vbustic = true;
USBINT = 0; AVR32_USBB.USBSTACLR.idtic = true;
#endif
#if defined(USB_CAN_BE_BOTH)
OTGINT = 0;
#endif
#if defined(USB_CAN_BE_HOST)
UHINT = 0;
#endif
#if defined(USB_CAN_BE_DEVICE) AVR32_USBB.uhintclr = 0xFFFFFFFF;
UDINT = 0; AVR32_USBB.udintclr = 0xFFFFFFFF;
#endif
} }
ISR(USB_GEN_vect, ISR_BLOCK) ISR(USB_GEN_vect)
{ {
#if defined(USB_CAN_BE_DEVICE) #if defined(USB_CAN_BE_DEVICE)
#if !defined(NO_SOF_EVENTS) #if !defined(NO_SOF_EVENTS)
...@@ -83,7 +61,6 @@ ISR(USB_GEN_vect, ISR_BLOCK) ...@@ -83,7 +61,6 @@ ISR(USB_GEN_vect, ISR_BLOCK)
} }
#endif #endif
#if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
if (USB_INT_HasOccurred(USB_INT_VBUS) && USB_INT_IsEnabled(USB_INT_VBUS)) if (USB_INT_HasOccurred(USB_INT_VBUS) && USB_INT_IsEnabled(USB_INT_VBUS))
{ {
USB_INT_Clear(USB_INT_VBUS); USB_INT_Clear(USB_INT_VBUS);
...@@ -99,7 +76,6 @@ ISR(USB_GEN_vect, ISR_BLOCK) ...@@ -99,7 +76,6 @@ ISR(USB_GEN_vect, ISR_BLOCK)
EVENT_USB_Device_Disconnect(); EVENT_USB_Device_Disconnect();
} }
} }
#endif
if (USB_INT_HasOccurred(USB_INT_SUSPI) && USB_INT_IsEnabled(USB_INT_SUSPI)) if (USB_INT_HasOccurred(USB_INT_SUSPI) && USB_INT_IsEnabled(USB_INT_SUSPI))
{ {
...@@ -110,26 +86,12 @@ ISR(USB_GEN_vect, ISR_BLOCK) ...@@ -110,26 +86,12 @@ ISR(USB_GEN_vect, ISR_BLOCK)
USB_CLK_Freeze(); USB_CLK_Freeze();
if (!(USB_Options & USB_OPT_MANUAL_PLL))
USB_PLL_Off();
#if defined(USB_SERIES_2_AVR) && !defined(NO_LIMITED_CONTROLLER_CONNECT)
USB_DeviceState = DEVICE_STATE_Unattached;
EVENT_USB_Device_Disconnect();
#else
USB_DeviceState = DEVICE_STATE_Suspended; USB_DeviceState = DEVICE_STATE_Suspended;
EVENT_USB_Device_Suspend(); EVENT_USB_Device_Suspend();
#endif
} }
if (USB_INT_HasOccurred(USB_INT_WAKEUPI) && USB_INT_IsEnabled(USB_INT_WAKEUPI)) if (USB_INT_HasOccurred(USB_INT_WAKEUPI) && USB_INT_IsEnabled(USB_INT_WAKEUPI))
{ {
if (!(USB_Options & USB_OPT_MANUAL_PLL))
{
USB_PLL_On();
while (!(USB_PLL_IsReady()));
}
USB_CLK_Unfreeze(); USB_CLK_Unfreeze();
USB_INT_Clear(USB_INT_WAKEUPI); USB_INT_Clear(USB_INT_WAKEUPI);
...@@ -142,11 +104,7 @@ ISR(USB_GEN_vect, ISR_BLOCK) ...@@ -142,11 +104,7 @@ ISR(USB_GEN_vect, ISR_BLOCK)
else else
USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered; USB_DeviceState = (USB_Device_IsAddressSet()) ? DEVICE_STATE_Configured : DEVICE_STATE_Powered;
#if defined(USB_SERIES_2_AVR) && !defined(NO_LIMITED_CONTROLLER_CONNECT)
EVENT_USB_Device_Connect();
#else
EVENT_USB_Device_WakeUp(); EVENT_USB_Device_WakeUp();
#endif
} }
if (USB_INT_HasOccurred(USB_INT_EORSTI) && USB_INT_IsEnabled(USB_INT_EORSTI)) if (USB_INT_HasOccurred(USB_INT_EORSTI) && USB_INT_IsEnabled(USB_INT_EORSTI))
......
...@@ -57,31 +57,243 @@ ...@@ -57,31 +57,243 @@
/* Private Interface - For use in library only: */ /* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
/* Macros: */ /* Macros: */
#define USB_INT_Enable(int) MACROS{ USB_INT_GET_EN_REG(int) |= USB_INT_GET_EN_MASK(int); }MACROE enum USB_Interrupts_t
#define USB_INT_Disable(int) MACROS{ USB_INT_GET_EN_REG(int) &= ~(USB_INT_GET_EN_MASK(int)); }MACROE {
#define USB_INT_Clear(int) MACROS{ USB_INT_GET_INT_REG(int) &= ~(USB_INT_GET_INT_MASK(int)); }MACROE USB_INT_VBUS = 0,
#define USB_INT_IsEnabled(int) ((USB_INT_GET_EN_REG(int) & USB_INT_GET_EN_MASK(int)) ? true : false) USB_INT_IDTI = 1,
#define USB_INT_HasOccurred(int) ((USB_INT_GET_INT_REG(int) & USB_INT_GET_INT_MASK(int)) ? true : false) USB_INT_WAKEUPI = 2,
USB_INT_SUSPI = 3,