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

Go to the source code of this file.

Functions

void circular_buffer_init (struct circular_buffer *cb, uint8_t *buffer, size_t len)
 initialize a circular buffer.
 
int circular_buffer_get (struct circular_buffer *cb, uint8_t *buf, size_t len)
 copy the next buffer available in cb to buf.
 
int circular_buffer_put (struct circular_buffer *cb, const uint8_t *buf, size_t len)
 Copy buf in the circular buffer.
 
int circular_buffer_drop (struct circular_buffer *cb)
 Drop last inserted record.
 
size_t circular_buffer_available (struct circular_buffer *cb)
 Get the available sapce for the next buffer.
 
void circular_buffer_clear (struct circular_buffer *cb)
 Clear buffer.
 

Function Documentation

◆ circular_buffer_available()

size_t circular_buffer_available ( struct circular_buffer cb)

Get the available sapce for the next buffer.

Definition at line 110 of file circular_buffer.c.

References circular_buffer::_buf_len, foo, circular_buffer::read_offset, and circular_buffer::write_offset.

Referenced by circular_buffer_put().

+ Here is the caller graph for this function:

◆ circular_buffer_clear()

void circular_buffer_clear ( struct circular_buffer cb)

Clear buffer.

Definition at line 122 of file circular_buffer.c.

References circular_buffer::read_offset, and circular_buffer::write_offset.

◆ circular_buffer_drop()

int circular_buffer_drop ( struct circular_buffer cb)

Drop last inserted record.

Definition at line 90 of file circular_buffer.c.

References circular_buffer::_buf, circular_buffer::_buf_len, CIR_ERROR_NO_MSG, foo, circular_buffer::read_offset, and circular_buffer::write_offset.

Referenced by uavcan_broadcast().

+ Here is the caller graph for this function:

◆ circular_buffer_get()

int circular_buffer_get ( struct circular_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 22 of file circular_buffer.c.

References circular_buffer::_buf, circular_buffer::_buf_len, CIR_ERROR_BUFFER_TOO_SMALL, CIR_ERROR_NO_MSG, foo, circular_buffer::read_offset, and circular_buffer::write_offset.

Referenced by sts3032_event(), and uavcan_tx().

+ Here is the caller graph for this function:

◆ circular_buffer_init()

void circular_buffer_init ( struct circular_buffer cb,
uint8_t buffer,
size_t  len 
)

initialize a circular buffer.

Parameters
cbcircular_buffer structure
bufferbuffer used internally by the circular buffer
lensize of buffer

Definition at line 13 of file circular_buffer.c.

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

Referenced by actuators_sts3032_init(), and uavcanInitIface().

+ Here is the caller graph for this function:

◆ circular_buffer_put()

int circular_buffer_put ( struct circular_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 52 of file circular_buffer.c.

References circular_buffer::_buf, circular_buffer::_buf_len, CIR_ERROR_NO_SPACE_AVAILABLE, circular_buffer_available(), foo, and circular_buffer::write_offset.

Referenced by uavcan_broadcast(), and write_buf().

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