FlashAir Developers Summit OSAKA 2019 handson step2

Dependencies:   mbed ADT7410 FlashAir_iSDIO SDFileSystem USBDevice

Files at this revision

API Documentation at this revision

Comitter:
hogejun
Date:
Tue Jan 15 06:41:31 2019 +0000
Parent:
3:e36e31ebb464
Child:
5:7ade87f735a2
Commit message:
add ADT7410

Changed in this revision

ADT7410.lib Show annotated file Show diff for this revision Revisions of this file
USBDevice.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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ADT7410.lib	Tue Jan 15 06:41:31 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/tkreyche/code/ADT7410/#e1aee50340ec
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Tue Jan 15 06:41:31 2019 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/USBDevice/#01321bd6ff89
--- a/main.cpp	Fri Jan 11 07:51:34 2019 +0000
+++ b/main.cpp	Tue Jan 15 06:41:31 2019 +0000
@@ -1,5 +1,9 @@
 #include "mbed.h"
 #include "FlashAir_iSDIO.h"
+#include "USBSerial.h"
+#include "ADT7410.h"
+
+#define USE_ADT7410
 //-------------------------------------------------------------------------------
 //Port Settings
 DigitalOut led1(LED1);
@@ -29,6 +33,15 @@
 Serial console(P0_19, P0_18); // TX, RX
 FlashAir_iSDIO sd(P0_21, P0_22, P1_15, P0_17, "sd", &console); // mosi(CMD), miso(DAT0), sclk(CLK), cs(DAT3)
 
+USBSerial serial;
+#ifdef USE_ADT7410
+ADT7410 sensor(P0_5, P0_4, 0x90, 100000);
+#else
+int dummyval[] = {0,1,2,3,4,5,6,7,8,9};
+#define DUMMYVALLEN (sizeof(dummyval)/sizeof(dummyval[0]))
+#endif
+int senseval;
+
 //-------------------------------------------------------------------------------
 //Program
 
@@ -62,8 +75,8 @@
 }
 
 void isp_int(){
-    #define TESTDATA 0xdeadbeaf
-    uint32_t testdata = TESTDATA;
+    #define TESTDATA "deadbeaf"
+    char testdata[] = TESTDATA;
     uint8_t data[sizeof(testdata)];
     memcpy(data, &testdata, sizeof(data));
     sd.write_shared_mem(0x0, data, sizeof(data));
@@ -101,27 +114,39 @@
 
 int main()
 {
+     console.printf("Hello FlashAIr_iSDIO_16seg_ADT7410\n");
      SD_VEN = 1;
     // Initialize card
     FILE *fp = fopen("/sd/isdio.txt", "w");
     fclose(fp);
     
+#ifdef USE_ADT7410
+    sensor.reset();
+#endif
+
+    // disconnect anyway    
     sequenceId = sd.getNextSequenceId();
     sd.wlan_disconnect(sequenceId);
     sd.waitResponse(sequenceId);
     
+    // register interrupt handler
     sw.rise(&sw_int);
     isp.rise(&isp_int);
     
     int i=0;
     while(1)
     {
-        seg_disp(i);
+#ifdef USE_ADT7410
+        senseval = (int)sensor.getTemp();
+#else
+        senseval = dummyval[i];
+#endif        
+        seg_disp(senseval);
+        serial.printf("%d\n",senseval);
         i++;
-        wait(0.3);
-    
-        
-
-        
+#ifndef USE_ADT7410
+        if(i>=DUMMYVALLEN) i=0;
+#endif
+        wait(0.3);        
     }
 }