diff options
author | Karel Kočí <cynerd@email.cz> | 2016-03-20 16:39:30 +0100 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2016-03-20 16:39:30 +0100 |
commit | 9439c6f1caffd938673018f3af7460b33a12528e (patch) | |
tree | 55eb32bfb1f90a489982853f698619a2083a4285 /docs/modules/utils/buffer.md | |
parent | 1ac3026c039cb15dd8c110c84215096854c3c804 (diff) | |
download | avr-ioe-9439c6f1caffd938673018f3af7460b33a12528e.tar.gz avr-ioe-9439c6f1caffd938673018f3af7460b33a12528e.tar.bz2 avr-ioe-9439c6f1caffd938673018f3af7460b33a12528e.zip |
Another work progress
Diffstat (limited to 'docs/modules/utils/buffer.md')
-rw-r--r-- | docs/modules/utils/buffer.md | 105 |
1 files changed, 0 insertions, 105 deletions
diff --git a/docs/modules/utils/buffer.md b/docs/modules/utils/buffer.md deleted file mode 100644 index 4365c25..0000000 --- a/docs/modules/utils/buffer.md +++ /dev/null @@ -1,105 +0,0 @@ -buffer -====== -In whole project are used ring buffers. This is so common that handling them is -exported to separated header file. In fact it contains two implementations of -buffers. One implementation is defined using preprocessor macros. Another one is -plain C code. - -## Preprocessor implementation -Preprocessor implementation is expected to be faster and less memory intense. Also -more suitable for buffers of simple types (such us int). But this buffer has to be -defined with known size at compile time and can't be resized. All this makes it -good implementation for IO devices input and output buffers, but less for more -complicated tasks containing for example sorting. - -### Macros -#### IOEBUFFER -```C -IOEBUFFER(type, name, size) -``` -This macro defines buffer. Use it to define new buffer. -##### Parameters -| type | Specify type of elements in buffer. Can be any valid C type | -| name | Name of buffer. This is C variable name. | -| size | Numerical value of buffer size | - -#### IOEBUFFER_INIT -```C -IOEBUFFER_INIT(name, size) -``` -Use this to initialize buffer. Parameter `size` must be same as for IOEBUFFER -(definition of buffer). You can use this also to reset buffer (remove all data -from buffer). -##### Parameters -| name | Name if buffer. This is C variable name. | -| size | Numerical value of buffer size | - -#### IOEBUFFER_PUT -```C -IOEBUFFER_PUT(name, size, data, mode) -``` -Use this macro to add new data to buffer. -##### Parameters -| name | Name of buffer. This is C variable name. | -| size | Numerical value of buffer size | -| data | Data to be stored to buffer | -| mode | This specifies action if buffer is full. | -##### Modes -| IOEBUFFER_MODE_BLOCK | Block execution until buffer has some free space. | -| IOEBUFFER_MODE_OVERWRITE | Overwrites oldest added (fist to be read) | -| IOEBUFFER_MODE_DROP | New data won't be stored to buffer if full | - -#### IOEBUFFER_GET -```C -IOEBUFFER_GET(name, size, variable) -``` -Get value from buffer. Value is stored in `variable` (it is variable of same type -as buffer data, not pointer to variable of same type). If no data is in buffer, -variable is set to NULL. -##### Parameters -| name | Name of buffer. This is C variable name. | -| size | Numerical value of buffer size. | -| variable | Variable in which data will be stored in. | - -#### IOEBUFFER_CNT -```C -IOEBUFFER_CNT(name, size, variable) -``` -Counts number of data entries in buffer and saves value to variable. -##### Parameters -| name | Name of buffer. This is C variable name. | -| size | Numerical value of buffer size. | -| variable | Int/Unsigned type variable where data count will be stored. | - -## C implementation -C implementation is more general. Size is defined by calling initialization -function. But it is using general pointers, so it is only able store pointers. - -As buffer identification is used defined type `IOEBuffer`. All functions takes -pointer to this type as parameter. Because of this, it won't be described for -every function. - -### Functions -#### ioebuffer_init -```C -int8_t ioebuffer_init(IOEBuffer *buf, uint8_t size, uint8_t flags) -``` -Initialized buffer and allocates required resources. -##### Parameters -| size | Number of elements to be maximally stored in buffer | -| flags | TODO -##### Flags -TODO - -#### ioebuffer_uninit -```C -void ioebuffer_uninit(IOEBuffer *buf) -``` -Frees all resources allocated during initialization of buffer. Use this every time -you are freeing buffer. - -#### ioebuffer_put -```C -int8_t ioebuffer_put(IOEBuffer *buf, void *data) -``` -Add `data` to buffer |