Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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 #include "mbed.h" 00016 00017 #ifndef TimerTime_t 00018 typedef uint64_t TimerTime_t; 00019 #endif 00020 00021 /*! 00022 * \brief Returns the minimum value betwen a and b 00023 * 00024 * \param [IN] a 1st value 00025 * \param [IN] b 2nd value 00026 * \retval minValue Minimum value 00027 */ 00028 #define MIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) ) 00029 00030 /*! 00031 * \brief Returns the maximum value betwen a and b 00032 * 00033 * \param [IN] a 1st value 00034 * \param [IN] b 2nd value 00035 * \retval maxValue Maximum value 00036 */ 00037 #define MAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) ) 00038 00039 /*! 00040 * \brief Returns 2 raised to the power of n 00041 * 00042 * \param [IN] n power value 00043 * \retval result of raising 2 to the power n 00044 */ 00045 #define POW2( n ) ( 1 << n ) 00046 00047 /*! 00048 * \brief Initializes the pseudo ramdom generator initial value 00049 * 00050 * \param [IN] seed Pseudo ramdom generator initial value 00051 */ 00052 void srand1( uint32_t seed ); 00053 00054 /*! 00055 * \brief Computes a random number between min and max 00056 * 00057 * \param [IN] min range minimum value 00058 * \param [IN] max range maximum value 00059 * \retval random random value in range min..max 00060 */ 00061 int32_t randr( int32_t min, int32_t max ); 00062 00063 /*! 00064 * \brief Copies size elements of src array to dst array 00065 * 00066 * \remark STM32 Standard memcpy function only works on pointers that are aligned 00067 * 00068 * \param [OUT] dst Destination array 00069 * \param [IN] src Source array 00070 * \param [IN] size Number of bytes to be copied 00071 */ 00072 void memcpy1( uint8_t *dst, const uint8_t *src, uint16_t size ); 00073 00074 /*! 00075 * \brief Copies size elements of src array to dst array reversing the byte order 00076 * 00077 * \param [OUT] dst Destination array 00078 * \param [IN] src Source array 00079 * \param [IN] size Number of bytes to be copied 00080 */ 00081 void memcpyr( uint8_t *dst, const uint8_t *src, uint16_t size ); 00082 00083 /*! 00084 * \brief Set size elements of dst array with value 00085 * 00086 * \remark STM32 Standard memset function only works on pointers that are aligned 00087 * 00088 * \param [OUT] dst Destination array 00089 * \param [IN] value Default value 00090 * \param [IN] size Number of bytes to be copied 00091 */ 00092 void memset1( uint8_t *dst, uint8_t value, uint16_t size ); 00093 00094 /*! 00095 * \brief Converts a nibble to an hexadecimal character 00096 * 00097 * \param [IN] a Nibble to be converted 00098 * \retval hexChar Converted hexadecimal character 00099 */ 00100 int8_t Nibble2HexChar( uint8_t a ); 00101 00102 #endif // __UTILITIES_H__
Generated on Tue Jul 12 2022 15:51:16 by
1.7.2