You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ring buffer modules is implemented for general used in embedded C code. It support three data types: uint32_t, int32_t and float32_t. Data type is not importatn at initialization point as it is only how stored information are interpreted by C compiler.
2
+
This module constains ring buffer implementation for general purpose usage.
3
+
It can work with simple byte size item or larger size items. Module is
4
+
written in such a way that all details are hidden from user. Additionally
5
+
buffers are created as individual, separated instances so different
6
+
instances of buffer can be configured differently in order to addopt application needs.
3
7
4
-
Ring buffer memory space is dynamically allocated and success of allocation is taken into consideration before using that instance. Deallocation on exsisting ring buffer instance is not supported as it's not good practice to free memory in C world.
8
+
Override mode is supported where buffer is never full and new values are
9
+
always overriding old values regarding of reading rate. This functionality
10
+
is very usefull for filter sampling storage purposes.
5
11
6
-
#### Dependencies
12
+
Additionally buffers data storage can be allocated statically if dynamic
13
+
allocation is not perfered by application. Look at the example of
14
+
static allocation of memory.
15
+
16
+
There are two distinct get functions: "ring_buffer_get" and "ring_buffer_get_by_index".
17
+
First one returns oldest item in buffer and acts as a FIFO, meaning that tail increments
18
+
at every call of it. On the other side "ring_buffer_get_by_index" returns value relative
19
+
to input argument value and does not increment tail pointer! It is important not to
20
+
use those two get functionalities simultaniously.
21
+
22
+
Function "ring_buffer_get_by_index" supports two kind of access types:
23
+
24
+
1. NORMAL ACCESS: classical aproach, where index is a positive
25
+
number and simple represants buffer index. This approach
26
+
has no information about time stamps of values inside buffer.
27
+
Range: [0, size)
28
+
29
+
2. INVERS ACCESS: chronologically aproach, where index is a negative number.
30
+
Meaning that "-1" value will always returns latest value in
31
+
buffer and "-size" index value will return oldest value
32
+
in buffer. This feature becomes very handy when performing
33
+
digital filtering where ring buffer can represants sample
34
+
window and thus easy access from oldest to latest sample
35
+
can be achieved with invers access.
36
+
Range of index: [-size, -1]
37
+
38
+
39
+
40
+
## Dependencies
7
41
8
42
Definition of flaot32_t must be provided by user. In current implementation it is defined in "*project_config.h*". Just add following statement to your code where it suits the best.
9
43
@@ -12,19 +46,141 @@ Definition of flaot32_t must be provided by user. In current implementation it i
NOTE: Detailed description of functions can be found in doxygen (doc/**ring_buffer_Vx_x_x.zip**)!
67
+
68
+
## Usage
16
69
17
-
API of ring buffer constist of three blocks, those are: initialization, add element to buffer and get element from buffer. Note that getting element from buffer intakes intiger parameter as support normal and invers access. Invers access meas that get function will return time related element from ring buffer. This feature is specially handy when comes to digital filter calculations.
0 commit comments