Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
framed_ring_buffer.c File Reference
#include "framed_ring_buffer.h"
#include <string.h>
Include dependency graph for framed_ring_buffer.c:

Go to the source code of this file.

Macros

#define FRB_LOAD(_x)
#define FRB_STORE(_x, _v)

Functions

void framed_ring_buffer_init (struct framed_ring_buffer *cb, uint8_t *buffer, size_t len)
 initialize a circular buffer.
int framed_ring_buffer_get (struct framed_ring_buffer *cb, uint8_t *buf, size_t len)
 copy the next buffer available in cb to buf.
int framed_ring_buffer_put (struct framed_ring_buffer *cb, const uint8_t *buf, size_t len)
 Copy buf in the circular buffer.
int framed_ring_buffer_drop_last (struct framed_ring_buffer *cb)
 Drop last inserted record.
size_t framed_ring_buffer_available (struct framed_ring_buffer *cb)
 Get the available sapce for the next buffer.
void framed_ring_buffer_clear (struct framed_ring_buffer *cb)
 Clear buffer.

Macro Definition Documentation

◆ FRB_LOAD

#define FRB_LOAD ( _x)
Value:
__atomic_load_n(&(_x), __ATOMIC_ACQUIRE)

Definition at line 16 of file framed_ring_buffer.c.

Referenced by framed_ring_buffer_available(), and framed_ring_buffer_get().

◆ FRB_STORE

#define FRB_STORE ( _x,
_v )
Value:
__atomic_store_n(&(_x), (_v), __ATOMIC_RELEASE)

Definition at line 17 of file framed_ring_buffer.c.

Referenced by framed_ring_buffer_get(), and framed_ring_buffer_put().

Function Documentation

◆ framed_ring_buffer_available()

size_t framed_ring_buffer_available ( struct framed_ring_buffer * cb)

Get the available sapce for the next buffer.

Definition at line 117 of file framed_ring_buffer.c.

References framed_ring_buffer::_buf_len, FRB_LOAD, framed_ring_buffer::read_offset, and framed_ring_buffer::write_offset.

Referenced by framed_ring_buffer_put().

Here is the caller graph for this function:

◆ framed_ring_buffer_clear()

void framed_ring_buffer_clear ( struct framed_ring_buffer * cb)

Clear buffer.

Definition at line 131 of file framed_ring_buffer.c.

References framed_ring_buffer::read_offset, and framed_ring_buffer::write_offset.

◆ framed_ring_buffer_drop_last()

int framed_ring_buffer_drop_last ( struct framed_ring_buffer * cb)

◆ framed_ring_buffer_get()

int framed_ring_buffer_get ( struct framed_ring_buffer * cb,
uint8_t * buf,
size_t len )

copy the next buffer available in cb to buf.

Parameters
cbThe circular buffer
bufdestination buffer
lensize of buf
Returns
Size of the data copied to buf, or an error code if negative.

Definition at line 29 of file framed_ring_buffer.c.

References framed_ring_buffer::_buf, framed_ring_buffer::_buf_len, CIR_ERROR_BUFFER_TOO_SMALL, CIR_ERROR_NO_MSG, FRB_LOAD, FRB_STORE, framed_ring_buffer::read_offset, and framed_ring_buffer::write_offset.

Referenced by sts3032_event(), and uavcan_handle_rx().

Here is the caller graph for this function:

◆ framed_ring_buffer_init()

void framed_ring_buffer_init ( struct framed_ring_buffer * cb,
uint8_t * buffer,
size_t len )

initialize a circular buffer.

Parameters
cbframed_ring_buffer structure
bufferbuffer used internally by the framed ring buffer
lensize of buffer

Definition at line 20 of file framed_ring_buffer.c.

References framed_ring_buffer::_buf, framed_ring_buffer::_buf_len, framed_ring_buffer::read_offset, and framed_ring_buffer::write_offset.

Referenced by actuators_sts3032_init(), and uavcanInitIface().

Here is the caller graph for this function:

◆ framed_ring_buffer_put()

int framed_ring_buffer_put ( struct framed_ring_buffer * cb,
const uint8_t * buf,
size_t len )

Copy buf in the circular buffer.

Parameters
cbThe circular buffer
bufsource buffer
lenSize of buf
Returns
0 on success, Error code if negative

Definition at line 59 of file framed_ring_buffer.c.

References framed_ring_buffer::_buf, framed_ring_buffer::_buf_len, CIR_ERROR_NO_SPACE_AVAILABLE, framed_ring_buffer_available(), FRB_STORE, and framed_ring_buffer::write_offset.

Referenced by can_frame_cb(), and write_buf().

Here is the call graph for this function:
Here is the caller graph for this function: