00001 00011 #ifndef BUFFER_H 00012 #define BUFFER_H 00013 00014 #include <inttypes.h> 00015 00016 #ifndef BUFFER_BITS 00017 00019 #define BUFFER_BITS 7 00020 #endif 00021 00024 #define buffer_init( b ) b.head = b.tail = 0 00025 00028 struct buffer 00029 { 00030 unsigned char data[1<<BUFFER_BITS]; 00031 uint8_t head, tail; 00032 }; 00033 00043 char buffer_put( struct buffer *b, char c ); 00044 00055 char buffer_get( struct buffer *b ); 00056 00062 uint8_t buffer_size( struct buffer *b ); 00063 00064 #endif