forked from mfulz_github/qmk_firmware
Add experimental support for the UC3A0, UC3A1 and UC3A3 series AVR32 microcontrollers.
This commit is contained in:
parent
f301a4a21f
commit
6005a42150
|
@ -214,6 +214,12 @@
|
|||
*/
|
||||
#define GCC_FORCE_POINTER_ACCESS(StructPtr) __asm__ __volatile__("" : "=b" (StructPtr) : "0" (StructPtr))
|
||||
|
||||
/** Forces GCC to create a memory barrier, ensuring that memory accesses are not reordered past the barrier point.
|
||||
* This can be used before ordering-critical operations, to ensure that the compiler does not re-order the resulting
|
||||
* assembly output in an unexpected manner on sections of code that are ordering-specific.
|
||||
*/
|
||||
#define GCC_MEMORY_BARRIER() __asm__ __volatile__("" ::: "memory");
|
||||
|
||||
/* Inline Functions: */
|
||||
/** Function to reverse the individual bits in a byte - i.e. bit 7 is moved to bit 0, bit 6 to bit 1,
|
||||
* etc.
|
||||
|
|
|
@ -76,17 +76,24 @@
|
|||
*/
|
||||
#define NO_DESCRIPTOR 0
|
||||
|
||||
/** Macro to calculate the power value for the configuration descriptor, from a given number of milliamperes. */
|
||||
/** Macro to calculate the power value for the configuration descriptor, from a given number of milliamperes.
|
||||
*
|
||||
* \param[in] mA Maximum number of milliamps the device consumes when the given configuration is selected.
|
||||
*/
|
||||
#define USB_CONFIG_POWER_MA(mA) ((mA) >> 1)
|
||||
|
||||
/** Macro to calculate the Unicode length of a string with a given number of Unicode characters.
|
||||
* Should be used in string descriptor's headers for giving the string descriptor's byte length.
|
||||
*
|
||||
* \param[in] UnicodeChars Number of Unicode characters in the string text.
|
||||
*/
|
||||
#define USB_STRING_LEN(str) (sizeof(USB_Descriptor_Header_t) + ((str) << 1))
|
||||
#define USB_STRING_LEN(UnicodeChars) (sizeof(USB_Descriptor_Header_t) + ((UnicodeChars) << 1))
|
||||
|
||||
/** Macro to encode a given four digit floating point version number (e.g. 01.23) into Binary Coded
|
||||
* Decimal format for descriptor fields requiring BCD encoding, such as the USB version number in the
|
||||
* standard device descriptor.
|
||||
*
|
||||
* \param[in] x Version number to encode as a 16-bit little-endian number, as a floating point number.
|
||||
*/
|
||||
#define VERSION_BCD(x) CPU_TO_LE16((((VERSION_TENS(x) << 4) | VERSION_ONES(x)) << 8) | \
|
||||
((VERSION_TENTHS(x) << 4) | VERSION_HUNDREDTHS(x)))
|
||||
|
|
|
@ -104,11 +104,11 @@ void USB_ResetInterface(void)
|
|||
bool UIDModeSelectEnabled = AVR32_USBB.USBCON.uide;
|
||||
#endif
|
||||
|
||||
AVR32_PM.GCCTRL[USB_GCLK_USBB_INDEX].pllsel = !(USB_Options & USB_OPT_GCLK_SRC_OSC);
|
||||
AVR32_PM.GCCTRL[USB_GCLK_USBB_INDEX].oscsel = !(USB_Options & USB_OPT_GCLK_CHANNEL_0);
|
||||
AVR32_PM.GCCTRL[USB_GCLK_USBB_INDEX].diven = (F_CLOCK != 48000000UL);
|
||||
AVR32_PM.GCCTRL[USB_GCLK_USBB_INDEX].div = (F_CLOCK == 48000000UL) ? 0 : (uint32_t)(((F_CLOCK / 48000000UL) - 1) / 2);
|
||||
AVR32_PM.GCCTRL[USB_GCLK_USBB_INDEX].cen = true;
|
||||
AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].pllsel = !(USB_Options & USB_OPT_GCLK_SRC_OSC);
|
||||
AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].oscsel = !(USB_Options & USB_OPT_GCLK_CHANNEL_0);
|
||||
AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].diven = (F_CLOCK != USB_CLOCK_REQUIRED_FREQ);
|
||||
AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].div = (F_CLOCK == USB_CLOCK_REQUIRED_FREQ) ? 0 : (uint32_t)(((F_CLOCK / USB_CLOCK_REQUIRED_FREQ) - 1) / 2);
|
||||
AVR32_PM.GCCTRL[AVR32_PM_GCLK_USBB].cen = true;
|
||||
|
||||
USB_INT_DisableAllInterrupts();
|
||||
USB_INT_ClearAllInterrupts();
|
||||
|
|
|
@ -293,8 +293,12 @@
|
|||
|
||||
/* Private Interface - For use in library only: */
|
||||
#if !defined(__DOXYGEN__)
|
||||
/* Macros: */
|
||||
#define USB_GCLK_USBB_INDEX 3
|
||||
/* Macros: */
|
||||
#if defined(USB_SERIES_UC3A3_AVR)
|
||||
#define USB_CLOCK_REQUIRED_FREQ 12000000UL
|
||||
#else
|
||||
#define USB_CLOCK_REQUIRED_FREQ 48000000UL
|
||||
#endif
|
||||
|
||||
/* Function Prototypes: */
|
||||
#if defined(__INCLUDE_FROM_USB_CONTROLLER_C)
|
||||
|
|
|
@ -62,30 +62,50 @@
|
|||
|
||||
/* Public Interface - May be used in end-application: */
|
||||
#if defined(__DOXYGEN__)
|
||||
/** Indicates that the target AVR microcontroller belongs to the Series 2 USB controller
|
||||
/** Indicates that the target AVR microcontroller belongs to the Series 2 AVR8 USB controller
|
||||
* (i.e. AT90USBxxx2 or ATMEGAxxU2) when defined.
|
||||
*/
|
||||
#define USB_SERIES_2_AVR
|
||||
|
||||
/** Indicates that the target AVR microcontroller belongs to the Series 4 USB controller
|
||||
/** Indicates that the target AVR microcontroller belongs to the Series 4 AVR8 USB controller
|
||||
* (i.e. ATMEGAxxU4) when defined.
|
||||
*/
|
||||
#define USB_SERIES_4_AVR
|
||||
|
||||
/** Indicates that the target AVR microcontroller belongs to the Series 6 USB controller
|
||||
/** Indicates that the target AVR microcontroller belongs to the Series 6 AVR8 USB controller
|
||||
* (i.e. AT90USBxxx6) when defined.
|
||||
*/
|
||||
#define USB_SERIES_6_AVR
|
||||
|
||||
/** Indicates that the target AVR microcontroller belongs to the Series 7 USB controller
|
||||
/** Indicates that the target AVR microcontroller belongs to the Series 7 AVR8 USB controller
|
||||
* (i.e. AT90USBxxx7) when defined.
|
||||
*/
|
||||
#define USB_SERIES_7_AVR
|
||||
|
||||
/** Indicates that the target AVR microcontroller belongs to the UC3B Series USB controller
|
||||
* (i.e. AT32UC3B*) when defined.
|
||||
/** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A0 Series USB controller
|
||||
* (i.e. AT32UC3A0*) when defined.
|
||||
*/
|
||||
#define USB_SERIES_UC3B_AVR
|
||||
#define USB_SERIES_UC3A0_AVR
|
||||
|
||||
/** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A1 Series USB controller
|
||||
* (i.e. AT32UC3A1*) when defined.
|
||||
*/
|
||||
#define USB_SERIES_UC3A1_AVR
|
||||
|
||||
/** Indicates that the target AVR microcontroller belongs to the AVR32 UC3A3 Series USB controller
|
||||
* (i.e. AT32UC3A3*) when defined.
|
||||
*/
|
||||
#define USB_SERIES_UC3A3_AVR
|
||||
|
||||
/** Indicates that the target AVR microcontroller belongs to the AVR32 UC3B0 Series USB controller
|
||||
* (i.e. AT32UC3B0*) when defined.
|
||||
*/
|
||||
#define USB_SERIES_UC3B0_AVR
|
||||
|
||||
/** Indicates that the target AVR microcontroller belongs to the AVR32 UC3B1 Series USB controller
|
||||
* (i.e. AT32UC3B1*) when defined.
|
||||
*/
|
||||
#define USB_SERIES_UC3B1_AVR
|
||||
|
||||
/** Indicates that the target microcontroller and compilation settings allow for the
|
||||
* target to be configured in USB Device mode when defined.
|
||||
|
@ -117,11 +137,30 @@
|
|||
#define USB_SERIES_7_AVR
|
||||
#define USB_CAN_BE_DEVICE
|
||||
#define USB_CAN_BE_HOST
|
||||
#elif (defined(__AVR32_UC3B0512__) || defined(__AVR32_UC3B1512__) || \
|
||||
defined(__AVR32_UC3B0256__) || defined(__AVR32_UC3B1256__) || \
|
||||
defined(__AVR32_UC3B0128__) || defined(__AVR32_UC3B1128__) || \
|
||||
defined(__AVR32_UC3B064__) || defined(__AVR32_UC3B164__))
|
||||
#define USB_SERIES_UC3B_AVR
|
||||
#elif (defined(__AVR32_UC3A0512__) || defined(__AVR32_UC3A0256__) || \
|
||||
defined(__AVR32_UC3A0128__) || defined(__AVR32_UC3A064__))
|
||||
#define USB_SERIES_UC3A0_AVR
|
||||
#define USB_CAN_BE_DEVICE
|
||||
#define USB_CAN_BE_HOST
|
||||
#elif (defined(__AVR32_UC3A1512__) || defined(__AVR32_UC3A1256__) || \
|
||||
defined(__AVR32_UC3A1128__) || defined(__AVR32_UC3A164__))
|
||||
#define USB_SERIES_UC3A1_AVR
|
||||
#define USB_CAN_BE_DEVICE
|
||||
#define USB_CAN_BE_HOST
|
||||
#elif (defined(__AVR32_UC3A3256__) || defined(__AVR32_UC3A3256S__) || \
|
||||
defined(__AVR32_UC3A3128__) || defined(__AVR32_UC3A3128S__) || \
|
||||
defined(__AVR32_UC3A364__) || defined(__AVR32_UC3A364S__))
|
||||
#define USB_SERIES_UC3A3_AVR
|
||||
#define USB_CAN_BE_DEVICE
|
||||
#define USB_CAN_BE_HOST
|
||||
#elif (defined(__AVR32_UC3B0512__) || defined(__AVR32_UC3B0256__) || \
|
||||
defined(__AVR32_UC3B0128__) || defined(__AVR32_UC3B064__))
|
||||
#define USB_SERIES_UC3B0_AVR
|
||||
#define USB_CAN_BE_DEVICE
|
||||
#define USB_CAN_BE_HOST
|
||||
#elif (defined(__AVR32_UC3B1512__) || defined(__AVR32_UC3B1256__) || \
|
||||
defined(__AVR32_UC3B1128__) || defined(__AVR32_UC3B164__))
|
||||
#define USB_SERIES_UC3B1_AVR
|
||||
#define USB_CAN_BE_DEVICE
|
||||
#define USB_CAN_BE_HOST
|
||||
#endif
|
||||
|
@ -153,7 +192,7 @@
|
|||
#endif
|
||||
|
||||
#if (!defined(USB_CAN_BE_DEVICE) && !defined(USB_CAN_BE_HOST))
|
||||
#error The currently selected architecture is not supported under the USB component of the library.
|
||||
#error The currently selected device or architecture is not supported under the USB component of the library.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue