Maxim Integrated / MaximBLE

Dependents:   BLE_Thermometer MAXWSNENV_demo

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers wsf_buf.h Source File

wsf_buf.h

Go to the documentation of this file.
00001 /*************************************************************************************************/
00002 /*!
00003  *  \file   wsf_buf.h
00004  *        
00005  *  \brief  Buffer pool service.
00006  *
00007  *          $Date: 2013-05-13 15:20:24 -0700 (Mon, 13 May 2013) $
00008  *          $Revision: 612 $
00009  *  
00010  *  Copyright (c) 2009-2016 ARM Limited. All rights reserved.
00011  *
00012  *  SPDX-License-Identifier: LicenseRef-PBL
00013  *
00014  *  Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use
00015  *  this file except in compliance with the License.  You may obtain a copy of the License at
00016  *
00017  *  https://www.mbed.com/licenses/PBL-1.0
00018  *
00019  *  See the License for the specific language governing permissions and limitations under the License.
00020  */
00021 /*************************************************************************************************/
00022 #ifndef WSF_BUF_H
00023 #define WSF_BUF_H
00024 
00025 #ifdef __cplusplus
00026 extern "C" {
00027 #endif
00028 
00029 /**************************************************************************************************
00030   Macros
00031 **************************************************************************************************/
00032 
00033 /*! Length of the buffer statistics array */
00034 #define WSF_BUF_STATS_MAX_LEN       128
00035 
00036 /**************************************************************************************************
00037   Data Types
00038 **************************************************************************************************/
00039 
00040 /*! Buffer pool descriptor structure */
00041 typedef struct
00042 {
00043   uint16_t   len;                  /*! length of buffers in pool */
00044   uint8_t    num ;                  /*! number of buffers in pool */
00045 } wsfBufPoolDesc_t ;
00046 
00047 
00048 /**************************************************************************************************
00049   Function Declarations
00050 **************************************************************************************************/
00051 
00052 /*************************************************************************************************/
00053 /*!
00054  *  \fn     WsfBufInit
00055  *        
00056  *  \brief  Initialize the buffer pool service.  This function should only be called once
00057  *          upon system initialization.
00058  *
00059  *  \param  bufMemLen Length in bytes of memory pointed to by pBufMem.
00060  *  \param  pBufMem   Memory in which to store the pools used by the buffer pool service.
00061  *  \param  numPools  Number of buffer pools.
00062  *  \param  pDesc     Array of buffer pool descriptors, one for each pool.
00063  *
00064  *  \return TRUE if initialization was successful, FALSE otherwise.
00065  */
00066 /*************************************************************************************************/
00067 bool_t WsfBufInit(uint16_t bufMemLen, uint8_t *pBufMem, uint8_t numPools, wsfBufPoolDesc_t  *pDesc);
00068 
00069 /*************************************************************************************************/
00070 /*!
00071  *  \fn     WsfBufAlloc
00072  *        
00073  *  \brief  Allocate a buffer.
00074  *
00075  *  \param  len     Length of buffer to allocate.
00076  *
00077  *  \return Pointer to allocated buffer or NULL if allocation fails.
00078  */
00079 /*************************************************************************************************/
00080 void *WsfBufAlloc(uint16_t len);
00081 
00082 /*************************************************************************************************/
00083 /*!
00084  *  \fn     WsfBufFree
00085  *        
00086  *  \brief  Free a buffer.
00087  *
00088  *  \param  pBuf    Buffer to free.
00089  *
00090  *  \return None.
00091  */
00092 /*************************************************************************************************/
00093 void WsfBufFree(void *pBuf);
00094 
00095 /*************************************************************************************************/
00096 /*!
00097  *  \fn     WsfBufGetMaxAlloc
00098  *        
00099  *  \brief  Diagnostic function to get maximum allocated buffers from a pool.
00100  *
00101  *  \param  pool    Buffer pool number.
00102  *
00103  *  \return Number of allocated buffers.
00104  */
00105 /*************************************************************************************************/
00106 uint8_t WsfBufGetMaxAlloc(uint8_t pool);
00107 
00108 /*************************************************************************************************/
00109 /*!
00110  *  \fn     WsfBufGetNumAlloc
00111  *        
00112  *  \brief  Diagnostic function to get the number of currently allocated buffers in a pool.
00113  *
00114  *  \param  pool    Buffer pool number.
00115  *
00116  *  \return Number of allocated buffers.
00117  */
00118 /*************************************************************************************************/
00119 uint8_t WsfBufGetNumAlloc(uint8_t pool);
00120 
00121 /*************************************************************************************************/
00122 /*!
00123  *  \fn     WsfBufGetAllocStats
00124  *        
00125  *  \brief  Diagnostic function to get the buffer allocation statistics.
00126  *
00127  *  \return Buffer allocation statistics array.
00128  */
00129 /*************************************************************************************************/
00130 uint8_t *WsfBufGetAllocStats(void);
00131 
00132 
00133 #ifdef __cplusplus
00134 };
00135 #endif
00136 
00137 #endif /* WSF_BUF_H */