lora experiments

Dependencies:   BLE_API LoRaWAN-lib SX1276Lib mbed nRF51822 HCSR04Lib

Fork of LoRa by Olav Nymoen

Committer:
haaspors
Date:
Thu Jun 09 14:42:23 2016 +0000
Revision:
4:63d6744a61b6
Parent:
0:4c1fcbfcc7bf
Add 'device joined lora network' gatt char.

Who changed what in which revision?

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