Example Tx Rx LoRa code for Multitech Conduit. Based on Semtech stack for ELMO - ver. 4.1.0.

Dependencies:   SX1272lib mbed

Committer:
mleksio
Date:
Wed Dec 16 14:25:16 2015 +0000
Revision:
0:c58229885f95
Child:
1:2be292bd43f9
first commit

Who changed what in which revision?

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