Minor documentation improvements.
[pub/USBasp.git] / LUFA / Platform / XMEGA / ClockManagement.h
index 9b3b562..f51c73b 100644 (file)
@@ -1,13 +1,13 @@
 /*
              LUFA Library
-     Copyright (C) Dean Camera, 2012.
+     Copyright (C) Dean Camera, 2015.
 
   dean [at] fourwalledcubicle [dot] com
            www.lufa-lib.org
 */
 
 /*
-  Copyright 2012  Dean Camera (dean [at] fourwalledcubicle [dot] com)
+  Copyright 2015  Dean Camera (dean [at] fourwalledcubicle [dot] com)
 
   Permission to use, copy, modify, distribute, and sell this
   software and its documentation for any purpose is hereby granted
@@ -18,7 +18,7 @@
   advertising or publicity pertaining to distribution of the
   software without specific, written prior permission.
 
-  The author disclaim all warranties with regard to this
+  The author disclaims all warranties with regard to this
   software, including all implied warranties of merchantability
   and fitness.  In no event shall the author be liable for any
   special, indirect or consequential damages or any damages
  *  \defgroup Group_PlatformDrivers_XMEGAClocks Clock Management Driver - LUFA/Platform/XMEGA/ClockManagement.h
  *  \brief Module Clock Driver for the AVR USB XMEGA microcontrollers.
  *
- *  \section Sec_Dependencies Module Source Dependencies
+ *  \section Sec_PlatformDrivers_XMEGAClocks_Dependencies Module Source Dependencies
  *  The following files must be built with any user project that uses this module:
  *    - None
  *
- *  \section Sec_ModDescription Module Description
+ *  \section Sec_PlatformDrivers_XMEGAClocks_ModDescription Module Description
  *  Clock management driver for the AVR USB XMEGA microcontrollers. This driver allows for the configuration
  *  of the various clocks within the device to clock the various peripherals.
  *
@@ -70,7 +70,7 @@
 #define _XMEGA_CLOCK_MANAGEMENT_H_
 
        /* Includes: */
-               #include <LUFA/Common/Common.h>
+               #include "../../Common/Common.h"
 
        /* Enable C linkage for C++ Compilers: */
                #if defined(__cplusplus)
@@ -88,7 +88,7 @@
                                EXOSC_FREQ_16MHZ_MAX     = OSC_FRQRANGE_12TO16_gc, /**< External crystal oscillator equal to or slower than 16MHz. */
                        };
 
-                       /** Enum for the possible external oscillator statup times. */
+                       /** Enum for the possible external oscillator startup times. */
                        enum XMEGA_Extern_OSC_ClockStartup_t
                        {
                                EXOSC_START_6CLK         = OSC_XOSCSEL_EXTCLK_gc,      /**< Wait 6 clock cycles before startup (external clock). */
                         *  \param[in] Address  Address to write to, a memory address protected by the CCP mechanism
                         *  \param[in] Value    Value to write to the protected location
                         */
-                       static inline void XMEGACLK_CCP_Write(volatile void* Address, const uint8_t Value) ATTR_ALWAYS_INLINE;
+                       static inline void XMEGACLK_CCP_Write(volatile void* Address, const uint8_t Value) ATTR_NON_NULL_PTR_ARG(1) ATTR_ALWAYS_INLINE;
                        static inline void XMEGACLK_CCP_Write(volatile void* Address, const uint8_t Value)
                        {
                                __asm__ __volatile__ (
                                        : /* No output operands */
                                        : /* Input operands: */ "m" (RAMPZ), "e" (Address), "m" (CCP), "r" (CCP_IOREG_gc), "r" (Value)
                                        : /* Clobbered registers: */ "r30", "r31"
-                               ); 
+                               );
                        }
 
                        /** Starts the external oscillator of the XMEGA microcontroller, with the given options. This routine blocks until
                         *  the oscillator is ready for use.
                         *
                         *  \param[in] FreqRange  Frequency range of the external oscillator, a value from \ref XMEGA_Extern_OSC_ClockFrequency_t.
-                        *  \param[in] Startup    Statup time of the external oscillator, a value from \ref XMEGA_Extern_OSC_ClockStartup_t.
+                        *  \param[in] Startup    Startup time of the external oscillator, a value from \ref XMEGA_Extern_OSC_ClockStartup_t.
                         *
                         *  \return Boolean \c true if the external oscillator was successfully started, \c false if invalid parameters specified.
                         */
                         *
                         *  \return Boolean \c true if the internal oscillator was successfully started, \c false if invalid parameters specified.
                         */
-                       static inline uint8_t XMEGACLK_StartInternalOscillator(const uint8_t Source) ATTR_ALWAYS_INLINE;
-                       static inline uint8_t XMEGACLK_StartInternalOscillator(const uint8_t Source)
+                       static inline bool XMEGACLK_StartInternalOscillator(const uint8_t Source) ATTR_ALWAYS_INLINE;
+                       static inline bool XMEGACLK_StartInternalOscillator(const uint8_t Source)
                        {
                                switch (Source)
                                {
                                                OSC.CTRL |= OSC_RC32KEN_bm;
                                                while (!(OSC.STATUS & OSC_RC32KRDY_bm));
                                                return true;
+                                       default:
+                                               return false;
                                }
-
-                               return false;
                        }
 
                        /** Stops the given internal oscillator of the XMEGA microcontroller.
                                        case CLOCK_SRC_INT_RC32KHZ:
                                                OSC.CTRL &= ~OSC_RC32KEN_bm;
                                                return true;
+                                       default:
+                                               return false;
                                }
-
-                               return false;
                        }
 
                        /** Starts the PLL of the XMEGA microcontroller, with the given options. This routine blocks until the PLL is ready for use.
 
                                if (SourceFreq > Frequency)
                                  return false;
-                                 
+
                                if (MulFactor > 31)
                                  return false;
 
                                                              const uint8_t Reference,
                                                              const uint32_t Frequency)
                        {
-                               uint16_t DFLLCompare = (Frequency / 1000);
+                               uint16_t DFLLCompare = (Frequency / 1024);
 
                                switch (Source)
                                {
                         *
                         *  \param[in] Source      Clock source for the CPU core, a value from \ref XMEGA_System_ClockSource_t.
                         *
-                        *  \return Boolean \c true if the CPU core clock was sucessfully altered, \c false if invalid parameters specified.
+                        *  \return Boolean \c true if the CPU core clock was successfully altered, \c false if invalid parameters specified.
                         */
                        static inline bool XMEGACLK_SetCPUClockSource(const uint8_t Source) ATTR_ALWAYS_INLINE;
                        static inline bool XMEGACLK_SetCPUClockSource(const uint8_t Source)