1

Dependencies:   X_NUCLEO_IKS01A1 LoRaWAN-lib SX1276Lib mbed

Revision:
0:42863a11464a
Child:
1:80c1daf19aa4
diff -r 000000000000 -r 42863a11464a board/board.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/board/board.cpp	Fri Aug 26 19:36:35 2016 +0000
@@ -0,0 +1,69 @@
+/*
+ / _____)             _              | |
+( (____  _____ ____ _| |_ _____  ____| |__
+ \____ \| ___ |    (_   _) ___ |/ ___)  _ \
+ _____) ) ____| | | || |_| ____( (___| | | |
+(______/|_____)_|_|_| \__)_____)\____)_| |_|
+    (C)2015 Semtech
+
+Description: Target board general functions implementation
+
+License: Revised BSD License, see LICENSE.TXT file include in the project
+
+Maintainer: Miguel Luis and Gregory Cristian
+*/
+#include "mbed.h"
+#include "board.h"
+
+MoteVersion_t BoardGetVersion( void );
+
+DigitalIn I2cInterrupt( PB_4 );
+I2C I2c(I2C_SDA, I2C_SCL);
+
+DigitalOut Pc7( PC_7 );
+DigitalIn Pc1( PC_1 );
+
+#define AIN_VREF            3.3     // STM32 internal refernce
+#define AIN_VBAT_DIV        2       // Resistor divider
+
+SX1276MB1xAS Radio( NULL );
+
+void BoardInit( void )
+{
+    TimerTimeCounterInit( );
+}
+
+
+uint8_t BoardGetBatteryLevel( void ) 
+{
+    return 0xFE;
+}
+
+uint32_t BoardGetRandomSeed( void )
+{
+    return ( ( *( uint32_t* )ID1 ) ^ ( *( uint32_t* )ID2 ) ^ ( *( uint32_t* )ID3 ) );
+}
+
+void BoardGetDevEUI( uint8_t *id )
+{
+    uint32_t *pDevEuiHWord = ( uint32_t* )&id[4];
+
+    if( *pDevEuiHWord == 0 )
+    {        
+        *pDevEuiHWord = BoardGetRandomSeed( );
+    }
+    
+}
+
+void BoardGetUniqueId( uint8_t *id )
+{
+    id[7] = ( ( *( uint32_t* )ID1 )+ ( *( uint32_t* )ID3 ) ) >> 24;
+    id[6] = ( ( *( uint32_t* )ID1 )+ ( *( uint32_t* )ID3 ) ) >> 16;
+    id[5] = ( ( *( uint32_t* )ID1 )+ ( *( uint32_t* )ID3 ) ) >> 8;
+    id[4] = ( ( *( uint32_t* )ID1 )+ ( *( uint32_t* )ID3 ) );
+    id[3] = ( ( *( uint32_t* )ID2 ) ) >> 24;
+    id[2] = ( ( *( uint32_t* )ID2 ) ) >> 16;
+    id[1] = ( ( *( uint32_t* )ID2 ) ) >> 8;
+    id[0] = ( ( *( uint32_t* )ID2 ) );
+}
+