investigating UART crash

Dependencies:   mbed LoRaWAN-lib_publishing_testing_UART_bug SingleFrequencyLora

Fork of simple-demo-76_revised_20171113 by Christopher De Bank

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 #include <stdlib.h>
mluis 1:352f608c3337 16 #include <stdio.h>
mluis 1:352f608c3337 17 #include "board.h"
mluis 1:352f608c3337 18 #include "utilities.h"
mluis 1:352f608c3337 19
mluis 1:352f608c3337 20 /*!
mluis 1:352f608c3337 21 * Redefinition of rand() and srand() standard C functions.
mluis 1:352f608c3337 22 * These functions are redefined in order to get the same behavior across
mluis 1:352f608c3337 23 * different compiler toolchains implementations.
mluis 1:352f608c3337 24 */
mluis 1:352f608c3337 25 // Standard random functions redefinition start
mluis 1:352f608c3337 26 #define RAND_LOCAL_MAX 2147483647L
mluis 1:352f608c3337 27
mluis 1:352f608c3337 28 static uint32_t next = 1;
mluis 1:352f608c3337 29
mluis 1:352f608c3337 30 int32_t rand1( void )
mluis 1:352f608c3337 31 {
mluis 1:352f608c3337 32 return ( ( next = next * 1103515245L + 12345L ) % RAND_LOCAL_MAX );
mluis 1:352f608c3337 33 }
mluis 1:352f608c3337 34
mluis 1:352f608c3337 35 void srand1( uint32_t seed )
mluis 1:352f608c3337 36 {
mluis 1:352f608c3337 37 next = seed;
mluis 1:352f608c3337 38 }
mluis 1:352f608c3337 39 // Standard random functions redefinition end
mluis 1:352f608c3337 40
mluis 1:352f608c3337 41 int32_t randr( int32_t min, int32_t max )
mluis 1:352f608c3337 42 {
mluis 1:352f608c3337 43 return ( int32_t )rand1( ) % ( max - min + 1 ) + min;
mluis 1:352f608c3337 44 }
mluis 1:352f608c3337 45
mluis 1:352f608c3337 46 void memcpy1( uint8_t *dst, const uint8_t *src, uint16_t size )
mluis 1:352f608c3337 47 {
mluis 1:352f608c3337 48 while( size-- )
mluis 1:352f608c3337 49 {
mluis 1:352f608c3337 50 *dst++ = *src++;
mluis 1:352f608c3337 51 }
mluis 1:352f608c3337 52 }
mluis 1:352f608c3337 53
mluis 1:352f608c3337 54 void memset1( uint8_t *dst, uint8_t value, uint16_t size )
mluis 1:352f608c3337 55 {
mluis 1:352f608c3337 56 while( size-- )
mluis 1:352f608c3337 57 {
mluis 1:352f608c3337 58 *dst++ = value;
mluis 1:352f608c3337 59 }
mluis 1:352f608c3337 60 }
mluis 1:352f608c3337 61
mluis 1:352f608c3337 62 int8_t Nibble2HexChar( uint8_t a )
mluis 1:352f608c3337 63 {
mluis 1:352f608c3337 64 if( a < 10 )
mluis 1:352f608c3337 65 {
mluis 1:352f608c3337 66 return '0' + a;
mluis 1:352f608c3337 67 }
mluis 1:352f608c3337 68 else if( a < 16 )
mluis 1:352f608c3337 69 {
mluis 1:352f608c3337 70 return 'A' + ( a - 10 );
mluis 1:352f608c3337 71 }
mluis 1:352f608c3337 72 else
mluis 1:352f608c3337 73 {
mluis 1:352f608c3337 74 return '?';
mluis 1:352f608c3337 75 }
mluis 1:352f608c3337 76 }