CatPot 2015-2016 / Mbed 2 deprecated CatPotI2CSlavetest

Dependencies:   Ping mbed

Fork of CatPotI2CSlavetest by Fumiya Fujisawa

Files at this revision

API Documentation at this revision

Comitter:
ryuna
Date:
Mon Dec 15 07:37:14 2014 +0000
Child:
1:178963fb9f75
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
--- /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
--- /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;
+        }
+        
+    }
+}
--- /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