xref: /btstack/port/stm32-wb55xx-nucleo-freertos/Middlewares/STM32_WPAN/utilities/stm_queue.h (revision 0561b2d8d5dba972c7daa57d5e677f7a1327edfd)
1 /**
2   ******************************************************************************
3   * @file    stm_queue.h
4   * @author  MCD Application Team
5   * @brief   Header for stm_queue.c
6   ******************************************************************************
7    * @attention
8   *
9   * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
10   * All rights reserved.</center></h2>
11   *
12   * This software component is licensed by ST under BSD 3-Clause license,
13   * the "License"; You may not use this file except in compliance with the
14   * License. You may obtain a copy of the License at:
15   *                        opensource.org/licenses/BSD-3-Clause
16   *
17   ******************************************************************************
18  */
19 
20 
21 
22 /* Define to prevent recursive inclusion -------------------------------------*/
23 #ifndef __STM_QUEUE_H
24 #define __STM_QUEUE_H
25 
26 /* Includes ------------------------------------------------------------------*/
27 /* Exported define -----------------------------------------------------------*/
28 /* Options flags */
29 #define CIRCULAR_QUEUE_NO_FLAG 0
30 #define CIRCULAR_QUEUE_NO_WRAP_FLAG 1
31 #define CIRCULAR_QUEUE_SPLIT_IF_WRAPPING_FLAG 2
32 
33 
34 /* Exported types ------------------------------------------------------------*/
35 typedef struct {
36    uint8_t* qBuff;        /* queue buffer, , provided by init fct */
37    uint32_t queueMaxSize;   /* size of the queue, provided by init fct (in bytes)*/
38    uint16_t elementSize;    /* -1 variable. If variable elemenet size the size is stored in the 4 first of the queue element */
39    uint32_t first;          /* position of first element */
40    uint32_t last;           /* position of last element */
41    uint32_t byteCount;      /* number of bytes in the queue */
42    uint32_t elementCount;   /* number of element in the queue */
43    uint8_t  optionFlags;     /* option to enable specific features */
44 } queue_t;
45 
46 /* Exported constants --------------------------------------------------------*/
47 
48 /* Exported macro ------------------------------------------------------------*/
49 /* Exported functions ------------------------------------------------------- */
50 int CircularQueue_Init(queue_t *q, uint8_t* queueBuffer, uint32_t queueSize, uint16_t elementSize, uint8_t optionlags);
51 uint8_t* CircularQueue_Add(queue_t *q, uint8_t* x, uint16_t elementSize, uint32_t nbElements);
52 uint8_t* CircularQueue_Remove(queue_t *q, uint16_t* elementSize);
53 uint8_t* CircularQueue_Sense(queue_t *q, uint16_t* elementSize);
54 int CircularQueue_Empty(queue_t *q);
55 int CircularQueue_NbElement(queue_t *q);
56 uint8_t* CircularQueue_Remove_Copy(queue_t *q, uint16_t* elementSize, uint8_t* buffer);
57 uint8_t* CircularQueue_Sense_Copy(queue_t *q, uint16_t* elementSize, uint8_t* buffer);
58 
59 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
60 #endif /* __STM_QUEUE_H */
61