Espotel
/
LoRaWAN_ELMO_TxRx_Template
Example Tx Rx LoRa code for Multitech Conduit. Based on Semtech stack for ELMO - ver. 4.1.0.
utils/utilities.h@6:71b489e70063, 2016-04-19 (annotated)
- Committer:
- Pasi
- Date:
- Tue Apr 19 21:48:58 2016 +0000
- Revision:
- 6:71b489e70063
- Parent:
- 1:2be292bd43f9
Text tweaking
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mleksio | 0:c58229885f95 | 1 | /* |
mleksio | 0:c58229885f95 | 2 | / _____) _ | | |
mleksio | 0:c58229885f95 | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ |
mleksio | 0:c58229885f95 | 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ |
mleksio | 0:c58229885f95 | 5 | _____) ) ____| | | || |_| ____( (___| | | | |
mleksio | 0:c58229885f95 | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| |
mleksio | 0:c58229885f95 | 7 | (C)2013 Semtech |
mleksio | 0:c58229885f95 | 8 | Description: Helper functions implementation |
mleksio | 0:c58229885f95 | 9 | License: Revised BSD License, see LICENSE.TXT file include in the project |
mleksio | 0:c58229885f95 | 10 | Maintainer: Miguel Luis and Gregory Cristian |
mleksio | 0:c58229885f95 | 11 | */ |
mleksio | 0:c58229885f95 | 12 | #ifndef __UTILITIES_H__ |
mleksio | 0:c58229885f95 | 13 | #define __UTILITIES_H__ |
mleksio | 0:c58229885f95 | 14 | |
mleksio | 1:2be292bd43f9 | 15 | #include "mbed.h" |
mleksio | 1:2be292bd43f9 | 16 | |
mleksio | 1:2be292bd43f9 | 17 | #ifndef TimerTime_t |
mleksio | 1:2be292bd43f9 | 18 | typedef uint64_t TimerTime_t; |
mleksio | 1:2be292bd43f9 | 19 | #endif |
mleksio | 1:2be292bd43f9 | 20 | |
mleksio | 0:c58229885f95 | 21 | /*! |
mleksio | 0:c58229885f95 | 22 | * \brief Returns the minimum value betwen a and b |
mleksio | 0:c58229885f95 | 23 | * |
mleksio | 0:c58229885f95 | 24 | * \param [IN] a 1st value |
mleksio | 0:c58229885f95 | 25 | * \param [IN] b 2nd value |
mleksio | 0:c58229885f95 | 26 | * \retval minValue Minimum value |
mleksio | 0:c58229885f95 | 27 | */ |
mleksio | 0:c58229885f95 | 28 | #define MIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) ) |
mleksio | 0:c58229885f95 | 29 | |
mleksio | 0:c58229885f95 | 30 | /*! |
mleksio | 0:c58229885f95 | 31 | * \brief Returns the maximum value betwen a and b |
mleksio | 0:c58229885f95 | 32 | * |
mleksio | 0:c58229885f95 | 33 | * \param [IN] a 1st value |
mleksio | 0:c58229885f95 | 34 | * \param [IN] b 2nd value |
mleksio | 0:c58229885f95 | 35 | * \retval maxValue Maximum value |
mleksio | 0:c58229885f95 | 36 | */ |
mleksio | 0:c58229885f95 | 37 | #define MAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) ) |
mleksio | 0:c58229885f95 | 38 | |
mleksio | 0:c58229885f95 | 39 | /*! |
mleksio | 0:c58229885f95 | 40 | * \brief Returns 2 raised to the power of n |
mleksio | 0:c58229885f95 | 41 | * |
mleksio | 0:c58229885f95 | 42 | * \param [IN] n power value |
mleksio | 0:c58229885f95 | 43 | * \retval result of raising 2 to the power n |
mleksio | 0:c58229885f95 | 44 | */ |
mleksio | 0:c58229885f95 | 45 | #define POW2( n ) ( 1 << n ) |
mleksio | 0:c58229885f95 | 46 | |
mleksio | 0:c58229885f95 | 47 | /*! |
mleksio | 0:c58229885f95 | 48 | * \brief Initializes the pseudo ramdom generator initial value |
mleksio | 0:c58229885f95 | 49 | * |
mleksio | 0:c58229885f95 | 50 | * \param [IN] seed Pseudo ramdom generator initial value |
mleksio | 0:c58229885f95 | 51 | */ |
mleksio | 0:c58229885f95 | 52 | void srand1( uint32_t seed ); |
mleksio | 0:c58229885f95 | 53 | |
mleksio | 0:c58229885f95 | 54 | /*! |
mleksio | 0:c58229885f95 | 55 | * \brief Computes a random number between min and max |
mleksio | 0:c58229885f95 | 56 | * |
mleksio | 0:c58229885f95 | 57 | * \param [IN] min range minimum value |
mleksio | 0:c58229885f95 | 58 | * \param [IN] max range maximum value |
mleksio | 0:c58229885f95 | 59 | * \retval random random value in range min..max |
mleksio | 0:c58229885f95 | 60 | */ |
mleksio | 0:c58229885f95 | 61 | int32_t randr( int32_t min, int32_t max ); |
mleksio | 0:c58229885f95 | 62 | |
mleksio | 0:c58229885f95 | 63 | /*! |
mleksio | 0:c58229885f95 | 64 | * \brief Copies size elements of src array to dst array |
mleksio | 0:c58229885f95 | 65 | * |
mleksio | 0:c58229885f95 | 66 | * \remark STM32 Standard memcpy function only works on pointers that are aligned |
mleksio | 0:c58229885f95 | 67 | * |
mleksio | 0:c58229885f95 | 68 | * \param [OUT] dst Destination array |
mleksio | 0:c58229885f95 | 69 | * \param [IN] src Source array |
mleksio | 0:c58229885f95 | 70 | * \param [IN] size Number of bytes to be copied |
mleksio | 0:c58229885f95 | 71 | */ |
mleksio | 0:c58229885f95 | 72 | void memcpy1( uint8_t *dst, const uint8_t *src, uint16_t size ); |
mleksio | 0:c58229885f95 | 73 | |
mleksio | 0:c58229885f95 | 74 | /*! |
mleksio | 1:2be292bd43f9 | 75 | * \brief Copies size elements of src array to dst array reversing the byte order |
mleksio | 1:2be292bd43f9 | 76 | * |
mleksio | 1:2be292bd43f9 | 77 | * \param [OUT] dst Destination array |
mleksio | 1:2be292bd43f9 | 78 | * \param [IN] src Source array |
mleksio | 1:2be292bd43f9 | 79 | * \param [IN] size Number of bytes to be copied |
mleksio | 1:2be292bd43f9 | 80 | */ |
mleksio | 1:2be292bd43f9 | 81 | void memcpyr( uint8_t *dst, const uint8_t *src, uint16_t size ); |
mleksio | 1:2be292bd43f9 | 82 | |
mleksio | 1:2be292bd43f9 | 83 | /*! |
mleksio | 0:c58229885f95 | 84 | * \brief Set size elements of dst array with value |
mleksio | 0:c58229885f95 | 85 | * |
mleksio | 0:c58229885f95 | 86 | * \remark STM32 Standard memset function only works on pointers that are aligned |
mleksio | 0:c58229885f95 | 87 | * |
mleksio | 0:c58229885f95 | 88 | * \param [OUT] dst Destination array |
mleksio | 0:c58229885f95 | 89 | * \param [IN] value Default value |
mleksio | 0:c58229885f95 | 90 | * \param [IN] size Number of bytes to be copied |
mleksio | 0:c58229885f95 | 91 | */ |
mleksio | 0:c58229885f95 | 92 | void memset1( uint8_t *dst, uint8_t value, uint16_t size ); |
mleksio | 0:c58229885f95 | 93 | |
mleksio | 0:c58229885f95 | 94 | /*! |
mleksio | 0:c58229885f95 | 95 | * \brief Converts a nibble to an hexadecimal character |
mleksio | 0:c58229885f95 | 96 | * |
mleksio | 0:c58229885f95 | 97 | * \param [IN] a Nibble to be converted |
mleksio | 0:c58229885f95 | 98 | * \retval hexChar Converted hexadecimal character |
mleksio | 0:c58229885f95 | 99 | */ |
mleksio | 0:c58229885f95 | 100 | int8_t Nibble2HexChar( uint8_t a ); |
mleksio | 0:c58229885f95 | 101 | |
mleksio | 0:c58229885f95 | 102 | #endif // __UTILITIES_H__ |