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