-
Notifications
You must be signed in to change notification settings - Fork 0
/
mmic_fifo.c
96 lines (76 loc) · 1.68 KB
/
mmic_fifo.c
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
* Copyright (c) Huawei Technologies Co., Ltd. 2012-2020. All rights reserved.
* Description: common.c
* Author: none
* Create: 2020-05-16
*/
#include "mmic_fifo.h"
#if 0
/*
* PacketDataQueue structure and operations
*
* */
void InitQueue(PacketDataQueueType *pCQ)
{
*(pCQ->pfront) = 0x0u;
*(pCQ->prear) = 0x0u;
return;
}
int IsQueueEmpty(PacketDataQueueType *pCQ)
{
if (*(pCQ->pfront) == *(pCQ->prear))
return 1;
else
return 0;
}
int IsQueueFull(PacketDataQueueType *pCQ)
{
if (*((pCQ->prear) + 1) % PACKET_CNT_QUEUE == *(pCQ->pfront))
return 1;
else
return 0;
}
int PushElement(PacketDataQueueType *pCQ)
{
if (IsQueueFull(pCQ))
return -1;
*(pCQ->prear) = (*(pCQ->prear) + 1) % PACKET_CNT_QUEUE;
return 0;
}
int PopElement(PacketDataQueueType *pCQ)
{
if (IsQueueEmpty(pCQ))
return -1;
*(pCQ->pfront) = (*(pCQ->pfront) + 1) % PACKET_CNT_QUEUE;
return 0;
}
int GetHeadElement(PacketDataQueueType *pCQ, PacketDataType **pData)
{
if (IsQueueEmpty(pCQ))
return -1;
*pData = (PacketDataType*)&(pCQ->ppacketData[(*(pCQ->pfront) + 1) % PACKET_CNT_QUEUE]);
return 0;
}
int GetRearElement(PacketDataQueueType *pCQ, PacketDataType **pData)
{
if (IsQueueFull(pCQ))
return -1;
*pData = (PacketDataType*)&(pCQ->ppacketData[(*(pCQ->prear) + 1) % PACKET_CNT_QUEUE]);
return 0;
}
#endif
int IsQueueFull(U32 front, U32 rear)
{
if ((rear + 1) % PACKET_CNT_QUEUE == front)
return 1;
else
return 0;
}
// int PushElement()
// {
// if (IsQueueFull(pCQ))
// return -1;
// //*(pCQ->prear) = (*(pCQ->prear) + 1) % PACKET_CNT_QUEUE;
// //send to RPU
// return 0;
// }