3      Copyright (C) Dean Camera, 2009. 
   5   dean [at] fourwalledcubicle [dot] com 
   6       www.fourwalledcubicle.com 
  10   Copyright 2009  Denver Gingerich (denver [at] ossguy [dot] com) 
  11   Copyright 2009  Dean Camera (dean [at] fourwalledcubicle [dot] com) 
  13   Permission to use, copy, modify, and distribute this software 
  14   and its documentation for any purpose and without fee is hereby 
  15   granted, provided that the above copyright notice appear in all 
  16   copies and that both that the copyright notice and this 
  17   permission notice and warranty disclaimer appear in supporting 
  18   documentation, and that the name of the author not be used in 
  19   advertising or publicity pertaining to distribution of the 
  20   software without specific, written prior permission. 
  22   The author disclaim all warranties with regard to this 
  23   software, including all implied warranties of merchantability 
  24   and fitness.  In no event shall the author be liable for any 
  25   special, indirect or consequential damages or any damages 
  26   whatsoever resulting from loss of use, data or profits, whether 
  27   in an action of contract, negligence or other tortious action, 
  28   arising out of or in connection with the use or performance of 
  34  *  Header file for CircularBitBuffer.c. 
  37 #ifndef _CIRCULARBITBUFFER_H_ 
  38 #define _CIRCULARBITBUFFER_H_ 
  44                 #include <LUFA/Common/Common.h> 
  47                 #if (defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \ 
  48                      defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__)) || defined(__DOXYGEN__) 
  49                         /** Maximum number of bits which can be stored into a bit buffer. The memory usage is one eighth of this value per buffer. */ 
  56                 /** Type define for a pointer to a bit in a bit buffer. */ 
  59                         uint8_t* CurrentByte
; /**< Pointer to the current byte in the buffer */ 
  60                         uint8_t  ByteMask
; /**< Mask of the current bit in the buffer */ 
  63                 /** Type define for a circular packet bit buffer. */ 
  66                         uint8_t            Data
[MAX_BITS 
/ 8]; /**< Buffer to hold the stored bits in packed form */ 
  67                         uint16_t           Elements
; /**< Number of stored bits in the bit buffer */ 
  69                         BitBufferPointer_t In
; /**< Bit pointer to the next storage location in the buffer */ 
  70                         BitBufferPointer_t Out
; /**< Bit pointer to the next retrieval location in the buffer */ 
  73         /* Function Prototypes: */       
  74                 /** Initializes or resets a given bit buffer, ready to store new bits. 
  76                  *  \param[in,out] Buffer  Bit buffer to initialize 
  78                 void BitBuffer_Init(BitBuffer_t
* Buffer
) ATTR_NON_NULL_PTR_ARG(1); 
  80                 /** Stores a bit into the next location inside a given bit buffer. 
  82                  *  \param[in,out] Buffer  Bit buffer to store a bit into 
  83                  *  \param[in] Bit  Bit to store into the buffer 
  85                 void BitBuffer_StoreNextBit(BitBuffer_t
* Buffer
, bool Bit
) ATTR_NON_NULL_PTR_ARG(1); 
  87                 /** Retrieves a bit from the next location inside a given bit buffer. 
  89                  *  \param[in,out] Buffer  Bit buffer to store a bit into 
  91                  *  \return Next bit from the buffer 
  93                 bool BitBuffer_GetNextBit(BitBuffer_t
* Buffer
) ATTR_NON_NULL_PTR_ARG(1);