Update XMEGA platform clock management example code to suit the currently released...
authorDean Camera <dean@fourwalledcubicle.com>
Tue, 25 Oct 2011 04:28:22 +0000 (04:28 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Tue, 25 Oct 2011 04:28:22 +0000 (04:28 +0000)
Cleanups to the UC3 endpoint/pipe multi byte read code.

LUFA/Drivers/USB/Core/UC3/Endpoint_UC3.h
LUFA/Drivers/USB/Core/UC3/Pipe_UC3.h
LUFA/Platform/XMEGA/ClockManagement.h

index 8bbb605..3fd0d4c 100644 (file)
                        static inline uint16_t Endpoint_Read_16_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
                        static inline uint16_t Endpoint_Read_16_LE(void)
                        {
                        static inline uint16_t Endpoint_Read_16_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
                        static inline uint16_t Endpoint_Read_16_LE(void)
                        {
-                               uint16_t Byte1 = *(USB_EndpointFIFOPos[USB_SelectedEndpoint]++);
                                uint16_t Byte0 = *(USB_EndpointFIFOPos[USB_SelectedEndpoint]++);
                                uint16_t Byte0 = *(USB_EndpointFIFOPos[USB_SelectedEndpoint]++);
+                               uint16_t Byte1 = *(USB_EndpointFIFOPos[USB_SelectedEndpoint]++);
 
 
-                               return ((Byte0 << 8) | Byte1);
+                               return ((Byte1 << 8) | Byte0);
                        }
 
                        /** Reads two bytes from the currently selected endpoint's bank in big endian format, for OUT
                        }
 
                        /** Reads two bytes from the currently selected endpoint's bank in big endian format, for OUT
                        static inline uint32_t Endpoint_Read_32_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
                        static inline uint32_t Endpoint_Read_32_LE(void)
                        {
                        static inline uint32_t Endpoint_Read_32_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
                        static inline uint32_t Endpoint_Read_32_LE(void)
                        {
-                               uint32_t Byte3 = *(USB_EndpointFIFOPos[USB_SelectedEndpoint]++);
-                               uint32_t Byte2 = *(USB_EndpointFIFOPos[USB_SelectedEndpoint]++);
-                               uint32_t Byte1 = *(USB_EndpointFIFOPos[USB_SelectedEndpoint]++);
                                uint32_t Byte0 = *(USB_EndpointFIFOPos[USB_SelectedEndpoint]++);
                                uint32_t Byte0 = *(USB_EndpointFIFOPos[USB_SelectedEndpoint]++);
+                               uint32_t Byte1 = *(USB_EndpointFIFOPos[USB_SelectedEndpoint]++);
+                               uint32_t Byte2 = *(USB_EndpointFIFOPos[USB_SelectedEndpoint]++);
+                               uint32_t Byte3 = *(USB_EndpointFIFOPos[USB_SelectedEndpoint]++);
 
 
-                               return ((Byte0 << 24) | (Byte1 << 16) | (Byte2 << 8) | Byte3);
+                               return ((Byte3 << 24) | (Byte2 << 16) | (Byte1 << 8) | Byte0);
                        }
 
                        /** Reads four bytes from the currently selected endpoint's bank in big endian format, for OUT
                        }
 
                        /** Reads four bytes from the currently selected endpoint's bank in big endian format, for OUT
index 25957f2..26346e9 100644 (file)
                        static inline uint16_t Pipe_Read_16_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
                        static inline uint16_t Pipe_Read_16_LE(void)
                        {
                        static inline uint16_t Pipe_Read_16_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
                        static inline uint16_t Pipe_Read_16_LE(void)
                        {
-                               uint16_t Byte1 = *(USB_PipeFIFOPos[USB_SelectedPipe]++);
                                uint16_t Byte0 = *(USB_PipeFIFOPos[USB_SelectedPipe]++);
                                uint16_t Byte0 = *(USB_PipeFIFOPos[USB_SelectedPipe]++);
+                               uint16_t Byte1 = *(USB_PipeFIFOPos[USB_SelectedPipe]++);
 
 
-                               return ((Byte0 << 8) | Byte1);
+                               return ((Byte1 << 8) | Byte0);
                        }
 
                        /** Reads two bytes from the currently selected pipe's bank in big endian format, for OUT
                        }
 
                        /** Reads two bytes from the currently selected pipe's bank in big endian format, for OUT
                        static inline uint32_t Pipe_Read_32_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
                        static inline uint32_t Pipe_Read_32_LE(void)
                        {
                        static inline uint32_t Pipe_Read_32_LE(void) ATTR_WARN_UNUSED_RESULT ATTR_ALWAYS_INLINE;
                        static inline uint32_t Pipe_Read_32_LE(void)
                        {
-                               uint32_t Byte3 = *(USB_PipeFIFOPos[USB_SelectedPipe]++);
-                               uint32_t Byte2 = *(USB_PipeFIFOPos[USB_SelectedPipe]++);
-                               uint32_t Byte1 = *(USB_PipeFIFOPos[USB_SelectedPipe]++);
                                uint32_t Byte0 = *(USB_PipeFIFOPos[USB_SelectedPipe]++);
                                uint32_t Byte0 = *(USB_PipeFIFOPos[USB_SelectedPipe]++);
+                               uint32_t Byte1 = *(USB_PipeFIFOPos[USB_SelectedPipe]++);
+                               uint32_t Byte2 = *(USB_PipeFIFOPos[USB_SelectedPipe]++);
+                               uint32_t Byte3 = *(USB_PipeFIFOPos[USB_SelectedPipe]++);
 
 
-                               return ((Byte0 << 24) | (Byte1 << 16) | (Byte2 << 8) | Byte3);
+                               return ((Byte3 << 24) | (Byte2 << 16) | (Byte1 << 8) | Byte0);
                        }
 
                        /** Reads four bytes from the currently selected pipe's bank in big endian format, for OUT
                        }
 
                        /** Reads four bytes from the currently selected pipe's bank in big endian format, for OUT
index 04b91e0..18d7c63 100644 (file)
  *
  *  Usage Example:
  *  \code
  *
  *  Usage Example:
  *  \code
- *             #include <LUFA/Platform/XMEGA/ClockManagement.h>
- *
- *             void main(void)
- *             {
- *                     // Start the internal 32MHz RC oscillator and switch the CPU core to run from it
- *                     XMEGACLK_StartInternalOscillator(CLOCK_SRC_INT_RC32MHZ);
- *                     XMEGACLK_SetCPUClockSource(CLOCK_SRC_INT_RC32MHZ, F_CPU);
- *
- *                     // Start the external oscillator and multiply up the frequency
- *                     XMEGACLK_StartExternalOscillator(EXOSC_FREQ_9MHZ_MAX, EXOSC_START_1KCLK);
- *                     XMEGACLK_StartPLL(CLOCK_SRC_XOSC, 8000000, F_USB);
- *             }
+ *     #include <LUFA/Platform/XMEGA/ClockManagement.h>
+ *     
+ *     void main(void)
+ *     {
+ *             // Start the PLL to multiply the 2MHz RC oscillator to 32MHz and switch the CPU core to run from it
+ *             XMEGACLK_StartPLL(CLOCK_SRC_INT_RC2MHZ, 2000000, 32000000);
+ *             XMEGACLK_SetCPUClockSource(CLOCK_SRC_PLL, F_CPU);
+ *     
+ *             // Start the 32MHz internal RC oscillator and start the DFLL to increase it to 48MHz using the USB SOF as a reference
+ *             XMEGACLK_StartInternalOscillator(CLOCK_SRC_INT_RC32MHZ);
+ *             XMEGACLK_StartDFLL(CLOCK_SRC_INT_RC32MHZ, DFLL_REF_INT_USBSOF, 48000000);
+ *     }
  *  \endcode
  *
  *  @{
  *  \endcode
  *
  *  @{