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@0:c58229885f95, 2015-12-16 (annotated)
- Committer:
- mleksio
- Date:
- Wed Dec 16 14:25:16 2015 +0000
- Revision:
- 0:c58229885f95
- Child:
- 1:2be292bd43f9
first commit
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 | 0:c58229885f95 | 15 | /*! |
mleksio | 0:c58229885f95 | 16 | * \brief Returns the minimum value betwen a and b |
mleksio | 0:c58229885f95 | 17 | * |
mleksio | 0:c58229885f95 | 18 | * \param [IN] a 1st value |
mleksio | 0:c58229885f95 | 19 | * \param [IN] b 2nd value |
mleksio | 0:c58229885f95 | 20 | * \retval minValue Minimum value |
mleksio | 0:c58229885f95 | 21 | */ |
mleksio | 0:c58229885f95 | 22 | #define MIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) ) |
mleksio | 0:c58229885f95 | 23 | |
mleksio | 0:c58229885f95 | 24 | /*! |
mleksio | 0:c58229885f95 | 25 | * \brief Returns the maximum value betwen a and b |
mleksio | 0:c58229885f95 | 26 | * |
mleksio | 0:c58229885f95 | 27 | * \param [IN] a 1st value |
mleksio | 0:c58229885f95 | 28 | * \param [IN] b 2nd value |
mleksio | 0:c58229885f95 | 29 | * \retval maxValue Maximum value |
mleksio | 0:c58229885f95 | 30 | */ |
mleksio | 0:c58229885f95 | 31 | #define MAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) ) |
mleksio | 0:c58229885f95 | 32 | |
mleksio | 0:c58229885f95 | 33 | /*! |
mleksio | 0:c58229885f95 | 34 | * \brief Returns 2 raised to the power of n |
mleksio | 0:c58229885f95 | 35 | * |
mleksio | 0:c58229885f95 | 36 | * \param [IN] n power value |
mleksio | 0:c58229885f95 | 37 | * \retval result of raising 2 to the power n |
mleksio | 0:c58229885f95 | 38 | */ |
mleksio | 0:c58229885f95 | 39 | #define POW2( n ) ( 1 << n ) |
mleksio | 0:c58229885f95 | 40 | |
mleksio | 0:c58229885f95 | 41 | /*! |
mleksio | 0:c58229885f95 | 42 | * \brief Initializes the pseudo ramdom generator initial value |
mleksio | 0:c58229885f95 | 43 | * |
mleksio | 0:c58229885f95 | 44 | * \param [IN] seed Pseudo ramdom generator initial value |
mleksio | 0:c58229885f95 | 45 | */ |
mleksio | 0:c58229885f95 | 46 | void srand1( uint32_t seed ); |
mleksio | 0:c58229885f95 | 47 | |
mleksio | 0:c58229885f95 | 48 | /*! |
mleksio | 0:c58229885f95 | 49 | * \brief Computes a random number between min and max |
mleksio | 0:c58229885f95 | 50 | * |
mleksio | 0:c58229885f95 | 51 | * \param [IN] min range minimum value |
mleksio | 0:c58229885f95 | 52 | * \param [IN] max range maximum value |
mleksio | 0:c58229885f95 | 53 | * \retval random random value in range min..max |
mleksio | 0:c58229885f95 | 54 | */ |
mleksio | 0:c58229885f95 | 55 | int32_t randr( int32_t min, int32_t max ); |
mleksio | 0:c58229885f95 | 56 | |
mleksio | 0:c58229885f95 | 57 | /*! |
mleksio | 0:c58229885f95 | 58 | * \brief Copies size elements of src array to dst array |
mleksio | 0:c58229885f95 | 59 | * |
mleksio | 0:c58229885f95 | 60 | * \remark STM32 Standard memcpy function only works on pointers that are aligned |
mleksio | 0:c58229885f95 | 61 | * |
mleksio | 0:c58229885f95 | 62 | * \param [OUT] dst Destination array |
mleksio | 0:c58229885f95 | 63 | * \param [IN] src Source array |
mleksio | 0:c58229885f95 | 64 | * \param [IN] size Number of bytes to be copied |
mleksio | 0:c58229885f95 | 65 | */ |
mleksio | 0:c58229885f95 | 66 | void memcpy1( uint8_t *dst, const uint8_t *src, uint16_t size ); |
mleksio | 0:c58229885f95 | 67 | |
mleksio | 0:c58229885f95 | 68 | /*! |
mleksio | 0:c58229885f95 | 69 | * \brief Set size elements of dst array with value |
mleksio | 0:c58229885f95 | 70 | * |
mleksio | 0:c58229885f95 | 71 | * \remark STM32 Standard memset function only works on pointers that are aligned |
mleksio | 0:c58229885f95 | 72 | * |
mleksio | 0:c58229885f95 | 73 | * \param [OUT] dst Destination array |
mleksio | 0:c58229885f95 | 74 | * \param [IN] value Default value |
mleksio | 0:c58229885f95 | 75 | * \param [IN] size Number of bytes to be copied |
mleksio | 0:c58229885f95 | 76 | */ |
mleksio | 0:c58229885f95 | 77 | void memset1( uint8_t *dst, uint8_t value, uint16_t size ); |
mleksio | 0:c58229885f95 | 78 | |
mleksio | 0:c58229885f95 | 79 | /*! |
mleksio | 0:c58229885f95 | 80 | * \brief Converts a nibble to an hexadecimal character |
mleksio | 0:c58229885f95 | 81 | * |
mleksio | 0:c58229885f95 | 82 | * \param [IN] a Nibble to be converted |
mleksio | 0:c58229885f95 | 83 | * \retval hexChar Converted hexadecimal character |
mleksio | 0:c58229885f95 | 84 | */ |
mleksio | 0:c58229885f95 | 85 | int8_t Nibble2HexChar( uint8_t a ); |
mleksio | 0:c58229885f95 | 86 | |
mleksio | 0:c58229885f95 | 87 | #endif // __UTILITIES_H__ |