Espotel / Mbed 2 deprecated LoRaWAN_Semtech_stack

Dependencies:   SX1272lib mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers utilities.h Source File

utilities.h

00001 /*
00002  / _____)             _              | |
00003 ( (____  _____ ____ _| |_ _____  ____| |__
00004  \____ \| ___ |    (_   _) ___ |/ ___)  _ \
00005  _____) ) ____| | | || |_| ____( (___| | | |
00006 (______/|_____)_|_|_| \__)_____)\____)_| |_|
00007     (C)2013 Semtech
00008 Description: Helper functions implementation
00009 License: Revised BSD License, see LICENSE.TXT file include in the project
00010 Maintainer: Miguel Luis and Gregory Cristian
00011 */
00012 #ifndef __UTILITIES_H__
00013 #define __UTILITIES_H__
00014 
00015 /*!
00016  * \brief Returns the minimum value betwen a and b
00017  *
00018  * \param [IN] a 1st value
00019  * \param [IN] b 2nd value
00020  * \retval minValue Minimum value
00021  */
00022 #define MIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) )
00023 
00024 /*!
00025  * \brief Returns the maximum value betwen a and b
00026  *
00027  * \param [IN] a 1st value
00028  * \param [IN] b 2nd value
00029  * \retval maxValue Maximum value
00030  */
00031 #define MAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
00032 
00033 /*!
00034  * \brief Returns 2 raised to the power of n
00035  *
00036  * \param [IN] n power value
00037  * \retval result of raising 2 to the power n
00038  */
00039 #define POW2( n ) ( 1 << n )
00040 
00041 /*!
00042  * \brief Initializes the pseudo ramdom generator initial value
00043  *
00044  * \param [IN] seed Pseudo ramdom generator initial value
00045  */
00046 void srand1( uint32_t seed );
00047 
00048 /*!
00049  * \brief Computes a random number between min and max
00050  *
00051  * \param [IN] min range minimum value
00052  * \param [IN] max range maximum value
00053  * \retval random random value in range min..max
00054  */
00055 int32_t randr( int32_t min, int32_t max );
00056 
00057 /*!
00058  * \brief Copies size elements of src array to dst array
00059  * 
00060  * \remark STM32 Standard memcpy function only works on pointers that are aligned
00061  *
00062  * \param [OUT] dst  Destination array
00063  * \param [IN]  src  Source array
00064  * \param [IN]  size Number of bytes to be copied
00065  */
00066 void memcpy1( uint8_t *dst, const uint8_t *src, uint16_t size );
00067 
00068 /*!
00069  * \brief Set size elements of dst array with value 
00070  * 
00071  * \remark STM32 Standard memset function only works on pointers that are aligned
00072  *
00073  * \param [OUT] dst   Destination array
00074  * \param [IN]  value Default value
00075  * \param [IN]  size  Number of bytes to be copied
00076  */
00077 void memset1( uint8_t *dst, uint8_t value, uint16_t size );
00078 
00079 /*!
00080  * \brief Converts a nibble to an hexadecimal character
00081  * 
00082  * \param [IN] a   Nibble to be converted
00083  * \retval hexChar Converted hexadecimal character
00084  */
00085 int8_t Nibble2HexChar( uint8_t a );
00086 
00087 #endif // __UTILITIES_H__