NAMote72 Utility Application – Serial Terminal Monitor control for NAMote72 (note: this application replaces the previous na_mote1 test code application)

Dependencies:   SX127x lib_gps lib_mma8451q lib_mpl3115a2 lib_sx9500 mbed

Fork of na_mote1 by wayne roberts

See wiki Page for a detailed

This is a link to the wiki page

Revision:
12:6afe8fed5385
Parent:
11:0f62a500aedc
Child:
13:a22debeee855
--- a/main.cpp	Tue Jun 30 00:35:40 2015 +0000
+++ b/main.cpp	Thu Jul 02 00:14:33 2015 +0000
@@ -43,7 +43,16 @@
 /*  gps(tx, rx, en); */
 GPS gps(PB_6, PB_7, PB_11);
 DigitalOut pd2(PD_2);
-DigitalOut hdr_fem_ctx(PC_7);
+
+typedef enum {
+    MOTE_NONE = 0,
+    MOTE_V2,
+    MOTE_V3
+} mote_version_e;
+
+mote_version_e mote_version = MOTE_NONE;   
+DigitalOut pc_7(PC_7);
+DigitalIn pc_1(PC_1);
 DigitalOut hdr_fem_csd(PC_0);
 
 DigitalOut red_led(PB_1);
@@ -983,7 +992,11 @@
         printf("per_tx_delay:%f\r\n", per_tx_delay);
         printf("PER device ID:%d\r\n", per_id);
     }
-    printf("GPS enabled:%d\r\n", gps.enabled());
+    printf("GPS enabled:%d ", gps.enabled());
+    if (mote_version == MOTE_V2)
+        printf("MOTE_V2\r\n");
+    else if (mote_version == MOTE_V3)
+        printf("MOTE_V3\r\n");
 }
 
 void per_cb()
@@ -1071,10 +1084,10 @@
     radio.set_opmode(RF_OPMODE_STANDBY);              
     radio.set_opmode(RF_OPMODE_TRANSMITTER);
     
-    if (hdr_fem_ctx.read())
-        hdr_fem_ctx = 0;
+    if (pc_7.read())
+        pc_7 = 0;
     else
-        hdr_fem_ctx = 1;
+        pc_7 = 1;
 }
 
 void print_rx_buf(int len)
@@ -2353,6 +2366,26 @@
         
 }
 
+void get_mote_version()
+{
+    char first;
+    
+    /*DigitalOut pc_7(PC_7);
+      DigitalIn pc_1(PC_1);*/
+      
+    pc_7 = 1;
+    first = pc_1;
+    pc_7 = 0;
+    if (first && !pc_1) {
+        //printf("v2-mote\r\n");
+        mote_version = MOTE_V2;
+    } else {
+        //printf("v3-mote\r\n");
+        mote_version = MOTE_V3;
+    }
+    
+}
+
 int main()
 {  
     set_time(0);    // start RTC
@@ -2369,7 +2402,13 @@
     
     if (radio.RegOpMode.bits.LongRangeMode)
         last_RxCurrentAddr = radio.read_reg(REG_LR_FIFORXCURRENTADDR);
-    
+        
+    get_mote_version();
+    if (mote_version == MOTE_V3)
+        gps.en_invert = false;
+    else
+        gps.en_invert = true;
+        
     gps.enable(false);
     
     sx9500.RegProxCtrl0.bits.sensor_en = 3; // only CS0 and CS1 connected
@@ -2390,7 +2429,7 @@
     GPIOC->MODER |= 0x00000041;    // unused pins as outputs: PC0(HDR_FEM_CSD), PC3(SPI3_enable)
     printf("GPIOC->MODER:%08x\r\n", GPIOC->MODER);
 
-    
+ 
 
     while(1) {
         switch (app) {