for India band 30dBm LoRa Module, DSPLoRa based on code from Semtech and as modified by Sachin Pukale/ TCL/

Dependencies:   mbed Chainable_RGB_LED DigitDisplay LoRaWAN-lib SX1276Lib

Fork of DSP_LoRaWAN by Akshay Mishra

Committer:
akshaymishra
Date:
Thu Jan 05 03:47:15 2017 +0000
Revision:
7:5c0e1dfdf0c6
Parent:
0:cb80564f40e1
Address update

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mluis 0:cb80564f40e1 1 /*
mluis 0:cb80564f40e1 2 / _____) _ | |
mluis 0:cb80564f40e1 3 ( (____ _____ ____ _| |_ _____ ____| |__
mluis 0:cb80564f40e1 4 \____ \| ___ | (_ _) ___ |/ ___) _ \
mluis 0:cb80564f40e1 5 _____) ) ____| | | || |_| ____( (___| | | |
mluis 0:cb80564f40e1 6 (______/|_____)_|_|_| \__)_____)\____)_| |_|
mluis 0:cb80564f40e1 7 (C)2013 Semtech
mluis 0:cb80564f40e1 8
mluis 0:cb80564f40e1 9 Description: Helper functions implementation
mluis 0:cb80564f40e1 10
mluis 0:cb80564f40e1 11 License: Revised BSD License, see LICENSE.TXT file include in the project
mluis 0:cb80564f40e1 12
mluis 0:cb80564f40e1 13 Maintainer: Miguel Luis and Gregory Cristian
mluis 0:cb80564f40e1 14 */
mluis 0:cb80564f40e1 15 #include <stdlib.h>
mluis 0:cb80564f40e1 16 #include <stdio.h>
mluis 0:cb80564f40e1 17 #include "board.h"
mluis 0:cb80564f40e1 18 #include "utilities.h"
mluis 0:cb80564f40e1 19
mluis 0:cb80564f40e1 20 /*!
mluis 0:cb80564f40e1 21 * Redefinition of rand() and srand() standard C functions.
mluis 0:cb80564f40e1 22 * These functions are redefined in order to get the same behavior across
mluis 0:cb80564f40e1 23 * different compiler toolchains implementations.
mluis 0:cb80564f40e1 24 */
mluis 0:cb80564f40e1 25 // Standard random functions redefinition start
mluis 0:cb80564f40e1 26 #define RAND_LOCAL_MAX 2147483647L
mluis 0:cb80564f40e1 27
mluis 0:cb80564f40e1 28 static uint32_t next = 1;
mluis 0:cb80564f40e1 29
mluis 0:cb80564f40e1 30 int32_t rand1( void )
mluis 0:cb80564f40e1 31 {
mluis 0:cb80564f40e1 32 return ( ( next = next * 1103515245L + 12345L ) % RAND_LOCAL_MAX );
mluis 0:cb80564f40e1 33 }
mluis 0:cb80564f40e1 34
mluis 0:cb80564f40e1 35 void srand1( uint32_t seed )
mluis 0:cb80564f40e1 36 {
mluis 0:cb80564f40e1 37 next = seed;
mluis 0:cb80564f40e1 38 }
mluis 0:cb80564f40e1 39 // Standard random functions redefinition end
mluis 0:cb80564f40e1 40
mluis 0:cb80564f40e1 41 int32_t randr( int32_t min, int32_t max )
mluis 0:cb80564f40e1 42 {
mluis 0:cb80564f40e1 43 return ( int32_t )rand1( ) % ( max - min + 1 ) + min;
mluis 0:cb80564f40e1 44 }
mluis 0:cb80564f40e1 45
mluis 0:cb80564f40e1 46 void memcpy1( uint8_t *dst, const uint8_t *src, uint16_t size )
mluis 0:cb80564f40e1 47 {
mluis 0:cb80564f40e1 48 while( size-- )
mluis 0:cb80564f40e1 49 {
mluis 0:cb80564f40e1 50 *dst++ = *src++;
mluis 0:cb80564f40e1 51 }
mluis 0:cb80564f40e1 52 }
mluis 0:cb80564f40e1 53
mluis 0:cb80564f40e1 54 void memcpyr( uint8_t *dst, const uint8_t *src, uint16_t size )
mluis 0:cb80564f40e1 55 {
mluis 0:cb80564f40e1 56 dst = dst + ( size - 1 );
mluis 0:cb80564f40e1 57 while( size-- )
mluis 0:cb80564f40e1 58 {
mluis 0:cb80564f40e1 59 *dst-- = *src++;
mluis 0:cb80564f40e1 60 }
mluis 0:cb80564f40e1 61 }
mluis 0:cb80564f40e1 62
mluis 0:cb80564f40e1 63 void memset1( uint8_t *dst, uint8_t value, uint16_t size )
mluis 0:cb80564f40e1 64 {
mluis 0:cb80564f40e1 65 while( size-- )
mluis 0:cb80564f40e1 66 {
mluis 0:cb80564f40e1 67 *dst++ = value;
mluis 0:cb80564f40e1 68 }
mluis 0:cb80564f40e1 69 }
mluis 0:cb80564f40e1 70
mluis 0:cb80564f40e1 71 int8_t Nibble2HexChar( uint8_t a )
mluis 0:cb80564f40e1 72 {
mluis 0:cb80564f40e1 73 if( a < 10 )
mluis 0:cb80564f40e1 74 {
mluis 0:cb80564f40e1 75 return '0' + a;
mluis 0:cb80564f40e1 76 }
mluis 0:cb80564f40e1 77 else if( a < 16 )
mluis 0:cb80564f40e1 78 {
mluis 0:cb80564f40e1 79 return 'A' + ( a - 10 );
mluis 0:cb80564f40e1 80 }
mluis 0:cb80564f40e1 81 else
mluis 0:cb80564f40e1 82 {
mluis 0:cb80564f40e1 83 return '?';
mluis 0:cb80564f40e1 84 }
mluis 0:cb80564f40e1 85 }