X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/8f6b4ddf764c3a54e42d00a7502c82c5c3e71b1c..3d28d53c3e2ae529933283e63a8b05f2ab1ce2be:/LUFA/Common/Common.h diff --git a/LUFA/Common/Common.h b/LUFA/Common/Common.h index 0923d513b..a59a213a8 100644 --- a/LUFA/Common/Common.h +++ b/LUFA/Common/Common.h @@ -1,21 +1,21 @@ /* LUFA Library - Copyright (C) Dean Camera, 2009. + Copyright (C) Dean Camera, 2010. dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ /* - Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, and distribute this software - and its documentation for any purpose and without fee is hereby - granted, provided that the above copyright notice appear in all - copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + Copyright 2010 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 + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -29,9 +29,10 @@ */ /** \file + * \brief Common library convenience macros and functions. * * This file contains macros which are common to all library elements, and which may be useful in user code. It - * also includes other common headers, such as Atomic.h, FunctionAttributes.h and BoardTypes.h. + * also includes other common headers, such as Atomic.h, Attributes.h and BoardTypes.h. */ /** @defgroup Group_Common Common Utility Headers - LUFA/Drivers/Common/Common.h @@ -57,13 +58,9 @@ /* Includes: */ #include - #include - #include - - #include "FunctionAttributes.h" + + #include "Attributes.h" #include "BoardTypes.h" - - #include /* Public Interface - May be used in end-application: */ /* Macros: */ @@ -103,7 +100,7 @@ #define JTAG_DEBUG_ASSERT(x) MACROS{ if (!(x)) { JTAG_DEBUG_BREAK(); } }MACROE /** Macro for testing condition "x" and writing debug data to the serial stream if false. As a - * prerequisite for this macro, the serial stream should be configured via the Serial_Stream driver. + * prerequisite for this macro, the serial stream should be configured via the Peripheral/SerialStream driver. * * The serial output takes the form "{FILENAME}: Function {FUNCTION NAME}, Line {LINE NUMBER}: Assertion * {x} failed." @@ -121,7 +118,7 @@ * * \ingroup Group_BitManip * - * \param Byte Byte of data whose bits are to be reversed + * \param[in] Byte Byte of data whose bits are to be reversed */ static inline uint8_t BitReverse(uint8_t Byte) ATTR_WARN_UNUSED_RESULT ATTR_CONST; static inline uint8_t BitReverse(uint8_t Byte) @@ -137,7 +134,7 @@ * * \ingroup Group_BitManip * - * \param Word Word of data whose bytes are to be swapped + * \param[in] Word Word of data whose bytes are to be swapped */ static inline uint16_t SwapEndian_16(uint16_t Word) ATTR_WARN_UNUSED_RESULT ATTR_CONST; static inline uint16_t SwapEndian_16(uint16_t Word) @@ -149,7 +146,7 @@ * * \ingroup Group_BitManip * - * \param DWord Double word of data whose bytes are to be swapped + * \param[in] DWord Double word of data whose bytes are to be swapped */ static inline uint32_t SwapEndian_32(uint32_t DWord) ATTR_WARN_UNUSED_RESULT ATTR_CONST; static inline uint32_t SwapEndian_32(uint32_t DWord) @@ -164,21 +161,21 @@ * * \ingroup Group_BitManip * - * \param Data Pointer to a number containing an even number of bytes to be reversed - * \param Bytes Length of the data in bytes + * \param[in,out] Data Pointer to a number containing an even number of bytes to be reversed + * \param[in] Bytes Length of the data in bytes */ - static inline void SwapEndian_n(uint8_t* Data, uint8_t Bytes); - static inline void SwapEndian_n(uint8_t* Data, uint8_t Bytes) + static inline void SwapEndian_n(void* Data, uint8_t Bytes); + static inline void SwapEndian_n(void* Data, uint8_t Bytes) { - uint8_t Temp; - + uint8_t* CurrDataPos = Data; + while (Bytes) { - Temp = *Data; - *Data = *(Data + Bytes - 1); - *(Data + Bytes) = Temp; + uint8_t Temp = *CurrDataPos; + *CurrDataPos = *(CurrDataPos + Bytes - 1); + *(CurrDataPos + Bytes - 1) = Temp; - Data++; + CurrDataPos++; Bytes -= 2; } }