IRPyro messaging application
Communications program between IRPyro and IRPyro evaluation tool
queue.h
Go to the documentation of this file.
1 /**
2 ******************************************************************************
3 * @file queue.h
4 * @author _KEMET, Ltd
5 * @date March 2018
6 * @version Release 1.0.6
7 * @copyright (c) 2018 _KEMET, Ltd
8 * @brief Operates a circular queue
9 ******************************************************************************
10  @attention <h2><center>&copy; COPYRIGHT 2018 _KEMET, Ltd</center></h2>
11  @verbatim
12  Copyright (c) 2018, _KEMET, Ltd
13  All rights reserved.
14 
15  THIS SOFTWARE IS PROVIDED BY _KEMET, Ltd ''AS IS'' AND ANY
16  EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18  DISCLAIMED. IN NO EVENT SHALL _KEMET, Ltd BE LIABLE FOR ANY
19  DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25  @endverbatim
26 ******************************************************************************
27 */
28 /* Includes ------------------------------------------------------------------*/
29 #ifndef uart_QUEUE_H_
30 #define uart_QUEUE_H_
31 #include <stdio.h>
32 #include <stdint.h>
33 #include <stdarg.h>
34 #include <stdbool.h>
35 /* Exported constants -- ------------------------------------------------------*/
36 #define QUEUE_SIZE (64)
37 /* Exported types ------------------------------------------------------------*/
38 struct Queue
39 {
40  uint8_t pRD , pWR;
41  uint8_t q[QUEUE_SIZE];
42 };
43 // Configuration
44 int message_queue_full(volatile struct Queue *q);
45 int message_queue_empty(volatile struct Queue *q);
46 int message_enqueue(volatile struct Queue *q, uint8_t data);
47 int message_dequeue(volatile struct Queue *q, uint8_t *data);
48 
49 /*============================= END QUEUE HANDLING===========================*/
50 
51 #endif
52 /* ********** Copyright (c) 2018 _KEMET, Ltd. **********END OF FILE************/
Queue::pWR
uint8_t pWR
Definition: queue.h:40
message_dequeue
int message_dequeue(volatile struct Queue *q, uint8_t *data)
Obtains one byte from the circular buffer.
Definition: queue.c:95
QUEUE_SIZE
#define QUEUE_SIZE
Definition: queue.h:36
Queue
Definition: queue.h:39
message_queue_empty
int message_queue_empty(volatile struct Queue *q)
Checks if the queue is empty.
Definition: queue.c:63
Queue::q
uint8_t q[QUEUE_SIZE]
Definition: queue.h:41
message_enqueue
int message_enqueue(volatile struct Queue *q, uint8_t data)
Adds a byte to the circular buffer.
Definition: queue.c:72
Queue::pRD
uint8_t pRD
Definition: queue.h:40
message_queue_full
int message_queue_full(volatile struct Queue *q)
Checks is the queue is full.
Definition: queue.c:55