CharRing
Simple character ring buffer for mocrocontrollers
charring.h
Go to the documentation of this file.
00001 
00014 #ifndef _CHARING_H_
00015 #define _CHARING_H_
00016 
00017 #include <stdint.h>
00018 
00020 #define CharRing_available(B)    ((B)->count)
00021 
00023 #define CharRing_free_space(B)   ((B)->len - (B)->count)
00024 
00026 #define CharRing_full(B)         ((B)->count == (B)->len)
00027 
00029 #define CharRing_empty(B)        ((B)->count == 0)
00030 
00031 
00037 typedef struct {
00038     char *buf;  
00039     int16_t head;  
00040     int16_t tail;  
00041     int16_t count;  
00042     int16_t len;  
00043 } CharRingBuf;
00044 
00045 CharRingBuf *CharRing_new(int16_t);
00046 void CharRing_free(CharRingBuf *);
00047 void CharRing_putchar(CharRingBuf *, char);
00048 char CharRing_getchar(CharRingBuf *);
00049 
00050 #endif /* _CHARING_H_ */
 All Data Structures Files Functions Variables Defines