Functions that handle the queue instances.
More...
|
|
|
#define
|
NRF_QUEUE_DEF
(_type, _name, _size, _mode)
|
|
|
Create a queue instance.
More...
|
|
|
|
#define
|
NRF_QUEUE_INTERFACE_DEC
(_type, _name)
|
|
|
Declare a queue interface.
More...
|
|
|
|
#define
|
NRF_QUEUE_INTERFACE_DEF
(_type, _name, _p_queue)
|
|
|
Define a queue interface.
More...
|
|
|
|
#define
|
nrf_queue_pop
(_p_queue, _p_element)
nrf_queue_generic_pop
((_p_queue), (_p_element), false)
|
|
|
Pop element from the front of the queue.
More...
|
|
|
|
#define
|
nrf_queue_peek
(_p_queue, _p_element)
nrf_queue_generic_pop
((_p_queue), (_p_element), true)
|
|
|
Peek element from the front of the queue.
More...
|
|
|
|
|
|
ret_code_t
|
nrf_queue_push
(
nrf_queue_t
const *p_queue, void const *p_element)
|
|
|
Function for pushing an element to the end of queue.
More...
|
|
|
|
ret_code_t
|
nrf_queue_generic_pop
(
nrf_queue_t
const *p_queue, void *p_element, bool just_peek)
|
|
|
Generic pop implementation.
More...
|
|
|
|
ret_code_t
|
nrf_queue_write
(
nrf_queue_t
const *p_queue, void const *p_data, size_t element_count)
|
|
|
Function for writing elements to the queue.
More...
|
|
|
|
size_t
|
nrf_queue_in
(
nrf_queue_t
const *p_queue, void const *p_data, size_t element_count)
|
|
|
Function for writing a portion of elements to the queue.
More...
|
|
|
|
ret_code_t
|
nrf_queue_read
(
nrf_queue_t
const *p_queue, void *p_data, size_t element_count)
|
|
|
Function for reading elements from the queue.
More...
|
|
|
|
size_t
|
nrf_queue_out
(
nrf_queue_t
const *p_queue, void *p_data, size_t element_count)
|
|
|
Function for reading a portion of elements from the queue.
More...
|
|
|
|
bool
|
nrf_queue_is_full
(
nrf_queue_t
const *p_queue)
|
|
|
Function for checking if the queue is full.
More...
|
|
|
|
bool
|
nrf_queue_is_empty
(
nrf_queue_t
const *p_queue)
|
|
|
Function for checking if the queue is empty.
More...
|
|
|
|
size_t
|
nrf_queue_utilization_get
(
nrf_queue_t
const *p_queue)
|
|
|
Function for getting the current queue utilization.
More...
|
|
|
|
size_t
|
nrf_queue_available_get
(
nrf_queue_t
const *p_queue)
|
|
|
Function for getting the size of available space.
More...
|
|
|
|
size_t
|
nrf_queue_max_utilization_get
(
nrf_queue_t
const *p_queue)
|
|
|
Function for getting the maximal queue utilization.
More...
|
|
|
|
void
|
nrf_queue_max_utilization_reset
(
nrf_queue_t
const *p_queue)
|
|
|
Function for resetting the maximal queue utilization.
More...
|
|
|
|
void
|
nrf_queue_reset
(
nrf_queue_t
const *p_queue)
|
|
|
Function for resetting the queue state.
More...
|
|
|
Functions that handle the queue instances.
|
#define NRF_QUEUE_DEF
|
(
|
|
_type,
|
|
|
|
|
_name,
|
|
|
|
|
_size,
|
|
|
|
|
_mode
|
|
|
)
|
|
|
Value:
static
_type
CONCAT_2
(_name, _nrf_queue_buffer[(_size) + 1]); \
{ \
.p_buffer =
CONCAT_2
(_name,_nrf_queue_buffer), \
.size = (_size), \
.element_size =
sizeof
(_type), \
.mode = _mode, \
}
Create a queue instance.
-
Note
-
This macro reserves memory for the given queue instance.
-
Parameters
-
|
[in]
|
_type
|
Type which is stored.
|
|
[in]
|
_name
|
Name of the queue.
|
|
[in]
|
_size
|
Size of the queue.
|
|
[in]
|
_mode
|
Mode of the queue.
|
|
#define NRF_QUEUE_INTERFACE_DEC
|
(
|
|
_type,
|
|
|
|
|
_name
|
|
|
)
|
|
|
Value:
size_t
element_count); \
size_t _name##_out(_type * p_data, \
size_t
element_count); \
size_t _name##_in(_type
const
* p_data, \
size_t
element_count); \
bool _name##_is_full(
void
); \
bool _name##_is_empty(
void
); \
size_t _name##_utilization_get(
void
); \
size_t _name##_available_get(
void
); \
size_t _name##_max_utilization_get(
void
); \
void _name##_reset(
void
)
Declare a queue interface.
-
Parameters
-
|
[in]
|
_type
|
Type which is stored.
|
|
[in]
|
_name
|
Name of the queue.
|
|
#define NRF_QUEUE_INTERFACE_DEF
|
(
|
|
_type,
|
|
|
|
|
_name,
|
|
|
|
|
_p_queue
|
|
|
)
|
|
|
Define a queue interface.
-
Parameters
-
|
[in]
|
_type
|
Type which is stored.
|
|
[in]
|
_name
|
Name of the queue.
|
|
[in]
|
_p_queue
|
Queue instance.
|
Peek element from the front of the queue.
-
Parameters
-
|
[in]
|
_p_queue
|
Pointer to the
nrf_queue_t
instance.
|
|
[out]
|
_p_element
|
Pointer where the element will be copied.
|
-
Returns
-
NRF_SUCCESS If an element was returned.
-
NRF_ERROR_NOT_FOUND If there are no more elements in the queue.
Pop element from the front of the queue.
-
Parameters
-
|
[in]
|
_p_queue
|
Pointer to the
nrf_queue_t
instance.
|
|
[out]
|
_p_element
|
Pointer where the element will be copied.
|
-
Returns
-
NRF_SUCCESS If an element was returned.
-
NRF_ERROR_NOT_FOUND If there are no more elements in the queue.
Supported queue modes.
|
Enumerator
|
|
NRF_QUEUE_MODE_OVERFLOW
|
If the queue is full, new element will overwrite the oldest.
|
|
NRF_QUEUE_MODE_NO_OVERFLOW
|
If the queue is full, new element will not be accepted.
|
|
size_t nrf_queue_available_get
|
(
|
nrf_queue_t
const *
|
p_queue
|
)
|
|
Function for getting the size of available space.
-
Parameters
-
|
[in]
|
p_queue
|
Pointer to the queue instance.
|
-
Returns
-
Size of available space.
Generic pop implementation.
-
Parameters
-
|
[in]
|
p_queue
|
Pointer to the
nrf_queue_t
instance.
|
|
[out]
|
p_element
|
Pointer where the element will be copied.
|
|
[out]
|
just_peek
|
If true, the returned element will not be removed from queue.
|
-
Returns
-
NRF_SUCCESS If an element was returned.
-
NRF_ERROR_NOT_FOUND If there are no more elements in the queue.
|
size_t nrf_queue_in
|
(
|
nrf_queue_t
const *
|
p_queue
,
|
|
|
|
void const *
|
p_data
,
|
|
|
|
size_t
|
element_count
|
|
|
)
|
|
|
Function for writing a portion of elements to the queue.
-
Parameters
-
|
[in]
|
p_queue
|
Pointer to the
nrf_queue_t
instance.
|
|
[in]
|
p_data
|
Pointer to the buffer with elements to write.
|
|
[in]
|
element_count
|
Number of elements to write.
|
-
Returns
-
The number of added elements.
|
bool nrf_queue_is_empty
|
(
|
nrf_queue_t
const *
|
p_queue
|
)
|
|
Function for checking if the queue is empty.
-
Parameters
-
|
[in]
|
p_queue
|
Pointer to the queue instance.
|
-
Returns
-
True if the queue is empty.
Function for checking if the queue is full.
-
Parameters
-
|
[in]
|
p_queue
|
Pointer to the queue instance.
|
-
Returns
-
True if the queue is full.
|
size_t nrf_queue_max_utilization_get
|
(
|
nrf_queue_t
const *
|
p_queue
|
)
|
|
Function for getting the maximal queue utilization.
-
Parameters
-
|
[in]
|
p_queue
|
Pointer to the queue instance.
|
-
Returns
-
Maximal queue utilization.
|
void nrf_queue_max_utilization_reset
|
(
|
nrf_queue_t
const *
|
p_queue
|
)
|
|
Function for resetting the maximal queue utilization.
-
Parameters
-
|
[in]
|
p_queue
|
Pointer to the queue instance.
|
|
size_t nrf_queue_out
|
(
|
nrf_queue_t
const *
|
p_queue
,
|
|
|
|
void *
|
p_data
,
|
|
|
|
size_t
|
element_count
|
|
|
)
|
|
|
Function for reading a portion of elements from the queue.
-
Parameters
-
|
[in]
|
p_queue
|
Pointer to the
nrf_queue_t
instance.
|
|
[out]
|
p_data
|
Pointer to the buffer where elements will be copied.
|
|
[in]
|
element_count
|
Number of elements to read.
|
-
Returns
-
The number of read elements.
Function for pushing an element to the end of queue.
-
Parameters
-
|
[in]
|
p_queue
|
Pointer to the
nrf_queue_t
instance.
|
|
[in]
|
p_element
|
Pointer to the element that will be stored in the queue.
|
-
Returns
-
NRF_SUCCESS If an element has been successfully added.
-
NRF_ERROR_NO_MEM If the queue is full (only in
NRF_QUEUE_MODE_NO_OVERFLOW
).
Function for reading elements from the queue.
-
Parameters
-
|
[in]
|
p_queue
|
Pointer to the
nrf_queue_t
instance.
|
|
[out]
|
p_data
|
Pointer to the buffer where elements will be copied.
|
|
[in]
|
element_count
|
Number of elements to read.
|
-
Returns
-
NRF_SUCCESS If an element was returned.
-
NRF_ERROR_NOT_FOUND There is not enough elements in the queue.
Function for resetting the queue state.
-
Parameters
-
|
[in]
|
p_queue
|
Pointer to the queue instance.
|
|
size_t nrf_queue_utilization_get
|
(
|
nrf_queue_t
const *
|
p_queue
|
)
|
|
Function for getting the current queue utilization.
-
Parameters
-
|
[in]
|
p_queue
|
Pointer to the queue instance.
|
-
Returns
-
Current queue utilization.
Function for writing elements to the queue.
-
Parameters
-
|
[in]
|
p_queue
|
Pointer to the
nrf_queue_t
instance.
|
|
[in]
|
p_data
|
Pointer to the buffer with elements to write.
|
|
[in]
|
element_count
|
Number of elements to write.
|
-
Returns
-
NRF_SUCCESS If an element was written.
-
NRF_ERROR_NO_MEM There is not enough space in the queue. No element was written.