General cleanup and more port work to the AVR32 UC3B.

pull/1469/head
Dean Camera 14 years ago
parent 4a3b70e727
commit 92b3553a07

@ -92,7 +92,7 @@
defined(__AVR_ATmega32U2__) || defined(__AVR_ATmega16U2__) || defined(__AVR_ATmega8U2__)))
/** 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
* 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 microcontrollers contain
* 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.
*

@ -101,7 +101,7 @@
#if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
#define ENDPOINT_DETAILS_MAXEP 7
#define ENDPOINT_DETAILS_EP0 64, 2
#define ENDPOINT_DETAILS_EP0 64, 1
#define ENDPOINT_DETAILS_EP1 256, 2
#define ENDPOINT_DETAILS_EP2 64, 2
#define ENDPOINT_DETAILS_EP3 64, 2
@ -111,7 +111,7 @@
#else
#define ENDPOINT_DETAILS_MAXEP 5
#define ENDPOINT_DETAILS_EP0 64, 2
#define ENDPOINT_DETAILS_EP0 64, 1
#define ENDPOINT_DETAILS_EP1 64, 1
#define ENDPOINT_DETAILS_EP2 64, 1
#define ENDPOINT_DETAILS_EP3 64, 2
@ -262,8 +262,8 @@
* ascending order, or bank corruption will occur.
* \n\n
*
* \note Certain models of USB AVR's endpoints may have different maximum packet sizes based on the endpoint's
* index - refer to the chosen USB AVR's datasheet to determine the maximum bank size for each endpoint.
* \note Different endpoints may have different maximum packet sizes based on the endpoint's index - refer to
* the chosen microcontroller model's datasheet to determine the maximum bank size for each endpoint.
* \n\n
*
* \note The default control endpoint should not be manually configured by the user application, as

@ -838,8 +838,8 @@
* or bank corruption will occur.
* \n\n
*
* \note Certain models of USB AVR's pipes may have different maximum packet sizes based on the pipe's
* index - refer to the chosen USB AVR's datasheet to determine the maximum bank size for each pipe.
* \note Certain microcontroller model's pipes may have different maximum packet sizes based on the pipe's
* index - refer to the chosen microcontroller's datasheet to determine the maximum bank size for each pipe.
* \n\n
*
* \note The default control pipe should not be manually configured by the user application, as it is

@ -63,18 +63,13 @@
/* Macros: */
/** \name USB Device Mode Option Masks */
//@{
#if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR) || defined(__DOXYGEN__)
/** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the
* USB interface should be initialized in low speed (1.5Mb/s) mode.
*
* \note Low Speed mode is not available on all USB AVR models.
* \n
*
* \note Restrictions apply on the number, size and type of endpoints which can be used
* when running in low speed mode - refer to the USB 2.0 specification.
*/
#define USB_DEVICE_OPT_LOWSPEED (1 << 0)
#endif
/** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the
* USB interface should be initialized in low speed (1.5Mb/s) mode.
*
* \note Restrictions apply on the number, size and type of endpoints which can be used
* when running in low speed mode - refer to the USB 2.0 specification.
*/
#define USB_DEVICE_OPT_LOWSPEED (1 << 0)
/** Mask for the Options parameter of the \ref USB_Init() function. This indicates that the
* USB interface should be initialized in full speed (12Mb/s) mode.
@ -84,7 +79,7 @@
/** 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
* 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 microcontrollers contain
* 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.
*
@ -152,7 +147,6 @@
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Inline Functions: */
#if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
static inline void USB_Device_SetLowSpeed(void) ATTR_ALWAYS_INLINE;
static inline void USB_Device_SetLowSpeed(void)
{
@ -164,7 +158,6 @@
{
AVR32_USBB.UDCON.ls = false;
}
#endif
static inline void USB_Device_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;
static inline void USB_Device_SetDeviceAddress(const uint8_t Address)

@ -98,25 +98,15 @@
#define _ENDPOINT_GET_BANKS2(EPDetails) _ENDPOINT_GET_BANKS3(EPDetails)
#define _ENDPOINT_GET_BANKS3(MaxSize, Banks) (Banks)
#if defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR)
#define ENDPOINT_DETAILS_MAXEP 7
#define ENDPOINT_DETAILS_EP0 64, 2
#define ENDPOINT_DETAILS_EP1 256, 2
#define ENDPOINT_DETAILS_EP2 64, 2
#define ENDPOINT_DETAILS_EP3 64, 2
#define ENDPOINT_DETAILS_EP4 64, 2
#define ENDPOINT_DETAILS_EP5 64, 2
#define ENDPOINT_DETAILS_EP6 64, 2
#else
#define ENDPOINT_DETAILS_MAXEP 5
#define ENDPOINT_DETAILS_MAXEP 7
#define ENDPOINT_DETAILS_EP0 64, 2
#define ENDPOINT_DETAILS_EP1 64, 1
#define ENDPOINT_DETAILS_EP2 64, 1
#define ENDPOINT_DETAILS_EP3 64, 2
#define ENDPOINT_DETAILS_EP4 64, 2
#endif
#define ENDPOINT_DETAILS_EP0 64, 1
#define ENDPOINT_DETAILS_EP1 64, 2
#define ENDPOINT_DETAILS_EP2 64, 2
#define ENDPOINT_DETAILS_EP3 64, 2
#define ENDPOINT_DETAILS_EP4 64, 2
#define ENDPOINT_DETAILS_EP5 256, 2
#define ENDPOINT_DETAILS_EP6 256, 2
/* Inline Functions: */
static inline uint32_t Endpoint_BytesToEPSizeMask(const uint16_t Bytes) ATTR_WARN_UNUSED_RESULT ATTR_CONST
@ -174,13 +164,6 @@
* accesses the second bank.
*/
#define ENDPOINT_BANK_DOUBLE AVR32_USBB_UECFG0_EPBK_DOUBLE
/** 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
* in faster transfers as one USB device (the AVR or the host) can access one bank while the other
* accesses the remaining banks.
*/
#define ENDPOINT_BANK_TRIPLE AVR32_USBB_UECFG0_EPBK_TRIPLE
//@}
#if (!defined(FIXED_CONTROL_ENDPOINT_SIZE) || defined(__DOXYGEN__))
@ -210,7 +193,7 @@
#if !defined(CONTROL_ONLY_DEVICE) || defined(__DOXYGEN__)
/** Total number of endpoints (including the default control endpoint at address 0) which may
* be used in the device. Different USB AVR models support different amounts of endpoints,
* be used in the device. Different AVR models support different amounts of endpoints,
* this value reflects the maximum number of endpoints for the currently selected AVR model.
*/
#define ENDPOINT_TOTAL_ENDPOINTS ENDPOINT_DETAILS_MAXEP
@ -270,8 +253,8 @@
* ascending order, or bank corruption will occur.
* \n\n
*
* \note Certain models of USB AVR's endpoints may have different maximum packet sizes based on the endpoint's
* index - refer to the chosen USB AVR's datasheet to determine the maximum bank size for each endpoint.
* \note Different endpoints may have different maximum packet sizes based on the endpoint's index - refer to
* the chosen microcontroller model's datasheet to determine the maximum bank size for each endpoint.
* \n\n
*
* \note The default control endpoint should not be manually configured by the user application, as

@ -355,8 +355,6 @@
static inline void USB_Host_VBUS_Manual_Enable(void)
{
AVR32_USBB.USBCON.vbushwc = true;
// TODO: Manual VBUS pin output setup
}
static inline void USB_Host_VBUS_Auto_On(void) ATTR_ALWAYS_INLINE;
@ -368,7 +366,7 @@
static inline void USB_Host_VBUS_Manual_On(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_VBUS_Manual_On(void)
{
// TODO: Manual VBUS pin output on
AVR32_USBB.USBSTASET.vbusrqs = true;
}
static inline void USB_Host_VBUS_Auto_Off(void) ATTR_ALWAYS_INLINE;
@ -380,7 +378,7 @@
static inline void USB_Host_VBUS_Manual_Off(void) ATTR_ALWAYS_INLINE;
static inline void USB_Host_VBUS_Manual_Off(void)
{
// TODO: Manual VBUS pin output off
AVR32_USBB.USBSTACLR.vbusrqc = true;
}
static inline void USB_Host_SetDeviceAddress(const uint8_t Address) ATTR_ALWAYS_INLINE;

@ -172,15 +172,14 @@
#define PIPE_CONTROLPIPE_DEFAULT_SIZE 64
/** Total number of pipes (including the default control pipe at address 0) which may be used in
* the device. Different USB AVR models support different amounts of pipes, this value reflects
* the maximum number of pipes for the currently selected AVR model.
* the device.
*/
#define PIPE_TOTAL_PIPES 7
/** Size in bytes of the largest pipe bank size possible in the device. Not all banks on each AVR
* model supports the largest bank size possible on the device; different pipe numbers support
* different maximum bank sizes. This value reflects the largest possible bank of any pipe on the
* currently selected USB AVR model.
* currently selected UC3B AVR model.
*/
#define PIPE_MAX_SIZE 256
@ -857,8 +856,8 @@
* or bank corruption will occur.
* \n\n
*
* \note Certain models of USB AVR's pipes may have different maximum packet sizes based on the pipe's
* index - refer to the chosen USB AVR's datasheet to determine the maximum bank size for each pipe.
* \note Certain microcontroller model's pipes may have different maximum packet sizes based on the pipe's
* index - refer to the chosen microcontroller's datasheet to determine the maximum bank size for each pipe.
* \n\n
*
* \note The default control pipe should not be manually configured by the user application, as it is

@ -152,25 +152,15 @@ static void USB_Init_Device(void)
USB_Descriptor_Device_t* DeviceDescriptorPtr;
if (CALLBACK_USB_GetDescriptor((DTYPE_Device << 8), 0, (void*)&DeviceDescriptorPtr) != NO_DESCRIPTOR)
{
#if defined(USE_RAM_DESCRIPTORS)
USB_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size;
#elif defined(USE_EEPROM_DESCRIPTORS)
USB_ControlEndpointSize = eeprom_read_byte(&DeviceDescriptorPtr->Endpoint0Size);
#else
USB_ControlEndpointSize = pgm_read_byte(&DeviceDescriptorPtr->Endpoint0Size);
#endif
}
USB_ControlEndpointSize = DeviceDescriptorPtr->Endpoint0Size;
#endif
#if (defined(USB_SERIES_4_AVR) || defined(USB_SERIES_6_AVR) || defined(USB_SERIES_7_AVR))
if (USB_Options & USB_DEVICE_OPT_LOWSPEED)
USB_Device_SetLowSpeed();
else
USB_Device_SetFullSpeed();
USB_INT_Enable(USB_INT_VBUS);
#endif
Endpoint_ConfigureEndpoint(ENDPOINT_CONTROLEP, EP_TYPE_CONTROL,
ENDPOINT_DIR_OUT, USB_ControlEndpointSize,
@ -192,9 +182,7 @@ static void USB_Init_Host(void)
USB_Host_HostMode_On();
USB_Host_VBUS_Auto_Off();
USB_Host_VBUS_Manual_Enable();
USB_Host_VBUS_Manual_On();
USB_Host_VBUS_Auto_On();
USB_INT_Enable(USB_INT_SRPI);
USB_INT_Enable(USB_INT_BCERRI);

@ -122,8 +122,6 @@
/* 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.
*/
@ -193,10 +191,6 @@
* this function). To statically set the USB options, pass in the \c USE_STATIC_OPTIONS token,
* defined to the appropriate options masks. When the options are statically set, this
* parameter does not exist in the function prototype.
* \n\n
*
* \note The mode parameter does not exist on devices where only one mode is possible, such as USB
* AVR models which only implement the USB device mode in hardware.
*
* \see \ref Group_Device for the \c USB_DEVICE_OPT_* masks.
*/

Loading…
Cancel
Save