Skip to content

Commit 3afe16b

Browse files
author
Žiga Miklošič
committed
Merge branch 'develop'
2 parents 6dd0fb9 + 16c4f41 commit 3afe16b

5 files changed

Lines changed: 90 additions & 93 deletions

File tree

CHANGE_LOG.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Changelog
2+
All notable changes to this project/module will be documented in this file.
3+
4+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5+
and this project/module adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6+
7+
---
8+
## V2.0.3 - 04.11.2022
9+
10+
### Changed
11+
- Replace version notes with changelog
12+
- Updated readme
13+
14+
---
15+
## V2.0.2 - 23.06.2022
16+
17+
### Changed
18+
- Added protection for multiple init calls
19+
- Added detailed description about module limitations
20+
21+
---
22+
## V2.0.1 - 25.05.2022
23+
24+
### Changed
25+
- Removed unused function
26+
- Change return status enumeration. Now supports masking error codes
27+
- Removed not needed include files
28+
29+
---
30+
## V2.0.0 - 31.07.2021
31+
32+
### Note
33+
Complete rework of *Ring Buffer* module. Inspiration of new API was taken from CMSIS RTOS Queues.
34+
35+
### Added
36+
- Optional buffer item size
37+
- FIFO support
38+
- Override mode
39+
- Dynamic or static allocation of memory
40+
- Buffer name for debugging purposes
41+
- Two types of buffer access: NORMAL (for fifo) & INVERS (for filters)
42+
- Get functions to acquire name, taken items, free items, size of buffer, size of item
43+
44+
---
45+
## V1.0.1 - 25.07.2021
46+
47+
### Added
48+
- Added module version
49+
- Added copyright notice
50+
- Change is_init func in to return status
51+
52+
### Changed
53+
- *iss_init* returns status
54+
55+
### Todo
56+
- Change "get" functions to return status and return value of buffer via arguments
57+
---
58+
59+
## V1.0.0 - 13.02.2022
60+
61+
### Added
62+
- Initial implementation of ring buffer
63+
- Supported three data types: uint32_t, int32_t and float32_t
64+
- Two types of buffer access: NORMAL & INVERS
65+
---

README.md

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Ring buffer
1+
# **Ring buffer**
22
This module constains ring buffer implementation for general purpose usage.
33
It can work with simple byte size item or larger size items. Module is
44
written in such a way that all details are hidden from user. Additionally
@@ -13,13 +13,13 @@ Additionally buffers data storage can be allocated statically if dynamic
1313
allocation is not perfered by application. Look at the example of
1414
static allocation of memory.
1515

16-
There are two distinct get functions: "ring_buffer_get" and "ring_buffer_get_by_index".
16+
There are two distinct get functions: *"ring_buffer_get"* and *"ring_buffer_get_by_index"*.
1717
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
18+
at every call of it. On the other side *"ring_buffer_get_by_index"* returns value relative
1919
to input argument value and does not increment tail pointer! It is important not to
2020
use those two get functionalities simultaniously.
2121

22-
Function "ring_buffer_get_by_index" supports two kind of access types:
22+
Function *"ring_buffer_get_by_index"* supports two kind of access types:
2323

2424
1. **NORMAL ACCESS: classical aproach**, where index is a positive
2525
number and simple represants buffer index. This approach
@@ -37,18 +37,24 @@ Function "ring_buffer_get_by_index" supports two kind of access types:
3737

3838

3939

40-
## Dependencies
40+
## **Dependencies**
4141

4242
This module needs only ANSI C standard libraries.
4343

44-
## Multientry Limitations
44+
## **General Embedded C Libraries Ecosystem**
45+
In order to be part of *General Embedded C Libraries Ecosystem* this module must be placed in following path:
46+
```
47+
root/middleware/ring_buffer/"module_space"
48+
```
49+
50+
## **Multientry Limitations**
4551

4652
Guidance for multi-entry usage:
4753
- **It is recomented to use ring_buffer between two task/interrupts/cores in provider/consumer manner.** Meaning one task/interrupt/core is writing to ring_buffer and other task/interrupt/core is reading from it.
4854
- **It is not recommended for two or more task/interrupt/core to read/write to same ring_buffer instance!**
4955

5056

51-
## API
57+
## **API**
5258

5359
| API Functions | Description | Prototype |
5460
| --- | ----------- | ----- |
@@ -67,9 +73,9 @@ Guidance for multi-entry usage:
6773

6874
NOTE: Detailed description of functions can be found in doxygen (doc/**ring_buffer_Vx_x_x.zip**)!
6975

70-
## Usage
76+
## **Usage**
7177

72-
### Initialization examples
78+
### **Initialization examples**
7379

7480
```C
7581
// My ring buffer instance
@@ -88,7 +94,7 @@ ring_buffer_attr_t my_ringbuffer_2_attr;
8894

8995
// Customize ring buffer:
9096
my_ring_buffer_2_attr.name = "Dynamic allocated buffer";
91-
my_ring_buffer_2_attr.p_mem = NULL;
97+
my_ring_buffer_2_attr.p_mem = NULL; // NULL -> Dynamical allocation
9298
my_ring_buffer_2_attr.item_size = sizeof(float32_t);
9399
my_ring_buffer_2_attr.override = true;
94100

@@ -115,10 +121,9 @@ if ( eRING_BUFFER_OK != ring_buffer_init( &my_ringbuffer_2, 32, &my_ring_buffer_
115121
{
116122
// Init failed...
117123
}
118-
119124
```
120125

121-
### Get items out of buffer examples
126+
### **Get items out of buffer examples**
122127

123128
```C
124129
// My ring buffer is initialized for byte items
@@ -131,7 +136,7 @@ uint8_t item;
131136
// Pump all items out of buffer
132137
ring_buffer_get_taken( my_ring_buffer, &taken );
133138

134-
for ( i = 0; i < taken; i++ )
139+
for ( uint32_t i = 0; i < taken; i++ )
135140
{
136141
ring_buffer_get( my_ring_buffer, &item );
137142

@@ -165,18 +170,17 @@ ring_buffer_get_by_index( my_ringbuffer, &item, -10 );
165170
float32_t sample;
166171

167172
// Make convolution
168-
for ( i = 0; i < filter_inst -> order; i++ )
173+
for ( uint32_t i = 0; i < filter_inst -> order; i++ )
169174
{
170175
// Get sample
171176
ring_buffer_get_by_index( filter_inst->p_x, &sample, (( -i ) - 1 ));
172177

173178
// Convolve
174179
y += ( filter_inst->p_a[i] * sample );
175180
}
176-
177181
```
178182
179-
### Add item to buffer examples
183+
### **Add item to buffer examples**
180184
181185
```C
182186
// My ring buffer is initialized for byte items

src/ring_buffer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
*@file ring_buffer.c
77
*@brief Ring (circular) buffer for general use
88
*@author Ziga Miklosic
9-
*@date 03.02.2021
10-
*@version V2.0.2
9+
*@date 04.11.2022
10+
*@version V2.0.3
1111
*
1212
*@section Description
1313
*

src/ring_buffer.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
*@file ring_buffer.h
77
*@brief Ring (circular) buffer for general use
88
*@author Ziga Miklosic
9-
*@date 03.02.2021
10-
*@version V2.0.2
9+
*@date 04.11.2022
10+
*@version V2.0.3
1111
*/
1212
////////////////////////////////////////////////////////////////////////////////
1313
/**
@@ -37,7 +37,7 @@
3737
*/
3838
#define RING_BUFFER_VER_MAJOR ( 2 )
3939
#define RING_BUFFER_VER_MINOR ( 0 )
40-
#define RING_BUFFER_VER_DEVELOP ( 2 )
40+
#define RING_BUFFER_VER_DEVELOP ( 3 )
4141

4242
/**
4343
* Status

version.txt

Lines changed: 0 additions & 72 deletions
This file was deleted.

0 commit comments

Comments
 (0)