Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed LoRaWAN-lib SX1276Lib
Dependents: simple-demo-76_revised_20171113 simple-demo-76_revised_20171208
Fork of LoRaWAN-demo-76 by
Diff: system/utilities.cpp
- Revision:
- 1:352f608c3337
- Child:
- 3:9c6f7f082151
diff -r 92bca02df485 -r 352f608c3337 system/utilities.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/system/utilities.cpp Thu Nov 26 12:59:52 2015 +0000
@@ -0,0 +1,76 @@
+/*
+ / _____) _ | |
+( (____ _____ ____ _| |_ _____ ____| |__
+ \____ \| ___ | (_ _) ___ |/ ___) _ \
+ _____) ) ____| | | || |_| ____( (___| | | |
+(______/|_____)_|_|_| \__)_____)\____)_| |_|
+ (C)2013 Semtech
+
+Description: Helper functions implementation
+
+License: Revised BSD License, see LICENSE.TXT file include in the project
+
+Maintainer: Miguel Luis and Gregory Cristian
+*/
+#include <stdlib.h>
+#include <stdio.h>
+#include "board.h"
+#include "utilities.h"
+
+/*!
+ * Redefinition of rand() and srand() standard C functions.
+ * These functions are redefined in order to get the same behavior across
+ * different compiler toolchains implementations.
+ */
+// Standard random functions redefinition start
+#define RAND_LOCAL_MAX 2147483647L
+
+static uint32_t next = 1;
+
+int32_t rand1( void )
+{
+ return ( ( next = next * 1103515245L + 12345L ) % RAND_LOCAL_MAX );
+}
+
+void srand1( uint32_t seed )
+{
+ next = seed;
+}
+// Standard random functions redefinition end
+
+int32_t randr( int32_t min, int32_t max )
+{
+ return ( int32_t )rand1( ) % ( max - min + 1 ) + min;
+}
+
+void memcpy1( uint8_t *dst, const uint8_t *src, uint16_t size )
+{
+ while( size-- )
+ {
+ *dst++ = *src++;
+ }
+}
+
+void memset1( uint8_t *dst, uint8_t value, uint16_t size )
+{
+ while( size-- )
+ {
+ *dst++ = value;
+ }
+}
+
+int8_t Nibble2HexChar( uint8_t a )
+{
+ if( a < 10 )
+ {
+ return '0' + a;
+ }
+ else if( a < 16 )
+ {
+ return 'A' + ( a - 10 );
+ }
+ else
+ {
+ return '?';
+ }
+}
