1 /**
2  ********************************************************************************************************
3  Copyright (c) 2015, Realtek Semiconductor Corporation. All rights reserved.
4  *********************************************************************************************************
5  * @file      cycle_queue.h
6  * @brief     Log cycle buffer implementation head file.
7  * @details
8  *
9  * @author  lory_xu
10  * @date        2015-07-13
11  * @version v0.1
12  */
13 
14 #ifndef _CYCLE_QUEUE_H_
15 #define _CYCLE_QUEUE_H_
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 #include <stdint.h>
21 #include <stdbool.h>
22 
23 #define MAX_BUFFER_SIZE 2048
24 
25 /** @brief  Log Buffer */
26 extern uint8_t *cyc_buffer;
27 
28 /** @brief  Read pointer of Log Buffer */
29 extern volatile uint16_t pRead;
30 
31 /** @brief  Write pointer of Log Buffer */
32 extern volatile uint16_t pWrite;
33 
34 /**
35  * @brief Check log buffer is empty or not.
36  * @param  void.
37  * @return  Status of log buffer.
38  * @retval TURE if empty, FAILE if not empty.
39  */
40 uint8_t IsCycQueueEmpty(void);
41 
42 /**
43  * @brief Check log buffer is full or not.
44  * @param  void.
45  * @return  Status of log buffer.
46  * @retval TURE if full, FAILE if not full.
47  */
48 uint8_t IsCycQueueFull(void);
49 
50 /**
51  * @brief Return the number of data in log buffer.
52  * @param  void.
53  * @return  the number of data in log buffer.
54  */
55 uint16_t CycQueueSize(void);
56 
57 /**
58  * @brief  Return the available buffer size in log buffer.
59  * @param  void.
60  * @return  the available buffer size in log buffer.
61  */
62 uint16_t CycQueueRemainSize(void);
63 
64 /**
65  * @brief Put data in log buffer.
66  * @param  pWriteBuf -- Start address of write buffer.
67  * @param  length -- Length of write buffer.
68  * @return  the status of operation.
69  * @retval TURE if success, FAILE if fail.
70  */
71 bool CycQueueWrite(uint8_t *pWriteBuf, uint16_t length);
72 void UpdateQueueRead(uint16_t SendSize);
73 
74 /**
75  * @brief free the buffer
76  *
77  * @param free the buffer
78  *
79  * @return
80  */
81 void FreeCycQueue(void);
82 #ifdef __cplusplus
83 }
84 #endif
85 
86 #endif
87