GithubHelp home page GithubHelp logo

jiangshipengv8 / ring-buffer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from anderskaloer/ring-buffer

0.0 0.0 0.0 119 KB

A simple ring buffer (circular buffer) designed for embedded systems.

License: MIT License

C 100.00%

ring-buffer's Introduction

Ring-Buffer

A simple ring buffer (circular buffer) designed for embedded systems.

An example is given in examples/simple.c.

The size of the buffer can be configured by changing the value of RING_BUFFER_SIZE in ring_buffer.h. Note that RING_BUFFER_SIZE must be a power-of-two.

A new ring buffer is created using the ring_buffer_init(buffer) function:

ring_buffer_t ring_buffer;
ring_buffer_init(&ring_buffer);

The module provides the following functions for accessing the ring buffer (documentation can be found in ringbuffer.h):

void ring_buffer_queue(ring_buffer_t *buffer, char data);
void ring_buffer_queue_arr(ring_buffer_t *buffer, const char *data, ring_buffer_size_t size);
uint8_t ring_buffer_dequeue(ring_buffer_t *buffer, char *data);
ring_buffer_size_t ring_buffer_dequeue_arr(ring_buffer_t *buffer, char *data, ring_buffer_size_t len);
uint8_t ring_buffer_peek(ring_buffer_t *buffer, char *data, ring_buffer_size_t index);
uint8_t ring_buffer_is_empty(ring_buffer_t *buffer);
uint8_t ring_buffer_is_full(ring_buffer_t *buffer);
ring_buffer_size_t ring_buffer_num_items(ring_buffer_t *buffer);

ring-buffer's People

Contributors

5ooo avatar anderskaloer avatar ayushev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.