Demonstration of Class-A LoRaWAN device using NAMote-72
Dependencies: LoRaWAN-lib mbed lib_mpl3115a2 lib_mma8451q lib_gps SX1272Lib
Dependents: LoRaWAN-NAMote72-BVS-confirmed-tester-0-7v1_copy
utilities.cpp
00001 /* 00002 / _____) _ | | 00003 ( (____ _____ ____ _| |_ _____ ____| |__ 00004 \____ \| ___ | (_ _) ___ |/ ___) _ \ 00005 _____) ) ____| | | || |_| ____( (___| | | | 00006 (______/|_____)_|_|_| \__)_____)\____)_| |_| 00007 (C)2013 Semtech 00008 00009 Description: Helper functions implementation 00010 00011 License: Revised BSD License, see LICENSE.TXT file include in the project 00012 00013 Maintainer: Miguel Luis and Gregory Cristian 00014 */ 00015 #include <stdlib.h> 00016 #include <stdio.h> 00017 #include "board.h" 00018 #include "utilities.h" 00019 00020 /*! 00021 * Redefinition of rand() and srand() standard C functions. 00022 * These functions are redefined in order to get the same behavior across 00023 * different compiler toolchains implementations. 00024 */ 00025 // Standard random functions redefinition start 00026 #define RAND_LOCAL_MAX 2147483647L 00027 00028 static uint32_t next = 1; 00029 00030 int32_t rand1( void ) 00031 { 00032 return ( ( next = next * 1103515245L + 12345L ) % RAND_LOCAL_MAX ); 00033 } 00034 00035 void srand1( uint32_t seed ) 00036 { 00037 next = seed; 00038 } 00039 // Standard random functions redefinition end 00040 00041 int32_t randr( int32_t min, int32_t max ) 00042 { 00043 return ( int32_t )rand1( ) % ( max - min + 1 ) + min; 00044 } 00045 00046 void memcpy1( uint8_t *dst, const uint8_t *src, uint16_t size ) 00047 { 00048 while( size-- ) 00049 { 00050 *dst++ = *src++; 00051 } 00052 } 00053 00054 void memcpyr( uint8_t *dst, const uint8_t *src, uint16_t size ) 00055 { 00056 dst = dst + ( size - 1 ); 00057 while( size-- ) 00058 { 00059 *dst-- = *src++; 00060 } 00061 } 00062 00063 void memset1( uint8_t *dst, uint8_t value, uint16_t size ) 00064 { 00065 while( size-- ) 00066 { 00067 *dst++ = value; 00068 } 00069 } 00070 00071 int8_t Nibble2HexChar( uint8_t a ) 00072 { 00073 if( a < 10 ) 00074 { 00075 return '0' + a; 00076 } 00077 else if( a < 16 ) 00078 { 00079 return 'A' + ( a - 10 ); 00080 } 00081 else 00082 { 00083 return '?'; 00084 } 00085 }
Generated on Fri Jul 15 2022 22:53:36 by 1.7.2