MIP_SDK  v3.0.0
MicroStrain Communications Library for embedded systems
byte_ring.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <stdint.h>
4 #include <stddef.h>
5 
6 
7 typedef struct byte_ring_state
8 {
9  uint8_t* buffer;
10  size_t size;
11  size_t head;
12  size_t tail;
14 
15 void byte_ring_init(byte_ring_state* state, uint8_t* buffer, size_t size);
16 void byte_ring_clear(byte_ring_state* state);
17 
18 size_t byte_ring_capacity(const byte_ring_state* state);
19 size_t byte_ring_count(const byte_ring_state* state);
20 size_t byte_ring_free_space(const byte_ring_state* state);
21 
22 uint8_t byte_ring_at(const byte_ring_state* state, size_t index);
23 
24 size_t byte_ring_pop(byte_ring_state* state, size_t count);
25 
26 size_t byte_ring_copy_to(const byte_ring_state* state, uint8_t* buffer, size_t count);
27 size_t byte_ring_copy_from_and_update(byte_ring_state* state, const uint8_t** bytes, size_t* count);
28 
29 
30 size_t byte_ring_get_write_ptr(byte_ring_state* state, uint8_t** ptr_out);
31 void byte_ring_notify_written(byte_ring_state* state, size_t count);
byte_ring_init
void byte_ring_init(byte_ring_state *state, uint8_t *buffer, size_t size)
Definition: byte_ring.c:7
byte_ring_notify_written
void byte_ring_notify_written(byte_ring_state *state, size_t count)
Definition: byte_ring.c:111
byte_ring_state::size
size_t size
Definition: byte_ring.h:10
byte_ring_state
Definition: byte_ring.h:7
byte_ring_pop
size_t byte_ring_pop(byte_ring_state *state, size_t count)
Definition: byte_ring.c:53
byte_ring_state
struct byte_ring_state byte_ring_state
byte_ring_at
uint8_t byte_ring_at(const byte_ring_state *state, size_t index)
Definition: byte_ring.c:46
byte_ring_state::head
size_t head
Definition: byte_ring.h:11
byte_ring_count
size_t byte_ring_count(const byte_ring_state *state)
Definition: byte_ring.c:29
byte_ring_capacity
size_t byte_ring_capacity(const byte_ring_state *state)
Definition: byte_ring.c:24
byte_ring_state::tail
size_t tail
Definition: byte_ring.h:12
byte_ring_get_write_ptr
size_t byte_ring_get_write_ptr(byte_ring_state *state, uint8_t **ptr_out)
Definition: byte_ring.c:95
byte_ring_copy_from_and_update
size_t byte_ring_copy_from_and_update(byte_ring_state *state, const uint8_t **bytes, size_t *count)
Definition: byte_ring.c:77
byte_ring_copy_to
size_t byte_ring_copy_to(const byte_ring_state *state, uint8_t *buffer, size_t count)
Definition: byte_ring.c:64
byte_ring_free_space
size_t byte_ring_free_space(const byte_ring_state *state)
Definition: byte_ring.c:36
byte_ring_state::buffer
uint8_t * buffer
Definition: byte_ring.h:9
byte_ring_clear
void byte_ring_clear(byte_ring_state *state)
Definition: byte_ring.c:18