NXP / fsl_phy_mcr20a

Fork of fsl_phy_mcr20a by Freescale

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers FunctionLib.h Source File

FunctionLib.h

Go to the documentation of this file.
00001 /*!
00002 * Copyright (c) 2015, Freescale Semiconductor, Inc.
00003 * All rights reserved.
00004 *
00005 * \file FunctionLib.h
00006 * This is the Function Lib module header file
00007 *
00008 * Redistribution and use in source and binary forms, with or without modification,
00009 * are permitted provided that the following conditions are met:
00010 *
00011 * o Redistributions of source code must retain the above copyright notice, this list
00012 *   of conditions and the following disclaimer.
00013 *
00014 * o Redistributions in binary form must reproduce the above copyright notice, this
00015 *   list of conditions and the following disclaimer in the documentation and/or
00016 *   other materials provided with the distribution.
00017 *
00018 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
00019 *   contributors may be used to endorse or promote products derived from this
00020 *   software without specific prior written permission.
00021 *
00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00023 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00024 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00025 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
00026 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00027 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00028 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
00029 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00030 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00031 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00032 */
00033 
00034 #ifndef _FUNCTION_LIB_H_
00035 #define _FUNCTION_LIB_H_
00036 
00037 #include "EmbeddedTypes.h "
00038 
00039 /*! *********************************************************************************
00040 *************************************************************************************
00041 * Public macros
00042 *************************************************************************************
00043 ********************************************************************************** */
00044 
00045 #ifndef gUseToolchainMemFunc_d
00046 #define gUseToolchainMemFunc_d 0
00047 #endif
00048 
00049 #define FLib_MemSet16 FLib_MemSet
00050 
00051 /*! *********************************************************************************
00052 *************************************************************************************
00053 * Public prototypes
00054 *************************************************************************************
00055 ********************************************************************************** */
00056 
00057 /*! *********************************************************************************
00058 *************************************************************************************
00059 * Public type definitions
00060 *************************************************************************************
00061 ********************************************************************************** */
00062 
00063 /*! *********************************************************************************
00064 *************************************************************************************
00065 * Public memory declarations
00066 *************************************************************************************
00067 ********************************************************************************** */
00068 
00069 /*! *********************************************************************************
00070 *************************************************************************************
00071 * Public functions
00072 *************************************************************************************
00073 ********************************************************************************** */
00074 
00075 #ifdef __cplusplus
00076 extern "C" {
00077 #endif
00078 
00079 /*! *********************************************************************************
00080 * \brief  Copy the content of one memory block to another. The amount of data to copy
00081 *         must be specified in number of bytes.
00082 *
00083 * \param[out] pDst   Pointer to destination memory block
00084 * \param[in] pSrc    Pointer to source memory block
00085 * \param[in] cBytes  Number of bytes to copy
00086 *
00087 ********************************************************************************** */
00088 void FLib_MemCpy (void* pDst,
00089                   void* pSrc,
00090                   uint32_t cBytes
00091                   );
00092 
00093 void FLib_MemCpyAligned32bit (void* to_ptr,
00094                               void* from_ptr,
00095                               register uint32_t number_of_bytes);
00096 
00097 void FLib_MemCpyDir (void* pBuf1,
00098                      void* pBuf2,
00099                      bool_t dir,
00100                      uint32_t n);
00101 
00102 
00103 /*! *********************************************************************************
00104 * \brief  Copy bytes. The byte at index i from the source buffer is copied to index
00105 *         ((n-1) - i) in the destination buffer (and vice versa).
00106 *
00107 * \param[out] pDst   Pointer to destination memory block
00108 * \param[in] pSrc    Pointer to source memory block
00109 * \param[in] cBytes  Number of bytes to copy
00110 *
00111 ********************************************************************************** */
00112 void FLib_MemCpyReverseOrder (void* pDst,
00113                               void* pSrc,
00114                               uint32_t cBytes
00115                              );
00116 
00117 
00118 /*! *********************************************************************************
00119 * \brief  Compare two memory blocks. The number of bytes to compare must be specified. 
00120 *         If the blocks are equal byte by byte, the function returns TRUE, 
00121 *         and FALSE otherwise.
00122 *
00123 * \param[in] pData1  First memory block to compare
00124 * \param[in] pData2  Second memory block to compare
00125 * \param[in] cBytes  Number of bytes to compare
00126 *
00127 * \return  TRUE if memory areas are equal. FALSE othwerwise.
00128 *
00129 ********************************************************************************** */
00130 bool_t FLib_MemCmp (void* pData1,
00131                     void* pData2,
00132                     uint32_t cBytes
00133                    );
00134 
00135 
00136 /*! *********************************************************************************
00137 * \brief  Reset bytes in a memory block to a certain value. The value, and the number
00138 *         of bytes to be set, are supplied as arguments.
00139 *
00140 * \param[in] pData   Pointer to memory block to reset
00141 * \param[in] value   Value that memory block will be set to
00142 * \param[in] cBytes  Number of bytes to set
00143 *
00144 ********************************************************************************** */
00145  void FLib_MemSet (void* pData,
00146                    uint8_t value,
00147                    uint32_t cBytes
00148                   );
00149 
00150 
00151 /*! *********************************************************************************
00152 * \brief Copy bytes, possibly into the same overlapping memory as it is taken from
00153 *
00154 * \param[out] pDst   Pointer to destination memory block
00155 * \param[in] pSrc    Pointer to source memory block
00156 * \param[in] cBytes  Number of bytes to copy
00157 *
00158 ********************************************************************************** */
00159 void FLib_MemInPlaceCpy (void* pDst,
00160                          void* pSrc,
00161                          uint32_t cBytes
00162                         );
00163 
00164 
00165 /*! *********************************************************************************
00166 * \brief  Copies a 16bit value to an unaligned a memory block.
00167 *
00168 * \param[out] pDst   Pointer to destination memory block
00169 * \param[in] val16   The 16-bit value to be copied
00170 *
00171 ********************************************************************************** */
00172 void FLib_MemCopy16Unaligned (void* pDst, 
00173                               uint16_t val16
00174                              );
00175 
00176 
00177 /*! *********************************************************************************
00178 * \brief  Copies a 32bit value to an unaligned a memory block.
00179 *
00180 * \param[out] pDst   Pointer to destination memory block
00181 * \param[in] val32   The 32-bit value to be copied
00182 *
00183 ********************************************************************************** */
00184 void FLib_MemCopy32Unaligned (void* pDst,
00185                               uint32_t val32
00186                              );
00187 
00188 
00189 /*! *********************************************************************************
00190 * \brief  Copies a 64bit value to an unaligned a memory block.
00191 *
00192 * \param[out] pDst   Pointer to destination memory block
00193 * \param[in] val64   The 64-bit value to be copied
00194 *
00195 ********************************************************************************** */
00196 void FLib_MemCopy64Unaligned (void* pDst,
00197                               uint64_t val64
00198                              );
00199 
00200 
00201 /*! *********************************************************************************
00202 * \brief Add an offset to a pointer.
00203 *
00204 * \param[out] pPtr   Pointer to the pointer to be updated
00205 * \param[in] offset  The offset(in bytes) to be added
00206 *
00207 ********************************************************************************** */
00208 void FLib_AddOffsetToPointer (void** pPtr,
00209                               uint32_t offset);
00210 
00211 #define FLib_AddOffsetToPtr(pPtr,offset) FLib_AddOffsetToPointer((void**)(pPtr),(offset))
00212 
00213 
00214 /*! *********************************************************************************
00215 * \brief  This function returns the length of a NULL terminated string.
00216 *
00217 * \param[in]  str  A NULL terminated string
00218 *
00219 * \return  the size of string in bytes
00220 *
00221 ********************************************************************************** */
00222 uint32_t FLib_StrLen(char *str);
00223 
00224 
00225 /*! *********************************************************************************
00226 * \brief  Compare two bytes.
00227 *
00228 * \param[in] c1  first byte to compare
00229 * \param[in] c2  second byte to compare
00230 *
00231 * \return  TRUE if the two bytes are equal, and FALSE otherwise.
00232 *
00233 ********************************************************************************** */
00234 #define FLib_Cmp2Bytes(c1, c2) (*((uint16_t*) (c1)) == *((uint16_t*) (c2)))
00235 
00236 
00237 /*! *********************************************************************************
00238 * \brief  Returns the maximum value of arguments a and b.
00239 *
00240 * \return  The maximum value of arguments a and b
00241 *
00242 * \remarks
00243 *   The primitive should must be implemented as a macro, as it should be possible to
00244 *   evaluate the result on compile time if the arguments are constants.
00245 *
00246 ********************************************************************************** */
00247 #define FLib_GetMax(a,b)    (((a) > (b)) ? (a) : (b))
00248 
00249 
00250 /*! *********************************************************************************
00251 * \brief  Returns the minimum value of arguments a and b.
00252 *
00253 * \return  The minimum value of arguments a and b
00254 *
00255 * \remarks
00256 *   The primitive should must be implemented as a macro, as it should be possible to
00257 *   evaluate the result on compile time if the arguments are constants.
00258 *
00259 ********************************************************************************** */
00260 #define FLib_GetMin(a,b)    (((a) < (b)) ? (a) : (b))
00261 
00262 #ifdef __cplusplus
00263 }
00264 #endif
00265 
00266 #endif /* _FUNCTION_LIB_H_ */