MAX32620HSP (MAXREFDES100) RPC Example for Graphical User Interface

Dependencies:   USBDevice

Fork of HSP_Release by Jerry Bradshaw

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers RpcFifo.h Source File

RpcFifo.h

00001 /*******************************************************************************
00002  * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a
00005  * copy of this software and associated documentation files (the "Software"),
00006  * to deal in the Software without restriction, including without limitation
00007  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00008  * and/or sell copies of the Software, and to permit persons to whom the
00009  * Software is furnished to do so, subject to the following conditions:
00010  *
00011  * The above copyright notice and this permission notice shall be included
00012  * in all copies or substantial portions of the Software.
00013  *
00014  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00015  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00016  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00017  * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
00018  * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00019  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00020  * OTHER DEALINGS IN THE SOFTWARE.
00021  *
00022  * Except as contained in this notice, the name of Maxim Integrated
00023  * Products, Inc. shall not be used except as stated in the Maxim Integrated
00024  * Products, Inc. Branding Policy.
00025  *
00026  * The mere transfer of this software does not imply any licenses
00027  * of trade secrets, proprietary technology, copyrights, patents,
00028  * trademarks, maskwork rights, or any other form of intellectual
00029  * property whatsoever. Maxim Integrated Products, Inc. retains all
00030  * ownership rights.
00031  *
00032  ********************************************************************************
00033  */
00034 #ifndef _RPCFIFO_H_
00035 #define _RPCFIFO_H_
00036 
00037 #include <stdint.h>
00038 
00039 /// Structure used for FIFO management
00040 typedef struct {
00041   unsigned int length; ///< FIFO size (number of elements)
00042   void *data;          ///< pointer to the FIFO buffer
00043   unsigned int rindex; ///< current FIFO read index
00044   unsigned int windex; ///< current FIFO write index
00045 } fifo_t;
00046 
00047 /**
00048 * @param    fifo     FIFO on which to perform the operation
00049 * @param    mem      memory buffer to use for FIFO element storage
00050 * @param    length   number of elements that the memory buffer can contain
00051 * @returns  0 if successful, -1 upon failure
00052 */
00053 void fifo_init(fifo_t *fifo, void *mem, unsigned int length);
00054 
00055 /**
00056 * @brief    Adds and 8-bit element to the FIFO
00057 * @param    fifo     FIFO on which to perform the operation
00058 * @param    element  element to add to the FIFO
00059 * @returns  0 if successful, -1 upon failure
00060 */
00061 int fifo_put8(fifo_t *fifo, uint8_t element);
00062 
00063 /**
00064 * @brief    Gets the next 8-bit element to the FIFO
00065 * @param    fifo     FIFO on which to perform the operation
00066 * @param    element  pointer to where to store the element from the FIFO
00067 * @returns  0 if successful, -1 upon failure
00068 */
00069 int fifo_get8(fifo_t *fifo, uint8_t *element);
00070 
00071 /**
00072 * @brief    Adds the next 16-bit element to the FIFO
00073 * @param    fifo     FIFO on which to perform the operation
00074 * @param    element  element to add to the FIFO
00075 * @returns  0 if successful, -1 upon failure
00076 */
00077 int fifo_put16(fifo_t *fifo, uint16_t element);
00078 
00079 /**
00080 * @brief    Gets the next 16-bit element to the FIFO
00081 * @param    fifo     FIFO on which to perform the operation
00082 * @param    element  pointer to where to store the element from the FIFO
00083 * @returns  0 if successful, -1 upon failure
00084 */
00085 int fifo_get16(fifo_t *fifo, uint16_t *element);
00086 
00087 /**
00088 * @brief    Adds the next 16-bit element to the FIFO
00089 * @param    fifo     FIFO on which to perform the operation
00090 * @param    element  element to add to the FIFO
00091 * @returns  0 if successful, -1 upon failure
00092 */
00093 int fifo_put32(fifo_t *fifo, uint32_t element);
00094 
00095 /**
00096 * @brief    Gets the next 16-bit element to the FIFO
00097 * @param    fifo     FIFO on which to perform the operation
00098 * @param    element  pointer to where to store the element from the FIFO
00099 * @returns  0 if successful, -1 upon failure
00100 */
00101 int fifo_get32(fifo_t *fifo, uint32_t *element);
00102 
00103 /**
00104 * @brief    Immediately resets the FIFO to the empty state
00105 * @param    fifo   FIFO on which to perform the operation
00106 */
00107 void fifo_clear(fifo_t *fifo);
00108 
00109 /**
00110 * @brief    Determines if the FIFO is empty
00111 * @param    fifo   FIFO on which to perform the operation
00112 * @returns  #TRUE if FIFO is empty, #FALSE otherwise
00113 */
00114 int fifo_empty(fifo_t *fifo);
00115 
00116 /**
00117 * @brief    FIFO status function
00118 * @param    fifo   FIFO on which to perform the operation
00119 * @returns  #TRUE if FIFO is full, #FALSE otherwise
00120 */
00121 int fifo_full(fifo_t *fifo);
00122 
00123 /**
00124 * @brief    FIFO status function
00125 * @param    fifo   FIFO on which to perform the operation
00126 * @returns  the number of elements currently in the FIFO
00127 */
00128 unsigned int fifo_level(fifo_t *fifo);
00129 
00130 /**
00131 * @brief    FIFO status function
00132 * @param    fifo   FIFO on which to perform the operation
00133 * @returns  the remaining elements that can be added to the FIFO
00134 */
00135 unsigned int fifo_remaining(fifo_t *fifo);
00136 
00137 #endif // _RPCFIFO_H_