New HID report item macros (with HID_RI_ prefix) to allow for easy creation and editi...
[pub/USBasp.git] / LUFA / Drivers / Misc / RingBuffer.h
index ced99f3..37e8a1b 100644 (file)
@@ -1,13 +1,13 @@
 /*\r
              LUFA Library\r
 /*\r
              LUFA Library\r
-     Copyright (C) Dean Camera, 2010.\r
+     Copyright (C) Dean Camera, 2011.\r
 \r
   dean [at] fourwalledcubicle [dot] com\r
            www.lufa-lib.org\r
 */\r
 \r
 /*\r
 \r
   dean [at] fourwalledcubicle [dot] com\r
            www.lufa-lib.org\r
 */\r
 \r
 /*\r
-  Copyright 2010  Dean Camera (dean [at] fourwalledcubicle [dot] com)\r
+  Copyright 2011  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
 \r
   Permission to use, copy, modify, distribute, and sell this\r
   software and its documentation for any purpose is hereby granted\r
@@ -35,9 +35,9 @@
  *  different sizes to suit different needs.\r
  *\r
  *  Note that for each buffer, insertion and removal operations may occur at the same time (via\r
  *  different sizes to suit different needs.\r
  *\r
  *  Note that for each buffer, insertion and removal operations may occur at the same time (via\r
- *  a multithreaded ISR based system) however the same kind of operation (two or more insertions\r
+ *  a multi-threaded ISR based system) however the same kind of operation (two or more insertions\r
  *  or deletions) must not overlap. If there is possibility of two or more of the same kind of\r
  *  or deletions) must not overlap. If there is possibility of two or more of the same kind of\r
- *  operating occuring at the same point in time, atomic (mutex) locking should be used.\r
+ *  operating occurring at the same point in time, atomic (mutex) locking should be used.\r
  */\r
  \r
 /** \ingroup Group_MiscDrivers\r
  */\r
  \r
 /** \ingroup Group_MiscDrivers\r
@@ -52,9 +52,9 @@
  *  different sizes to suit different needs.\r
  *\r
  *  Note that for each buffer, insertion and removal operations may occur at the same time (via\r
  *  different sizes to suit different needs.\r
  *\r
  *  Note that for each buffer, insertion and removal operations may occur at the same time (via\r
- *  a multithreaded ISR based system) however the same kind of operation (two or more insertions\r
+ *  a multi-threaded ISR based system) however the same kind of operation (two or more insertions\r
  *  or deletions) must not overlap. If there is possibility of two or more of the same kind of\r
  *  or deletions) must not overlap. If there is possibility of two or more of the same kind of\r
- *  operating occuring at the same point in time, atomic (mutex) locking should be used.\r
+ *  operating occurring at the same point in time, atomic (mutex) locking should be used.\r
  *\r
  *  \section Sec_ExampleUsage Example Usage\r
  *  The following snippet is an example of how this module may be used within a typical\r
  *\r
  *  \section Sec_ExampleUsage Example Usage\r
  *  The following snippet is an example of how this module may be used within a typical\r
                #include <LUFA/Common/Common.h>\r
 \r
        /* Type Defines: */\r
                #include <LUFA/Common/Common.h>\r
 \r
        /* Type Defines: */\r
-               /** Type define for a new ring buffer object. Buffers should be initialized via a call to\r
+               /** \brief Ring Buffer Management Structure.\r
+                *\r
+                *  Type define for a new ring buffer object. Buffers should be initialized via a call to\r
                 *  \ref RingBuffer_InitBuffer() before use.\r
                 */\r
                typedef struct\r
                 *  \ref RingBuffer_InitBuffer() before use.\r
                 */\r
                typedef struct\r
                 */\r
                static inline void RingBuffer_InitBuffer(RingBuffer_t* Buffer, uint8_t* const DataPtr, const uint16_t Size)\r
                {\r
                 */\r
                static inline void RingBuffer_InitBuffer(RingBuffer_t* Buffer, uint8_t* const DataPtr, const uint16_t Size)\r
                {\r
+                       GCC_FORCE_POINTER_ACCESS(Buffer);\r
+\r
                        ATOMIC_BLOCK(ATOMIC_RESTORESTATE)\r
                        ATOMIC_BLOCK(ATOMIC_RESTORESTATE)\r
-                       {\r
-                               GCC_FORCE_POINTER_ACCESS(Buffer);\r
-                               \r
+                       {       \r
                                Buffer->In     = DataPtr;\r
                                Buffer->Out    = DataPtr;\r
                                Buffer->Start  = &DataPtr[0];\r
                                Buffer->In     = DataPtr;\r
                                Buffer->Out    = DataPtr;\r
                                Buffer->Start  = &DataPtr[0];\r
                 *\r
                 *  \param[in,out] Buffer  Pointer to a ring buffer structure to insert into.\r
                 *\r
                 *\r
                 *  \param[in,out] Buffer  Pointer to a ring buffer structure to insert into.\r
                 *\r
-                *  \return Boolean true if the buffer contains no free space, false otherwise.\r
+                *  \return Boolean \c true if the buffer contains no free space, false otherwise.\r
                 */\r
                static inline bool RingBuffer_IsFull(RingBuffer_t* const Buffer)\r
                {\r
                 */\r
                static inline bool RingBuffer_IsFull(RingBuffer_t* const Buffer)\r
                {\r
                 *\r
                 *  \param[in,out] Buffer  Pointer to a ring buffer structure to insert into.\r
                 *\r
                 *\r
                 *  \param[in,out] Buffer  Pointer to a ring buffer structure to insert into.\r
                 *\r
-                *  \return Boolean true if the buffer contains no free space, false otherwise.\r
+                *  \return Boolean \c true if the buffer contains no free space, false otherwise.\r
                 */\r
                static inline bool RingBuffer_IsEmpty(RingBuffer_t* const Buffer)\r
                {\r
                 */\r
                static inline bool RingBuffer_IsEmpty(RingBuffer_t* const Buffer)\r
                {\r
                 *  \param[in,out] Buffer  Pointer to a ring buffer structure to insert into.\r
                 *  \param[in]     Data    Data element to insert into the buffer.\r
                 */\r
                 *  \param[in,out] Buffer  Pointer to a ring buffer structure to insert into.\r
                 *  \param[in]     Data    Data element to insert into the buffer.\r
                 */\r
-               static inline void RingBuffer_Insert(RingBuffer_t* const Buffer,\r
+               static inline void RingBuffer_Insert(RingBuffer_t* Buffer,\r
                                                     const uint8_t Data)\r
                {\r
                                                     const uint8_t Data)\r
                {\r
+                       GCC_FORCE_POINTER_ACCESS(Buffer);\r
+\r
                        *Buffer->In = Data;\r
 \r
                        if (++Buffer->In == Buffer->End)\r
                        *Buffer->In = Data;\r
 \r
                        if (++Buffer->In == Buffer->End)\r
                 *\r
                 *  \return Next data element stored in the buffer.\r
                 */\r
                 *\r
                 *  \return Next data element stored in the buffer.\r
                 */\r
-               static inline uint8_t RingBuffer_Remove(RingBuffer_t* const Buffer)\r
+               static inline uint8_t RingBuffer_Remove(RingBuffer_t* Buffer)\r
                {\r
                {\r
+                       GCC_FORCE_POINTER_ACCESS(Buffer);\r
+               \r
                        uint8_t Data = *Buffer->Out;\r
 \r
                        if (++Buffer->Out == Buffer->End)\r
                        uint8_t Data = *Buffer->Out;\r
 \r
                        if (++Buffer->Out == Buffer->End)\r