Application example using LoRaWAN-lib MAC layer implementation for STM32 + SX1276 on OpenChirp

Dependencies:   mbed LoRaWAN-lib SX1276Lib

Committer:
mluis
Date:
Thu Nov 26 12:59:52 2015 +0000
Revision:
1:352f608c3337
Child:
3:9c6f7f082151
Changed application architecture to mimic GitHub LoRaMac-node repository.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mluis 1:352f608c3337 1 /*
mluis 1:352f608c3337 2 / _____) _ | |
mluis 1:352f608c3337 3 ( (____ _____ ____ _| |_ _____ ____| |__
mluis 1:352f608c3337 4 \____ \| ___ | (_ _) ___ |/ ___) _ \
mluis 1:352f608c3337 5 _____) ) ____| | | || |_| ____( (___| | | |
mluis 1:352f608c3337 6 (______/|_____)_|_|_| \__)_____)\____)_| |_|
mluis 1:352f608c3337 7 (C)2013 Semtech
mluis 1:352f608c3337 8
mluis 1:352f608c3337 9 Description: Helper functions implementation
mluis 1:352f608c3337 10
mluis 1:352f608c3337 11 License: Revised BSD License, see LICENSE.TXT file include in the project
mluis 1:352f608c3337 12
mluis 1:352f608c3337 13 Maintainer: Miguel Luis and Gregory Cristian
mluis 1:352f608c3337 14 */
mluis 1:352f608c3337 15 #ifndef __UTILITIES_H__
mluis 1:352f608c3337 16 #define __UTILITIES_H__
mluis 1:352f608c3337 17
mluis 1:352f608c3337 18 /*!
mluis 1:352f608c3337 19 * \brief Returns the minimum value betwen a and b
mluis 1:352f608c3337 20 *
mluis 1:352f608c3337 21 * \param [IN] a 1st value
mluis 1:352f608c3337 22 * \param [IN] b 2nd value
mluis 1:352f608c3337 23 * \retval minValue Minimum value
mluis 1:352f608c3337 24 */
mluis 1:352f608c3337 25 #define MIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) )
mluis 1:352f608c3337 26
mluis 1:352f608c3337 27 /*!
mluis 1:352f608c3337 28 * \brief Returns the maximum value betwen a and b
mluis 1:352f608c3337 29 *
mluis 1:352f608c3337 30 * \param [IN] a 1st value
mluis 1:352f608c3337 31 * \param [IN] b 2nd value
mluis 1:352f608c3337 32 * \retval maxValue Maximum value
mluis 1:352f608c3337 33 */
mluis 1:352f608c3337 34 #define MAX( a, b ) ( ( ( a ) > ( b ) ) ? ( a ) : ( b ) )
mluis 1:352f608c3337 35
mluis 1:352f608c3337 36 /*!
mluis 1:352f608c3337 37 * \brief Returns 2 raised to the power of n
mluis 1:352f608c3337 38 *
mluis 1:352f608c3337 39 * \param [IN] n power value
mluis 1:352f608c3337 40 * \retval result of raising 2 to the power n
mluis 1:352f608c3337 41 */
mluis 1:352f608c3337 42 #define POW2( n ) ( 1 << n )
mluis 1:352f608c3337 43
mluis 1:352f608c3337 44 /*!
mluis 1:352f608c3337 45 * \brief Initializes the pseudo ramdom generator initial value
mluis 1:352f608c3337 46 *
mluis 1:352f608c3337 47 * \param [IN] seed Pseudo ramdom generator initial value
mluis 1:352f608c3337 48 */
mluis 1:352f608c3337 49 void srand1( uint32_t seed );
mluis 1:352f608c3337 50
mluis 1:352f608c3337 51 /*!
mluis 1:352f608c3337 52 * \brief Computes a random number between min and max
mluis 1:352f608c3337 53 *
mluis 1:352f608c3337 54 * \param [IN] min range minimum value
mluis 1:352f608c3337 55 * \param [IN] max range maximum value
mluis 1:352f608c3337 56 * \retval random random value in range min..max
mluis 1:352f608c3337 57 */
mluis 1:352f608c3337 58 int32_t randr( int32_t min, int32_t max );
mluis 1:352f608c3337 59
mluis 1:352f608c3337 60 /*!
mluis 1:352f608c3337 61 * \brief Copies size elements of src array to dst array
mluis 1:352f608c3337 62 *
mluis 1:352f608c3337 63 * \remark STM32 Standard memcpy function only works on pointers that are aligned
mluis 1:352f608c3337 64 *
mluis 1:352f608c3337 65 * \param [OUT] dst Destination array
mluis 1:352f608c3337 66 * \param [IN] src Source array
mluis 1:352f608c3337 67 * \param [IN] size Number of bytes to be copied
mluis 1:352f608c3337 68 */
mluis 1:352f608c3337 69 void memcpy1( uint8_t *dst, const uint8_t *src, uint16_t size );
mluis 1:352f608c3337 70
mluis 1:352f608c3337 71 /*!
mluis 1:352f608c3337 72 * \brief Set size elements of dst array with value
mluis 1:352f608c3337 73 *
mluis 1:352f608c3337 74 * \remark STM32 Standard memset function only works on pointers that are aligned
mluis 1:352f608c3337 75 *
mluis 1:352f608c3337 76 * \param [OUT] dst Destination array
mluis 1:352f608c3337 77 * \param [IN] value Default value
mluis 1:352f608c3337 78 * \param [IN] size Number of bytes to be copied
mluis 1:352f608c3337 79 */
mluis 1:352f608c3337 80 void memset1( uint8_t *dst, uint8_t value, uint16_t size );
mluis 1:352f608c3337 81
mluis 1:352f608c3337 82 /*!
mluis 1:352f608c3337 83 * \brief Converts a nibble to an hexadecimal character
mluis 1:352f608c3337 84 *
mluis 1:352f608c3337 85 * \param [IN] a Nibble to be converted
mluis 1:352f608c3337 86 * \retval hexChar Converted hexadecimal character
mluis 1:352f608c3337 87 */
mluis 1:352f608c3337 88 int8_t Nibble2HexChar( uint8_t a );
mluis 1:352f608c3337 89
mluis 1:352f608c3337 90 #endif // __UTILITIES_H__