SlaveTest

Dependencies:   Ping mbed

Files at this revision

API Documentation at this revision

Comitter:
ryuna
Date:
Mon Dec 15 07:37:14 2014 +0000
Commit message:
ver.1

Changed in this revision

Ping.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
diff -r 000000000000 -r dcc9cf1071f1 Ping.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Ping.lib	Mon Dec 15 07:37:14 2014 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/ryuna/code/Ping/#6be59631152a
diff -r 000000000000 -r dcc9cf1071f1 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Dec 15 07:37:14 2014 +0000
@@ -0,0 +1,48 @@
+#include "mbed.h"
+#include "Ping.h"
+
+#define SYSAHBCLKDIV_Val      0x00000001        // Reset: 0x001
+#define CLOCK_SETUP           1                  // デフォルト=1
+#define SYSPLLCTRL_Val        0x00000023        // デフォルト=23 Reset: 0x000
+#define SYSPLLCLKSEL_Val      0x00000001        // デフォルト=0  Reset: 0x000
+#define MAINCLKSEL_Val        0x00000003        // デフォルト=3  Reset: 0x000
+
+
+#define ADDRESS 0xA0
+#define DATA_NUM 5
+
+DigitalOut myled(LED1);
+I2CSlave Tiny(dp5, dp27);
+Ping Sensor(dp1,dp2);
+Serial pc(USBTX, USBRX);
+
+int main() {
+    
+    char Export[DATA_NUM]={0};
+    uint8_t cycle=0;
+    
+    Tiny.address(ADDRESS);
+    //Tiny.frequency(9600);
+    
+    while(1) {
+        
+        
+        Sensor.Send();
+        wait_ms(30);
+        Export[cycle%DATA_NUM] = 0xAA;//Sensor.Read_cm();
+        
+        cycle++;
+        
+        switch(Tiny.receive()){
+            
+            case I2CSlave::ReadAddressed:
+                 Tiny.write(Export, DATA_NUM); // Includes null char
+                 break;
+            case I2CSlave::WriteGeneral:
+                 break;
+            case I2CSlave::WriteAddressed:
+                 break;
+        }
+        
+    }
+}
diff -r 000000000000 -r dcc9cf1071f1 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Dec 15 07:37:14 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5
\ No newline at end of file