#include <aversive.h>
#include <stdio.h>
Go to the source code of this file.
#define CIRBUF_FOREACH | ( | c, | |||
i, | |||||
e | ) |
Value:
for ( i=0, e=(c)->buf[(c)->start] ; \ i<((c)->len) ; \ i ++, e=(c)->buf[((c)->start+i)%((c)->maxlen)])
Definition at line 104 of file cirbuf.h.
Referenced by rdline_redisplay().
return the number of free elts
Definition at line 96 of file cirbuf.h.
Referenced by cirbuf_add_buf_head(), cirbuf_add_buf_tail(), and uart_send_9bits_nowait().
return current size of the circular buffer (number of used elements)
Definition at line 86 of file cirbuf.h.
Referenced by cirbuf_del_buf_head(), cirbuf_del_buf_tail(), cirbuf_get_buf_head(), cirbuf_get_buf_tail(), rdline_char_in(), rdline_get_buffer(), uart_9bits_recv_nowait(), and uart_send_next_char().
Return 1 if the circular buffer is empty
Definition at line 81 of file cirbuf.h.
Referenced by cirbuf_add_buf_head(), cirbuf_add_buf_tail(), cirbuf_del_buf_head(), cirbuf_del_buf_tail(), cirbuf_del_head_safe(), cirbuf_del_tail_safe(), rdline_char_in(), uart_recv_nowait(), uart_send_9bits_nowait(), uart_send_next_char(), and uart_send_nowait().
Return 1 if the circular buffer is full
Definition at line 76 of file cirbuf.h.
Referenced by cirbuf_add_head_safe(), cirbuf_add_tail_safe(), and uart_send_nowait().
#define dprintf | ( | args... | ) | do {} while(0) |
Definition at line 63 of file cirbuf.h.
Referenced by cirbuf_add_buf_head(), cirbuf_add_buf_tail(), cirbuf_get_buf_head(), and cirbuf_get_buf_tail().
typedef signed char cirbuf_int |
typedef unsigned char cirbuf_uint |
cirbuf_int cirbuf_add_buf_head | ( | struct cirbuf * | cbuf, | |
const char * | c, | |||
cirbuf_uint | n | |||
) |
Add a buffer at head of the circular buffer. 'c' is a pointer to a buffer, and n is the number of char to add. Return the number of copied bytes on success, or a negative value on error.
Definition at line 31 of file cirbuf_add_buf_head.c.
References cirbuf::buf, CIRBUF_GET_FREELEN, CIRBUF_IS_EMPTY, dprintf, EINVAL, cirbuf::len, cirbuf::maxlen, and cirbuf::start.
Referenced by uart_send_9bits(), and uart_send_9bits_nowait().
cirbuf_int cirbuf_add_buf_tail | ( | struct cirbuf * | cbuf, | |
const char * | c, | |||
cirbuf_uint | n | |||
) |
Add a buffer at tail of the circular buffer. 'c' is a pointer to a buffer, and n is the number of char to add. Return the number of copied bytes on success, or a negative value on error.
Definition at line 31 of file cirbuf_add_buf_tail.c.
References cirbuf::buf, CIRBUF_GET_FREELEN, CIRBUF_IS_EMPTY, dprintf, EINVAL, cirbuf::end, cirbuf::len, and cirbuf::maxlen.
Referenced by rdline_char_in().
void cirbuf_add_head | ( | struct cirbuf * | cbuf, | |
char | c | |||
) |
Add a character at head of the circular buffer. You _must_ check that you have enough free space in the buffer before calling this func.
Definition at line 52 of file cirbuf_add_head.c.
Referenced by rdline_char_in(), uart_send(), and uart_send_nowait().
cirbuf_int cirbuf_add_head_safe | ( | struct cirbuf * | cbuf, | |
char | c | |||
) |
Add a character at head of the circular buffer. Return 0 on success, or a negative value on error.
Definition at line 42 of file cirbuf_add_head.c.
References CIRBUF_IS_FULL, and EINVAL.
void cirbuf_add_tail | ( | struct cirbuf * | cbuf, | |
char | c | |||
) |
Add a character at tail of the circular buffer. You _must_ check that you have enough free space in the buffer before calling this func.
Definition at line 53 of file cirbuf_add_tail.c.
Referenced by rdline_char_in().
cirbuf_int cirbuf_add_tail_safe | ( | struct cirbuf * | cbuf, | |
char | c | |||
) |
Add a character at tail of the circular buffer. Return 0 on success, or a negative value on error.
Definition at line 43 of file cirbuf_add_tail.c.
References CIRBUF_IS_FULL, and EINVAL.
Referenced by rdline_char_in().
void cirbuf_align_left | ( | struct cirbuf * | cbuf | ) |
Set the start of the data to the index 0 of the internal buffer.
Definition at line 62 of file cirbuf_align.c.
References cirbuf::maxlen, and cirbuf::start.
Referenced by rdline_char_in(), and rdline_get_buffer().
void cirbuf_align_right | ( | struct cirbuf * | cbuf | ) |
Set the end of the data to the last index of the internal buffer.
Definition at line 77 of file cirbuf_align.c.
References cirbuf::end, cirbuf::maxlen, and cirbuf::start.
cirbuf_int cirbuf_del_buf_head | ( | struct cirbuf * | cbuf, | |
cirbuf_uint | size | |||
) |
Remove chars at the head of the circular buffer. Return 0 on success, or a negative value on error.
Definition at line 30 of file cirbuf_del_buf_head.c.
References CIRBUF_GET_LEN, CIRBUF_IS_EMPTY, EINVAL, cirbuf::len, cirbuf::maxlen, and cirbuf::start.
Referenced by rdline_char_in().
cirbuf_int cirbuf_del_buf_tail | ( | struct cirbuf * | cbuf, | |
cirbuf_uint | size | |||
) |
Remove chars at the tail of the circular buffer. Return 0 on success, or a negative value on error.
Definition at line 30 of file cirbuf_del_buf_tail.c.
References CIRBUF_GET_LEN, CIRBUF_IS_EMPTY, EINVAL, cirbuf::end, cirbuf::len, and cirbuf::maxlen.
Referenced by uart_9bits_recv_nowait(), and uart_send_next_char().
void cirbuf_del_head | ( | struct cirbuf * | cbuf | ) |
Remove a char at the head of the circular buffer. You _must_ check that buffer is not empty before calling the function.
Definition at line 50 of file cirbuf_del_head.c.
Referenced by rdline_char_in().
cirbuf_int cirbuf_del_head_safe | ( | struct cirbuf * | cbuf | ) |
Remove a char at the head of the circular buffer. Return 0 on success, or a negative value on error.
Definition at line 40 of file cirbuf_del_head.c.
References CIRBUF_IS_EMPTY, and EINVAL.
Referenced by rdline_char_in().
void cirbuf_del_tail | ( | struct cirbuf * | cbuf | ) |
Remove a char at the tail of the circular buffer. You _must_ check that buffer is not empty before calling the function.
Definition at line 51 of file cirbuf_del_tail.c.
Referenced by rdline_char_in(), uart_recv_nowait(), and uart_send_next_char().
cirbuf_int cirbuf_del_tail_safe | ( | struct cirbuf * | cbuf | ) |
Remove a char at the tail of the circular buffer. Return 0 on success, or a negative value on error.
Definition at line 41 of file cirbuf_del_tail.c.
References CIRBUF_IS_EMPTY, and EINVAL.
Referenced by rdline_char_in().
cirbuf_int cirbuf_get_buf_head | ( | struct cirbuf * | cbuf, | |
char * | c, | |||
cirbuf_uint | size | |||
) |
Copy a maximum of 'size' characters from the head of the circular buffer to a flat one pointed by 'c'. Return the number of copied chars.
Definition at line 30 of file cirbuf_get_buf_head.c.
References cirbuf::buf, CIRBUF_GET_LEN, dprintf, cirbuf::end, cirbuf::maxlen, and cirbuf::start.
Referenced by rdline_char_in().
cirbuf_int cirbuf_get_buf_tail | ( | struct cirbuf * | cbuf, | |
char * | c, | |||
cirbuf_uint | size | |||
) |
Copy a maximum of 'size' characters from the tail of the circular buffer to a flat one pointed by 'c'. Return the number of copied chars.
Definition at line 31 of file cirbuf_get_buf_tail.c.
References cirbuf::buf, CIRBUF_GET_LEN, dprintf, cirbuf::end, cirbuf::maxlen, and cirbuf::start.
Referenced by uart_9bits_recv_nowait(), and uart_send_next_char().
char cirbuf_get_head | ( | struct cirbuf * | cbuf | ) |
Return the head of the circular buffer. You _must_ check that buffer is not empty before calling the function.
Definition at line 30 of file cirbuf_get_head.c.
References cirbuf::buf, and cirbuf::start.
Referenced by rdline_char_in().
char cirbuf_get_tail | ( | struct cirbuf * | cbuf | ) |
Return the tail of the circular buffer. You _must_ check that buffer is not empty before calling the function.
Definition at line 30 of file cirbuf_get_tail.c.
References cirbuf::buf, and cirbuf::end.
Referenced by rdline_char_in(), uart_recv_nowait(), and uart_send_next_char().
void cirbuf_init | ( | struct cirbuf * | cbuf, | |
char * | buf, | |||
cirbuf_uint | start, | |||
cirbuf_uint | maxlen | |||
) |
Init the circular buffer
Definition at line 29 of file cirbuf.c.
References cirbuf::buf, cirbuf::end, cirbuf::len, cirbuf::maxlen, and cirbuf::start.
Referenced by rdline_char_in(), rdline_init(), rdline_newline(), and uart_setconf().