nrf8001: added new BLE module with broadcasting example
[contrib/upm.git] / src / nrf8001 / aci_queue.h
1 /* Copyright (c) 2014, Nordic Semiconductor ASA\r
2  *\r
3  * Permission is hereby granted, free of charge, to any person obtaining a copy\r
4  * of this software and associated documentation files (the "Software"), to deal\r
5  * in the Software without restriction, including without limitation the rights\r
6  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r
7  * copies of the Software, and to permit persons to whom the Software is\r
8  * furnished to do so, subject to the following conditions:\r
9  *\r
10  * The above copyright notice and this permission notice shall be included in all\r
11  * copies or substantial portions of the Software.\r
12  *\r
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r
14  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r
16  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
17  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r
18  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r
19  * SOFTWARE.\r
20  */\r
21 \r
22 /** @file\r
23  * @brief Interface for buffer.\r
24  */\r
25 \r
26 /** @defgroup aci_queue aci_queue\r
27 @{\r
28 @ingroup aci_queue\r
29 \r
30 */\r
31 \r
32 #ifndef ACI_QUEUE_H__\r
33 #define ACI_QUEUE_H__\r
34 \r
35 #include "aci.h"\r
36 #include "hal_aci_tl.h"\r
37 \r
38 /***********************************************************************    */\r
39 /* The ACI_QUEUE_SIZE determines the memory usage of the system.            */\r
40 /* Successfully tested to a ACI_QUEUE_SIZE of 4 (interrupt) and 4 (polling) */\r
41 /***********************************************************************    */\r
42 #define ACI_QUEUE_SIZE  4\r
43 \r
44 /** Data type for queue of data packets to send/receive from radio.\r
45  *\r
46  *  A FIFO queue is maintained for packets. New packets are added (enqueued)\r
47  *  at the tail and taken (dequeued) from the head. The head variable is the\r
48  *  index of the next packet to dequeue while the tail variable is the index of\r
49  *  where the next packet should be queued.\r
50  */\r
51 \r
52 typedef struct {\r
53     hal_aci_data_t           aci_data[ACI_QUEUE_SIZE];\r
54     uint8_t                  head;\r
55     uint8_t                  tail;\r
56 } aci_queue_t;\r
57 \r
58 void aci_queue_init(aci_queue_t *aci_q);\r
59 \r
60 bool aci_queue_dequeue(aci_queue_t *aci_q, hal_aci_data_t *p_data);\r
61 bool aci_queue_dequeue_from_isr(aci_queue_t *aci_q, hal_aci_data_t *p_data);\r
62 \r
63 bool aci_queue_enqueue(aci_queue_t *aci_q, hal_aci_data_t *p_data);\r
64 bool aci_queue_enqueue_from_isr(aci_queue_t *aci_q, hal_aci_data_t *p_data);\r
65 \r
66 bool aci_queue_is_empty(aci_queue_t *aci_q);\r
67 bool aci_queue_is_empty_from_isr(aci_queue_t *aci_q);\r
68 \r
69 bool aci_queue_is_full(aci_queue_t *aci_q);\r
70 bool aci_queue_is_full_from_isr(aci_queue_t *aci_q);\r
71 \r
72 bool aci_queue_peek(aci_queue_t *aci_q, hal_aci_data_t *p_data);\r
73 bool aci_queue_peek_from_isr(aci_queue_t *aci_q, hal_aci_data_t *p_data);\r
74 \r
75 #endif /* ACI_QUEUE_H__ */\r
76 /** @} */\r