00001 /***************************************************************************\ 00002 00003 File........: ringbuffer.h 00004 Author(s)...: Gerhard Brünner 00005 Target(s)...: AVR_MEGA 00006 Compiler....: WIN_AVR 00007 Description.: Routines handling an ringbuffer with varialbe access-length 00008 00009 Defines the new datatype: ringbuffer_t 00010 00011 Revisions...: V2.02 00012 2009.01.18 - first shot.. 00013 2009.11.20 - removed toggle bit in struct _RINGBUFFER_T 00014 changed name of ringbuffer_t to _RINGBUFFER_T 00015 2009.12.27 - added global defines for buffer-datatype and access_width 00016 00017 \***************************************************************************/ 00018 00019 #ifndef _RINGBUFFER_H 00020 #define _RINGBUFFER_H 00022 /* Include-Dateien 00023 ****************************************************************************/ 00024 #include <stdio.h> 00025 00026 00027 /* Defines 00028 ****************************************************************************/ 00029 #define _RINGBUFFER_MAX_BUFFER_LEN 8 00030 #define _RINGBUFFER_DATATYPE_CONTENT uint8_t 00031 #define _RINGBUFFER_ACCESS_WIDTH uint8_t 00034 /* Typdefinitionen 00035 ****************************************************************************/ 00036 00039 typedef struct{ 00040 _RINGBUFFER_DATATYPE_CONTENT Data[_RINGBUFFER_MAX_BUFFER_LEN]; 00041 _RINGBUFFER_ACCESS_WIDTH WritePos; 00042 _RINGBUFFER_ACCESS_WIDTH ReadPos; 00043 uint8_t Overflow; 00044 } _RINGBUFFER_T; 00045 00046 00047 /* Funktions-Prototypen 00048 ****************************************************************************/ 00049 void ringbuffer_t_init( _RINGBUFFER_T *buf ); 00050 int8_t ringbuffer_add( _RINGBUFFER_T *buf, _RINGBUFFER_DATATYPE_CONTENT data); 00051 int8_t ringbuffer_read(_RINGBUFFER_T *buf, _RINGBUFFER_DATATYPE_CONTENT *data); 00052 _RINGBUFFER_ACCESS_WIDTH ringbuffer_flush(_RINGBUFFER_T *buf, _RINGBUFFER_DATATYPE_CONTENT *data); 00053 00054 /* Makros/Inlines 00055 ****************************************************************************/ 00056 00057 00058 #endif /* _RINGBUFFER_H */