Frank Vannieuwkerke / Mbed 2 deprecated Wi-Go_IOT_Demo_MKII

Dependencies:   NVIC_set_all_priorities mbed cc3000_hostdriver_mbedsocket TEMT6200 TSI Wi-Go_eCompass_Lib_V3 WiGo_BattCharger

Files at this revision

API Documentation at this revision

Comitter:
frankvnk
Date:
Sat Feb 28 20:23:30 2015 +0000
Parent:
6:cbd7f95bbca9
Commit message:
Fixed Webserver lockup by skipping all code in the SysTick_Handler while HTTP data is sent.

Changed in this revision

Webserver/demo.cpp Show annotated file Show diff for this revision Revisions of this file
cc3000_hostdriver_mbedsocket.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/Webserver/demo.cpp	Wed Dec 11 20:29:39 2013 +0000
+++ b/Webserver/demo.cpp	Sat Feb 28 20:23:30 2015 +0000
@@ -95,6 +95,10 @@
 extern unsigned char newData;
 extern unsigned short adc_sample3;
 
+// Variable declared in main and checked in the systick handler
+// Code in the systick handler is only processed when Systick_Allowed = 1
+extern bool Systick_Allowed;
+
 /** \brief Pointer to the index HTML page */
 char * indexPage;
 
@@ -395,7 +399,7 @@
     printf("Main HTTP server\r\n");
 
     // Start Listening
-    if(server.listen() != 0);
+    if(server.listen() != 0);       // !!?? if statement is of no use - replace with server.listen();
 
     // Handle Clients and Data
     while(1)
@@ -409,7 +413,13 @@
             client.set_blocking(true);
             printf("Connection\r\n");
 //            printf("Connection from: %s \r\n", client.get_address());
-            if(newData) handleHTTPRequest(&client);
+            if(newData)
+            {
+                Systick_Allowed = 0;
+// Alternative to Systick_Allowed - more intrusive as it will entirely disable systicks
+//                SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;  // *** Disable SysTick Timer
+                handleHTTPRequest(&client);
+            }
             newData = 0;
             client.close();
             LED_D2_OFF;
@@ -426,8 +436,10 @@
             server.bind(port);
 
             // Start Listening
-            if (server.listen() != 0);
+            if (server.listen() != 0);       // !!?? if statement is of no use - replace with server.listen();
         }
+        Systick_Allowed = 1;
+//        SysTick->CTRL |=  SysTick_CTRL_TICKINT_Msk;  // *** Re-Enable SysTick Timer
     }
 }
 
--- a/cc3000_hostdriver_mbedsocket.lib	Wed Dec 11 20:29:39 2013 +0000
+++ b/cc3000_hostdriver_mbedsocket.lib	Sat Feb 28 20:23:30 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/Kojto/code/cc3000_hostdriver_mbedsocket/#ca8c234997c0
+http://mbed.org/users/Kojto/code/cc3000_hostdriver_mbedsocket/#a63fe1a4f568
--- a/main.cpp	Wed Dec 11 20:29:39 2013 +0000
+++ b/main.cpp	Sat Feb 28 20:23:30 2015 +0000
@@ -62,6 +62,9 @@
 
 // Systick
 Ticker systick;
+// Variable checked in the systick handler
+// Code in the systick handler is only processed when Systick_Allowed = 1
+bool Systick_Allowed = 1;
 
 // Ambient light sensor : PTD5 = enable, PTB0 = analog input
 TEMT6200 ambi(PTD5, PTB0);
@@ -257,40 +260,43 @@
 {
     static unsigned int ttt = 1;
     int ts;
-    ts = ttt & 0x1;
-    if(ts == 0)
-    {
-        accel_read();
-        readCompass();
-    }
-    if(ts == 1)
-    {
-        run_eCompass();
-        newData = 1; // a general purpose flag for things that need to synch to the ISR
-        axis6.timestamp++;
-        if(!server_running) set_dir_LED(); // Set the LEDs based on direction when nothing else is usng them
-    }
-    if(ttt == 50)
+    if(Systick_Allowed)
     {
-        LED_D1_ON;
-        if(seconds && (seconds < 15)) calibrate_eCompass();
-        readTempAlt();
-        axis6.light = ambi.readRaw(); // Light Sensor    
-        HsecondFlag = 1; // A general purpose flag for things that need to happen every 500ms   
+        ts = ttt & 0x1;
+        if(ts == 0)
+        {
+            accel_read();
+            readCompass();
+        }
+        if(ts == 1)
+        {
+            run_eCompass();
+            newData = 1; // a general purpose flag for things that need to synch to the ISR
+            axis6.timestamp++;
+            if(!server_running) set_dir_LED(); // Set the LEDs based on direction when nothing else is usng them
+        }
+        if(ttt == 50)
+        {
+            LED_D1_ON;
+            if(seconds && (seconds < 15)) calibrate_eCompass();
+            readTempAlt();
+            axis6.light = ambi.readRaw(); // Light Sensor    
+            HsecondFlag = 1; // A general purpose flag for things that need to happen every 500ms   
+        }
+        if(ttt >= 100)
+        {
+            LED_D1_OFF;
+            ttt = 1;  
+            calibrate_eCompass();
+            Batt.sense_en(1);
+            adc_sample3 = Batt.level(); 
+            Batt.sense_en(0);
+            secondFlag = 1; // A general purpose flag for things that need to happen once a second
+            HsecondFlag = 1;
+            seconds++;
+            if(!(seconds & 0x1F)) do_mDNS = 1;          
+        } else ttt++;
     }
-    if(ttt >= 100)
-    {
-        LED_D1_OFF;
-        ttt = 1;  
-        calibrate_eCompass();
-        Batt.sense_en(1);
-        adc_sample3 = Batt.level(); 
-        Batt.sense_en(0);
-        secondFlag = 1; // A general purpose flag for things that need to happen once a second
-        HsecondFlag = 1;
-        seconds++;
-        if(!(seconds & 0x1F)) do_mDNS = 1;          
-    } else ttt++;
 }
 /*void SysTick_Handler(void)
 {
--- a/mbed.bld	Wed Dec 11 20:29:39 2013 +0000
+++ b/mbed.bld	Sat Feb 28 20:23:30 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/673126e12c73
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/e188a91d3eaa
\ No newline at end of file