BLE5.2 1.0
开发文档说明
| 类型定义 | 函数
ringbuffer.h 文件参考

浏览源代码.

struct  ring_buffer
 

类型定义

typedef uint32_t ring_buffer_size_t
 
typedef struct ring_buffer ring_buffer_t
 

函数

void ring_buffer_create (ring_buffer_t *rb, uint8_t *buffer, uint32_t size)
 
void ring_buffer_queue (ring_buffer_t *rb, uint8_t data)
 
void ring_buffer_queue_arr (ring_buffer_t *rb, uint8_t *data, ring_buffer_size_t size)
 
ring_buffer_size_t ring_buffer_dequeue (ring_buffer_t *rb, uint8_t *data)
 
ring_buffer_size_t ring_buffer_dequeue_arr (ring_buffer_t *rb, uint8_t *data, ring_buffer_size_t len)
 
ring_buffer_size_t ring_buffer_peek (ring_buffer_t *rb, uint8_t *data, ring_buffer_size_t index)
 
ring_buffer_size_t ring_buffer_is_empty (ring_buffer_t *rb)
 
ring_buffer_size_t ring_buffer_is_full (ring_buffer_t *rb)
 
ring_buffer_size_t ring_buffer_num_items (ring_buffer_t *rb)
 

详细描述

Prototypes and structures for the ring buffer module.

在文件 ringbuffer.h 中定义.

类型定义说明

◆ ring_buffer_size_t

typedef uint32_t ring_buffer_size_t

The size of a ring buffer. Due to the design only RING_BUFFER_SIZE-1 items can be contained in the buffer. The buffer size must be a power of two. The type which is used to hold the size and the indicies of the buffer. Must be able to fit RING_BUFFER_SIZE .

在文件 ringbuffer.h31 行定义.

◆ ring_buffer_t

typedef struct ring_buffer ring_buffer_t

Used as a modulo operator as a % b = (a & (b − 1)) where a is a positive index in the buffer and b is the (power of two) size of the buffer. Structure which holds a ring buffer. The buffer contains a buffer array as well as metadata for the ring buffer.

函数说明

◆ ring_buffer_create()

void ring_buffer_create ( ring_buffer_t rb,
uint8_t *  buffer,
uint32_t  size 
)

Initializes the ring buffer pointed to by buffer. This function can also be used to empty/reset the buffer.

参数
bufferThe ring buffer to initialize.

在文件 ringbuffer.c11 行定义.

◆ ring_buffer_dequeue()

ring_buffer_size_t ring_buffer_dequeue ( ring_buffer_t rb,
uint8_t *  data 
)

Returns the oldest byte in a ring buffer.

参数
bufferThe buffer from which the data should be returned.
dataA pointer to the location at which the data should be placed.
返回
1 if data was returned; 0 otherwise.

在文件 ringbuffer.c50 行定义.

◆ ring_buffer_dequeue_arr()

ring_buffer_size_t ring_buffer_dequeue_arr ( ring_buffer_t rb,
uint8_t *  data,
ring_buffer_size_t  len 
)

Returns the len oldest bytes in a ring buffer.

参数
bufferThe buffer from which the data should be returned.
dataA pointer to the array at which the data should be placed.
lenThe maximum number of bytes to return.
返回
The number of bytes returned.

在文件 ringbuffer.c63 行定义.

◆ ring_buffer_is_empty()

ring_buffer_size_t ring_buffer_is_empty ( ring_buffer_t rb)
inline

Returns whether a ring buffer is empty.

参数
bufferThe buffer for which it should be returned whether it is empty.
返回
1 if empty; 0 otherwise.

在文件 ringbuffer.h139 行定义.

◆ ring_buffer_is_full()

ring_buffer_size_t ring_buffer_is_full ( ring_buffer_t rb)
inline

Returns whether a ring buffer is full.

参数
bufferThe buffer for which it should be returned whether it is full.
返回
1 if full; 0 otherwise.

在文件 ringbuffer.h149 行定义.

◆ ring_buffer_num_items()

ring_buffer_size_t ring_buffer_num_items ( ring_buffer_t rb)
inline

Returns the number of items in a ring buffer.

参数
bufferThe buffer for which the number of items should be returned.
返回
The number of items in the ring buffer.

在文件 ringbuffer.h160 行定义.

◆ ring_buffer_peek()

ring_buffer_size_t ring_buffer_peek ( ring_buffer_t rb,
uint8_t *  data,
ring_buffer_size_t  index 
)

Peeks a ring buffer, i.e. returns an element without removing it.

参数
bufferThe buffer from which the data should be returned.
dataA pointer to the location at which the data should be placed.
indexThe index to peek.
返回
1 if data was returned; 0 otherwise.

在文件 ringbuffer.c81 行定义.

◆ ring_buffer_queue()

void ring_buffer_queue ( ring_buffer_t rb,
uint8_t  data 
)

Adds a byte to a ring buffer.

参数
bufferThe buffer in which the data should be placed.
dataThe byte to place.

在文件 ringbuffer.c25 行定义.

◆ ring_buffer_queue_arr()

void ring_buffer_queue_arr ( ring_buffer_t rb,
uint8_t *  data,
ring_buffer_size_t  size 
)

Adds an array of bytes to a ring buffer.

参数
bufferThe buffer in which the data should be placed.
dataA pointer to the array of bytes to place in the queue.
sizeThe size of the array.

在文件 ringbuffer.c40 行定义.