include/misc/ring_buffer.h
/**
 * @brief Initialize a ring buffer.
 *
 * This routine initializes a ring buffer, prior to its first use. It is only
 * used for ring buffers not defined using SYS_RING_BUF_DECLARE_POW2 or
 * SYS_RING_BUF_DECLARE_SIZE.
 *
 * Setting @a size to a power of 2 establishes a high performance ring buffer
 * that doesn't require the use of modulo arithmetic operations to maintain
 * itself.
 *
 * @param buf Address of ring buffer.
 * @param size Ring buffer size (in 32-bit words).
 * @param data Ring buffer data area (typically u32_t data[size]).
 */
@brief Initialize a ring buffer.
This routine initializes a ring buffer, prior to its first use. It is only
used for ring buffers not defined using SYS_RING_BUF_DECLARE_POW2 or
SYS_RING_BUF_DECLARE_SIZE.

Setting @a size to a power of 2 establishes a high performance ring buffer
that doesn't require the use of modulo arithmetic operations to maintain
itself.

@param buf Address of ring buffer.
@param size Ring buffer size (in 32-bit words).
@brief Initialize a ring buffer . This routine initializes a ring buffer prior to its first use . It is only used for ring buffers not defined using SYS_RING_BUF_DECLARE_POW2 or SYS_RING_BUF_DECLARE_SIZE . Setting @a size to a power of 2 establishes a high performance ring buffer that doesn ' t require the use of modulo arithmetic operations to maintain itself . @param buf Address of ring buffer . @param size Ring buffer size ( in 32 - bit words ) .
static inline void sys_ring_buf_init(struct ring_buf *buf, u32_t size,
				     u32_t *data)
{
	buf->head = 0;
	buf->tail = 0;
	buf->dropped_put_count = 0;
	buf->size = size;
	buf->buf = data;
	if (is_power_of_two(size)) {
		buf->mask = size - 1;
	} else {
		buf->mask = 0;
	}
	SYS_TRACING_OBJ_INIT(sys_ring_buf, buf);
}
static inline void sys_ring_buf_init ( struct ring_buf * buf , u32_t size , u32_t * data ) { buf -> head = 0 ; buf -> tail = 0 ; buf -> dropped_put_count = 0 ; buf -> size = size ; buf -> buf = data ; if ( is_power_of_two ( size ) ) { buf -> mask = size - 1 ; } else { buf -> mask = 0 ; } SYS_TRACING_OBJ_INIT ( sys_ring_buf , buf ) ; }
@brief Initialize a ring buffer.
@brief Initialize a ring buffer .