aboutsummaryrefslogtreecommitdiff
path: root/src/app/google_rcu/loop_queue.h
blob: f228e8791249eeb5080bd72600934e3e03c1bf59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
*********************************************************************************************************
*               Copyright(c) 2020, Realtek Semiconductor Corporation. All rights reserved.
*********************************************************************************************************
* @file      loop_queue.h
* @brief
* @details
* @author    barry_bian
* @date      2020-04-09
* @version   v1.0
* *********************************************************************************************************
*/

#ifndef __LOOP_QUEUE_H
#define __LOOP_QUEUE_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "trace.h"
#include "string.h"
#include "os_mem.h"

/* Defines ------------------------------------------------------------------*/

#ifdef PRINT_LOG
#define LOOP_QUEUE_DBG_BUFFER(module, level, fmt, param_num,...) \
    DBG_BUFFER_##level(TYPE_BUMBLEBEE3, SUBTYPE_FORMAT, module, fmt, param_num, ##__VA_ARGS__)

#else
#define LOOP_QUEUE_DBG_BUFFER(MODULE, LEVEL, pFormat, para_num,...) ((void)0)
#endif

typedef void *T_LOOP_QUEUE_BUF;

/**
 * @brief Loop queue data struct
 */
typedef struct
{
    volatile bool               is_over_flow;       /* loop queue item size */
    volatile uint16_t           item_size;          /* buf data type */
    volatile uint16_t           buf_max_item_num;   /* Buffer size of loop queue */
    volatile uint16_t           read_index;         /* index of read queue */
    volatile uint16_t           write_index;        /* index of write queue */
    volatile T_LOOP_QUEUE_BUF   p_buf;              /* Buffer for loop queue */
} T_LOOP_QUEUE_DEF;


T_LOOP_QUEUE_DEF *loop_queue_init(uint16_t buf_max_size, uint16_t item_size,
                                  RAM_TYPE ram_type);
void loop_queue_deinit(T_LOOP_QUEUE_DEF **p_loop_queue);
bool loop_queue_is_full(T_LOOP_QUEUE_DEF *p_queue_struct, uint16_t write_size);
bool loop_queue_is_empty(T_LOOP_QUEUE_DEF *p_queue_struct);
uint16_t loop_queue_get_vailid_data_size(T_LOOP_QUEUE_DEF *p_queue_struct);
uint16_t loop_queue_get_free_data_size(T_LOOP_QUEUE_DEF *p_loop_queue);
bool loop_queue_write_buf(T_LOOP_QUEUE_DEF *p_queue_struct, T_LOOP_QUEUE_BUF p_buf, uint16_t size,
                          bool is_overflow_data_abandoned);
bool loop_queue_read_buf(T_LOOP_QUEUE_DEF *p_queue_struct, T_LOOP_QUEUE_BUF p_buf, uint16_t size);
bool loop_queue_copy_buf(T_LOOP_QUEUE_DEF *p_queue_struct, T_LOOP_QUEUE_BUF p_buf, uint16_t size);

#ifdef __cplusplus
}
#endif

#endif /*__UART_TRANS_H*/

/******************* (C) COPYRIGHT 2017 Realtek Semiconductor Corporation *****END OF FILE****/