Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release/v2.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
MaJerle committed Jul 3, 2020
2 parents b233b5c + b7d88a5 commit 695cd91
Show file tree
Hide file tree
Showing 26 changed files with 241 additions and 209 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Generic ring buffer manager
# Lightweight ring buffer manager

Library provides generic FIFO ring buffer implementation.

<h3>Read first: <a href="http://docs.majerle.eu/projects/ringbuff/">Documentation</a></h3>
<h3>Read first: <a href="http://docs.majerle.eu/projects/lwrb/">Documentation</a></h3>

## Features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.28803.452
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ringbuff_dev", "ringbuff_dev.vcxproj", "{65B0BF4D-8CA6-48F2-8B0B-6BFD456AA57B}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "lwrb_dev", "lwrb_dev.vcxproj", "{65B0BF4D-8CA6-48F2-8B0B-6BFD456AA57B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -13,8 +13,8 @@ Global
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{65B0BF4D-8CA6-48F2-8B0B-6BFD456AA57B}.Debug|x64.ActiveCfg = Debug|Win32
{65B0BF4D-8CA6-48F2-8B0B-6BFD456AA57B}.Debug|x64.Build.0 = Debug|Win32
{65B0BF4D-8CA6-48F2-8B0B-6BFD456AA57B}.Debug|x64.ActiveCfg = Debug|x64
{65B0BF4D-8CA6-48F2-8B0B-6BFD456AA57B}.Debug|x64.Build.0 = Debug|x64
{65B0BF4D-8CA6-48F2-8B0B-6BFD456AA57B}.Debug|x86.ActiveCfg = Debug|Win32
{65B0BF4D-8CA6-48F2-8B0B-6BFD456AA57B}.Debug|x86.Build.0 = Debug|Win32
{65B0BF4D-8CA6-48F2-8B0B-6BFD456AA57B}.Release|x64.ActiveCfg = Release|x64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<VCProjectVersion>15.0</VCProjectVersion>
<ProjectGuid>{65B0BF4D-8CA6-48F2-8B0B-6BFD456AA57B}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>ringbuff_dev</RootNamespace>
<RootNamespace>lwrb_dev</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
Expand Down Expand Up @@ -72,7 +72,7 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>..\..\ringbuff\src\include\;$(IncludePath)</IncludePath>
<IncludePath>..\..\lwrb\src\include\;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
Expand Down Expand Up @@ -143,7 +143,7 @@
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\ringbuff\src\ringbuff\ringbuff.c" />
<ClCompile Include="..\..\lwrb\src\lwrb\lwrb.c" />
<ClCompile Include="main.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<ClCompile Include="main.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\ringbuff\src\ringbuff\ringbuff.c">
<ClCompile Include="..\..\lwrb\src\lwrb\lwrb.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
Expand Down
54 changes: 27 additions & 27 deletions dev/VisualStudio/main.c
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
// ringbuff_dev.cpp : Defines the entry point for the console application.
// lwrb_dev.cpp : Defines the entry point for the console application.
//

#include <stdio.h>
#include <string.h>
#include "ringbuff/ringbuff.h"
#include "lwrb/lwrb.h"

/* Create data array and buffer */
uint8_t ringbuff_data[8 + 1];
ringbuff_t buff;
uint8_t lwrb_data[8 + 1];
lwrb_t buff;

static void debug_buff(uint8_t cmp, size_t r_w, size_t r_r, size_t r_f, size_t r_e);

uint8_t tmp[8];

void
my_buff_evt_fn(ringbuff_t* buff, ringbuff_evt_type_t type, size_t len) {
my_buff_evt_fn(lwrb_t* buff, lwrb_evt_type_t type, size_t len) {
switch (type) {
case RINGBUFF_EVT_RESET:
case LWRB_EVT_RESET:
printf("[EVT] Buffer reset event!\r\n");
break;
case RINGBUFF_EVT_READ:
case LWRB_EVT_READ:
printf("[EVT] Buffer read event: %d byte(s)!\r\n", (int)len);
break;
case RINGBUFF_EVT_WRITE:
case LWRB_EVT_WRITE:
printf("[EVT] Buffer write event: %d byte(s)!\r\n", (int)len);
break;
default: break;
Expand All @@ -34,38 +34,38 @@ main() {
size_t len;

/* Init buffer */
ringbuff_init(&buff, ringbuff_data, sizeof(ringbuff_data));
ringbuff_set_evt_fn(&buff, my_buff_evt_fn);
lwrb_init(&buff, lwrb_data, sizeof(lwrb_data));
lwrb_set_evt_fn(&buff, my_buff_evt_fn);

ringbuff_write(&buff, "abc", 3);
ringbuff_write(&buff, "abc", 3);
ringbuff_write(&buff, "abc", 3);
len = ringbuff_read(&buff, tmp, 9);
lwrb_write(&buff, "abc", 3);
lwrb_write(&buff, "abc", 3);
lwrb_write(&buff, "abc", 3);
len = lwrb_read(&buff, tmp, 9);

buff.r = 0;
buff.w = 0;
memset(ringbuff_get_linear_block_write_address(&buff), 'A', ringbuff_get_linear_block_write_length(&buff));
ringbuff_advance(&buff, ringbuff_get_linear_block_write_length(&buff));
memset(lwrb_get_linear_block_write_address(&buff), 'A', lwrb_get_linear_block_write_length(&buff));
lwrb_advance(&buff, lwrb_get_linear_block_write_length(&buff));

buff.r = 2;
buff.w = 0;
memset(ringbuff_get_linear_block_write_address(&buff), 'B', ringbuff_get_linear_block_write_length(&buff));
ringbuff_advance(&buff, ringbuff_get_linear_block_write_length(&buff));
memset(lwrb_get_linear_block_write_address(&buff), 'B', lwrb_get_linear_block_write_length(&buff));
lwrb_advance(&buff, lwrb_get_linear_block_write_length(&buff));

buff.r = 3;
buff.w = 3;
memset(ringbuff_get_linear_block_write_address(&buff), 'C', ringbuff_get_linear_block_write_length(&buff));
ringbuff_advance(&buff, ringbuff_get_linear_block_write_length(&buff));
memset(lwrb_get_linear_block_write_address(&buff), 'C', lwrb_get_linear_block_write_length(&buff));
lwrb_advance(&buff, lwrb_get_linear_block_write_length(&buff));

ringbuff_reset(&buff);
lwrb_reset(&buff);

//for (size_t r = 0; r < sizeof(ringbuff_data); ++r) {
//for (size_t r = 0; r < sizeof(lwrb_data); ++r) {
// void* ptr;
// for (size_t w = 0; w < sizeof(ringbuff_data); ++w) {
// for (size_t w = 0; w < sizeof(lwrb_data); ++w) {
// buff.r = r;
// buff.w = w;
// ptr = ringbuff_get_linear_block_write_address(&buff);
// len = ringbuff_get_linear_block_write_length(&buff);
// ptr = lwrb_get_linear_block_write_address(&buff);
// len = lwrb_get_linear_block_write_length(&buff);
// printf("W: %3d, R: %3d, LEN: %3d\r\n", (int)w, (int)r, (int)len);
// }
//}
Expand All @@ -81,8 +81,8 @@ debug_buff(uint8_t cmp, size_t r_w, size_t r_r, size_t r_f, size_t r_e) {

r = buff.r;
w = buff.w;
f = ringbuff_get_full(&buff);
e = ringbuff_get_free(&buff);
f = lwrb_get_full(&buff);
e = lwrb_get_free(&buff);

printf("R: %3d, W: %3d, F: %3d, E: %3d\r\n", (int)r, (int)w, (int)f, (int)e);
}
2 changes: 1 addition & 1 deletion docs/api-reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ List of all the modules:
.. toctree::
:maxdepth: 2

ringbuff
lwrb
6 changes: 6 additions & 0 deletions docs/api-reference/lwrb.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.. _api_lwrb:

LwRB
====

.. doxygengroup:: LWRB
6 changes: 0 additions & 6 deletions docs/api-reference/ringbuff.rst

This file was deleted.

12 changes: 6 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@
subprocess.call('doxygen doxyfile.doxy', shell=True)
# -- Project information -----------------------------------------------------

project = 'Ringbuffer'
project = 'LwRB'
copyright = '2020, Tilen MAJERLE'
author = 'Tilen MAJERLE'

# The full version, including alpha/beta/rc tags
version = '1.3.1'
version = '2.0.0'

# Try to get branch at which this is running
# and try to determine which version to display in sphinx
Expand Down Expand Up @@ -100,8 +100,8 @@
'titles_only': False
}
html_logo = 'static/images/logo.svg'
github_url = 'https://github.com/MaJerle/ringbuff'
html_baseurl = 'https://docs.majerle.eu/projects/ringbuff/'
github_url = 'https://github.com/MaJerle/lwrb'
html_baseurl = 'https://docs.majerle.eu/projects/lwrb/'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand All @@ -123,7 +123,7 @@
#
#
breathe_projects = {
"ringbuff": "_build/xml/"
"lwrb": "_build/xml/"
}
breathe_default_project = "ringbuff"
breathe_default_project = "lwrb"
breathe_default_members = ('members', 'undoc-members')
6 changes: 3 additions & 3 deletions docs/doxyfile.doxy
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8
# title of most generated pages and in a few other places.
# The default value is: My Project.

PROJECT_NAME = "Ring buffer"
PROJECT_NAME = "LwRB"

# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
# could be handy for archiving the generated documentation or if some version
Expand All @@ -44,7 +44,7 @@ PROJECT_NUMBER = ""
# for a project that appears at the top of each page and should give viewer a
# quick idea about the purpose of the project. Keep the description short.

PROJECT_BRIEF = "Generic FIFO buffer"
PROJECT_BRIEF = "Lightweight ring buffer manager"

# With the PROJECT_LOGO tag one can specify a logo or an icon that is included
# in the documentation. The maximum height of the logo should not exceed 55
Expand Down Expand Up @@ -775,7 +775,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.

INPUT = "../ringbuff/"
INPUT = "../lwrb/"

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down
16 changes: 8 additions & 8 deletions docs/examples_src/example_advance_1.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* Declare buffer variables */
ringbuff_t buff;
lwrb_t buff;
uint8_t buff_data[8];

size_t len;
uint8_t* data;

/* Initialize buffer, use buff_data as data array */
ringbuff_init(&buff, buff_data, sizeof(buff_data));
lwrb_init(&buff, buff_data, sizeof(buff_data));

/* Use write, read operations, process data */
/* ... */
Expand All @@ -19,10 +19,10 @@ ringbuff_init(&buff, buff_data, sizeof(buff_data));
/* Get length of linear memory at write pointer */
/* Function returns 4 as we can write 4 bytes to buffer in sequence */
/* When function returns 0, there is no memory available in the buffer for write anymore */
if ((len = ringbuff_get_linear_block_write_length(&buff)) > 0) {
if ((len = lwrb_get_linear_block_write_length(&buff)) > 0) {
/* Get pointer to first element in linear block at write address */
/* Function returns &buff_data[4] */
data = ringbuff_get_linear_block_write_address(&buff);
data = lwrb_get_linear_block_write_address(&buff);

/* Receive data via DMA and wait to finish (for sake of example) */
/* Any other hardware may directly write to data array */
Expand All @@ -32,7 +32,7 @@ if ((len = ringbuff_get_linear_block_write_length(&buff)) > 0) {

/* Now advance buffer for written bytes to buffer = move write pointer */
/* Write pointer is moved for len bytes */
ringbuff_advance(&buff, len);
lwrb_advance(&buff, len);

/* Now W points to top of buffer, W = 0 */
/* At this point, we are at image part B */
Expand All @@ -43,10 +43,10 @@ if ((len = ringbuff_get_linear_block_write_length(&buff)) > 0) {
/* Get length of linear memory at write pointer */
/* Function returns 3 as we can write 3 bytes to buffer in sequence */
/* When function returns 0, there is no memory available in the buffer for write anymore */
if ((len = ringbuff_get_linear_block_read_length(&buff)) > 0) {
if ((len = lwrb_get_linear_block_read_length(&buff)) > 0) {
/* Get pointer to first element in linear block at write address */
/* Function returns &buff_data[0] */
data = ringbuff_get_linear_block_read_address(&buff);
data = lwrb_get_linear_block_read_address(&buff);

/* Receive data via DMA and wait to finish (for sake of example) */
/* Any other hardware may directly write to data array */
Expand All @@ -56,7 +56,7 @@ if ((len = ringbuff_get_linear_block_read_length(&buff)) > 0) {

/* Now advance buffer for written bytes to buffer = move write pointer */
/* Write pointer is moved for len bytes */
ringbuff_advance(&buff, len);
lwrb_advance(&buff, len);

/* Now W points to 3, R points to 4, that is R == W + 1 and buffer is now full */
/* At this point, we are at image part C */
Expand Down
10 changes: 5 additions & 5 deletions docs/examples_src/example_advance_2.c
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#include "ringbuff/ringbuff.h"
#include "lwrb/lwrb.h"

/* Buffer variables */
ringbuff_t buff; /* Declare ring buffer structure */
lwrb_t buff; /* Declare ring buffer structure */
uint8_t buff_data[8]; /* Declare raw buffer data array */

/* Application variables
uint8_t data[2]; /* Application working data */

/* Application code ... */
ringbuff_init(&buff, buff_data, sizeof(buff_data)); /* Initialize buffer */
lwrb_init(&buff, buff_data, sizeof(buff_data)); /* Initialize buffer */

/* Write 4 bytes of data */
ringbuff_write(&buff, "0123", 4);
lwrb_write(&buff, "0123", 4);

/* Print number of bytes in buffer */
printf("Bytes in buffer: %d\r\n", (int)ringbuff_get_full(&buff));
printf("Bytes in buffer: %d\r\n", (int)lwrb_get_full(&buff));

/* Will print "4" */
12 changes: 6 additions & 6 deletions docs/examples_src/example_dma_skip.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Buffer */
ringbuff_t buff;
lwrb_t buff;
uint8_t buff_data[8];

/* Working data length */
Expand All @@ -11,10 +11,10 @@ void send_data(void);
int
main(void) {
/* Initialize buffer */
ringbuff_init(&buff, buff_data, sizeof(buff_data));
lwrb_init(&buff, buff_data, sizeof(buff_data));

/* Write 4 bytes of data */
ringbuff_write(&buff, "0123", 4);
lwrb_write(&buff, "0123", 4);

/* Send data over DMA */
send_data();
Expand All @@ -31,10 +31,10 @@ send_data(void) {
}

/* Get maximal length of buffer to read data as linear memory */
len = ringbuff_get_linear_block_read_length(&buff);
len = lwrb_get_linear_block_read_length(&buff);
if (len > 0) {
/* Get pointer to read memory */
uint8_t* data = ringbuff_get_linear_block_read_address(&buff);
uint8_t* data = lwrb_get_linear_block_read_address(&buff);

/* Start DMA transfer */
start_dma_transfer(data, len);
Expand All @@ -50,7 +50,7 @@ DMA_Interrupt_handler(void) {
/* Transfer finished */
if (len > 0) {
/* Now skip the data (move read pointer) as they were successfully transferred over DMA */
ringbuff_skip(&buff, len);
lwrb_skip(&buff, len);

/* Reset length = DMA is not active */
len = 0;
Expand Down
Loading

0 comments on commit 695cd91

Please sign in to comment.