initial commit, reads dev id

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers queue.h Source File

queue.h

00001 /*******************************************************************************
00002 * Author: Ismail Kose, Ismail.Kose@maximintegrated.com
00003 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
00004 *
00005 * Permission is hereby granted, free of charge, to any person obtaining a
00006 * copy of this software and associated documentation files (the "Software"),
00007 * to deal in the Software without restriction, including without limitation
00008 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00009 * and/or sell copies of the Software, and to permit persons to whom the
00010 * Software is furnished to do so, subject to the following conditions:
00011 *
00012 * The above copyright notice and this permission notice shall be included
00013 * in all copies or substantial portions of the Software.
00014 *
00015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00016 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00017 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00018 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
00019 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00020 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00021 * OTHER DEALINGS IN THE SOFTWARE.
00022 *
00023 * Except as contained in this notice, the name of Maxim Integrated
00024 * Products, Inc. shall not be used except as stated in the Maxim Integrated
00025 * Products, Inc. Branding Policy.
00026 *
00027 * The mere transfer of this software does not imply any licenses
00028 * of trade secrets, proprietary technology, copyrights, patents,
00029 * trademarks, maskwork rights, or any other form of intellectual
00030 * property whatsoever. Maxim Integrated Products, Inc. retains all
00031 * ownership rights.
00032 *******************************************************************************
00033 */
00034 
00035 #ifndef _QUEUE_H_
00036 #define _QUEUE_H_
00037 #include <stdio.h>
00038 #include <stdint.h>
00039 #include <string.h>
00040 #include <stdlib.h>
00041 
00042 struct queue_t {
00043     void *wr; // write pointer
00044     void *rd; // read pointer
00045     void *base; // buffer base pointer
00046     int num_item; // number of data item
00047     int ovf_item; // Number of overflowed data
00048     int buffer_size; // buffer size in bytes
00049     int item_size; // data size
00050 };
00051 
00052 /**
00053  * @brief Queue initialization.
00054  * @param[in]       *q Points to the queue handle
00055  * @param[in]       *buf Points to external queue buffer
00056  * @param[in]       item_size Data size
00057  * @param[in]       buffer_size Total buffer size in bytes
00058  * @param[out]      *pDst points to output matrix structure
00059  * @return     The function returns 0: success
00060  *                              -1: Invalid Pointer
00061  *                              -2: Queue buffer is full, no more space
00062  **/
00063 int queue_init(struct queue_t *q, void *buf, int item_size, int buffer_size);
00064 
00065 
00066 
00067 
00068 /**
00069  * @brief Data reset.
00070  * @param[in]       *q Points to the queue handle
00071  * @param[in]       *data Points to any type of data to put FIFO
00072  * @param[out]      *pDst Points to output matrix structure
00073  * @return     The function returns 0: success
00074  *                              -1: Invalid Pointer
00075  *                              -2: Queue buffer is full, no more space
00076  **/
00077 int queue_reset(struct queue_t *q);
00078 
00079 
00080 /**
00081  * @brief Data enqueue.
00082  * @param[in]       *q points to the queue handle
00083  * @param[in]       *data points to any type of data to put FIFO
00084  * @return     The function returns 0: success
00085  *                              -1: Invalid Pointer
00086  *                              -2: Queue buffer is full, no more space
00087  **/
00088 int enqueue(struct queue_t *q, void *data);
00089 
00090 
00091 /**
00092  * @brief Data dequeue.
00093  * @param[in]       *q points to the queue handle
00094  * @param[in]       *data points to any type of data to put FIFO
00095  * @param[out]      *data pop data from Queue
00096  * @return     The function returns 0: success
00097  *                              -1: Invalid Pointer
00098  *                              -2: Queue buffer is empty
00099  **/
00100 int dequeue(struct queue_t *q, void *data);
00101 
00102 
00103 
00104 /**
00105  * @brief Queue Destroy
00106  * @param[in]       *q points to the queue handle
00107  **/
00108 void queue_destroy(struct queue_t *q);
00109 #endif //_QUEUE_H_
00110