Add FatFS library to the Webserver project, extend the HTTP server so that it now...
[pub/USBasp.git] / LUFA / Common / Common.h
index ed2d1bc..2ddb58c 100644 (file)
@@ -1,21 +1,21 @@
 /*\r
              LUFA Library\r
-     Copyright (C) Dean Camera, 2009.\r
+     Copyright (C) Dean Camera, 2010.\r
               \r
   dean [at] fourwalledcubicle [dot] com\r
       www.fourwalledcubicle.com\r
 */\r
 \r
 /*\r
-  Copyright 2009  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
-\r
-  Permission to use, copy, modify, and distribute this software\r
-  and its documentation for any purpose and without fee is hereby\r
-  granted, provided that the above copyright notice appear in all\r
-  copies and that both that the copyright notice and this\r
-  permission notice and warranty disclaimer appear in supporting\r
-  documentation, and that the name of the author not be used in\r
-  advertising or publicity pertaining to distribution of the\r
+  Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+\r
+  Permission to use, copy, modify, distribute, and sell this \r
+  software and its documentation for any purpose is hereby granted\r
+  without fee, provided that the above copyright notice appear in \r
+  all copies and that both that the copyright notice and this\r
+  permission notice and warranty disclaimer appear in supporting \r
+  documentation, and that the name of the author not be used in \r
+  advertising or publicity pertaining to distribution of the \r
   software without specific, written prior permission.\r
 \r
   The author disclaim all warranties with regard to this\r
 /** \file\r
  *\r
  *  This file contains macros which are common to all library elements, and which may be useful in user code. It\r
- *  also includes other common headees, such as Atomic.h, FunctionAttributes.h and BoardTypes.h.\r
+ *  also includes other common headers, such as Atomic.h, FunctionAttributes.h and BoardTypes.h.\r
+ */\r
\r
+/** @defgroup Group_Common Common Utility Headers - LUFA/Drivers/Common/Common.h\r
+ *\r
+ *  Common utility headers containing macros, functions, enums and types which are common to all\r
+ *  aspects of the library.\r
+ *\r
+ *  @{\r
+ */\r
+\r
+/** @defgroup Group_Debugging Debugging Macros\r
+ *\r
+ *  Macros for debugging use.\r
+ */\r
\r
+/** @defgroup Group_BitManip Endian and Bit Macros\r
+ *\r
+ *  Functions for swapping endianness and reversing bit orders.\r
  */\r
 \r
 #ifndef __COMMON_H__\r
 \r
        /* Includes: */\r
                #include <avr/io.h>\r
-               #include <stdio.h>\r
-               #include <avr/version.h>\r
-               \r
+       \r
                #include "FunctionAttributes.h"\r
                #include "BoardTypes.h"\r
-               \r
-               #include <alloca.h>\r
 \r
        /* Public Interface - May be used in end-application: */\r
                /* Macros: */           \r
-                       /** Macro for encasing other multi-statment macros. This should be used along with an opening brace\r
+                       /** Macro for encasing other multi-statement macros. This should be used along with an opening brace\r
                         *  before the start of any multi-statement macro, so that the macros contents as a whole are treated\r
-                        *  as a discreete block and not as a list of seperate statements which may cause problems when used as\r
-                        *  a block (such as inline IF statments).\r
+                        *  as a discrete block and not as a list of separate statements which may cause problems when used as\r
+                        *  a block (such as inline IF statements).\r
                         */\r
                        #define MACROS                  do\r
 \r
-                       /** Macro for encasing other multi-statment macros. This should be used along with a preceeding closing\r
+                       /** Macro for encasing other multi-statement macros. This should be used along with a preceding closing\r
                         *  brace at the end of any multi-statement macro, so that the macros contents as a whole are treated\r
-                        *  as a discreete block and not as a list of seperate statements which may cause problems when used as\r
-                        *  a block (such as inline IF statments).\r
+                        *  as a discrete block and not as a list of separate statements which may cause problems when used as\r
+                        *  a block (such as inline IF statements).\r
                         */\r
                        #define MACROE                  while (0)\r
                        \r
-                       /** Defines a volatile NOP statment which cannot be optimized out by the compiler, and thus can always\r
+                       /** Defines a volatile NOP statement which cannot be optimized out by the compiler, and thus can always\r
                         *  be set as a breakpoint in the resulting code. Useful for debugging purposes, where the optimizer\r
                         *  removes/reorders code to the point where break points cannot reliably be set.\r
+                        *\r
+                        *  \ingroup Group_Debugging\r
                         */\r
                        #define JTAG_DEBUG_POINT()      asm volatile ("NOP" ::)\r
 \r
-                       /** Defines an explicit JTAG break point in the resulting binary via the ASM BREAK statment. When\r
-                        *  a JTAG is used, this causes the program execution to halt when reached until manually resumed. */\r
+                       /** Defines an explicit JTAG break point in the resulting binary via the ASM BREAK statement. When\r
+                        *  a JTAG is used, this causes the program execution to halt when reached until manually resumed.\r
+                        *\r
+                        *  \ingroup Group_Debugging\r
+                        */\r
                        #define JTAG_DEBUG_BREAK()      asm volatile ("BREAK" ::)\r
                        \r
-                       /** Macro for testing condition "x" and breaking via JTAG_DEBUG_BREAK() if the condition is false. */\r
+                       /** Macro for testing condition "x" and breaking via JTAG_DEBUG_BREAK() if the condition is false.\r
+                        *\r
+                        *  \ingroup Group_Debugging\r
+                       */\r
                        #define JTAG_DEBUG_ASSERT(x)    MACROS{ if (!(x)) { JTAG_DEBUG_BREAK(); } }MACROE\r
 \r
                        /** Macro for testing condition "x" and writing debug data to the serial stream if false. As a\r
-                        *  prerequisite for this macro, the serial stream should be configured via the Serial_Stream driver.\r
+                        *  prerequisite for this macro, the serial stream should be configured via the Peripheral/SerialStream driver.\r
                         *\r
                         *  The serial output takes the form "{FILENAME}: Function {FUNCTION NAME}, Line {LINE NUMBER}: Assertion\r
                         *  {x} failed."\r
+                        *\r
+                        *  \ingroup Group_Debugging\r
                         */\r
                        #define SERIAL_STREAM_ASSERT(x) MACROS{ if (!(x)) { printf_P(PSTR("%s: Function \"%s\", Line %d: "   \\r
                                                                                                                                "Assertion \"%s\" failed.\r\n"),   \\r
                        /** Function to reverse the individual bits in a byte - i.e. bit 7 is moved to bit 0, bit 6 to bit 1,\r
                         *  etc.\r
                         *\r
-                        *  \param Byte   Byte of data whose bits are to be reversed\r
+                        *  \ingroup Group_BitManip\r
+                        *\r
+                        *  \param[in] Byte   Byte of data whose bits are to be reversed\r
                         */\r
                        static inline uint8_t BitReverse(uint8_t Byte) ATTR_WARN_UNUSED_RESULT ATTR_CONST;\r
                        static inline uint8_t BitReverse(uint8_t Byte)\r
                        \r
                        /** Function to reverse the byte ordering of the individual bytes in a 16 bit number.\r
                         *\r
-                        *  \param Word   Word of data whose bytes are to be swapped\r
+                        *  \ingroup Group_BitManip\r
+                        *\r
+                        *  \param[in] Word   Word of data whose bytes are to be swapped\r
                         */\r
                        static inline uint16_t SwapEndian_16(uint16_t Word) ATTR_WARN_UNUSED_RESULT ATTR_CONST;\r
                        static inline uint16_t SwapEndian_16(uint16_t Word)\r
 \r
                        /** Function to reverse the byte ordering of the individual bytes in a 32 bit number.\r
                         *\r
-                        *  \param DWord   Double word of data whose bytes are to be swapped\r
+                        *  \ingroup Group_BitManip\r
+                        *\r
+                        *  \param[in] DWord   Double word of data whose bytes are to be swapped\r
                         */\r
                        static inline uint32_t SwapEndian_32(uint32_t DWord) ATTR_WARN_UNUSED_RESULT ATTR_CONST;\r
                        static inline uint32_t SwapEndian_32(uint32_t DWord)\r
 \r
                        /** Function to reverse the byte ordering of the individual bytes in a n byte number.\r
                         *\r
-                        *  \param Data   Pointer to a number containing an even number of bytes to be reversed\r
-                        *  \param Bytes  Length of the data in bytes\r
+                        *  \ingroup Group_BitManip\r
+                        *\r
+                        *  \param[in,out] Data  Pointer to a number containing an even number of bytes to be reversed\r
+                        *  \param[in] Bytes  Length of the data in bytes\r
                         */\r
                        static inline void SwapEndian_n(uint8_t* Data, uint8_t Bytes);\r
                        static inline void SwapEndian_n(uint8_t* Data, uint8_t Bytes)\r
                                {\r
                                        Temp = *Data;\r
                                        *Data = *(Data + Bytes - 1);\r
-                                       *(Data + Bytes) = Temp;\r
+                                       *(Data + Bytes - 1) = Temp;\r
 \r
                                        Data++;\r
                                        Bytes -= 2;\r
                        }\r
 \r
 #endif\r
+\r
+/** @} */\r