pyl_v8

Dependencies:   mbed-rtos mbed stingr

Files at this revision

API Documentation at this revision

Comitter:
jmoreno10
Date:
Mon Oct 29 12:44:05 2018 +0000
Commit message:
pyl_v8

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib 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
stingr.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 5c85e75df952 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Oct 29 12:44:05 2018 +0000
@@ -0,0 +1,43 @@
+#include "mbed.h"                   
+#include "rtos.h"
+#include "Stingr.h"
+
+Serial stingrUART(p13, p14, 9600);  // tx, rx Comunicación Serial con el STINGR
+Serial pc(USBTX, USBRX, 9600);      // tx, rx Comunicación Serial con la PC
+I2CSlave slave(p9, p10);            // sda, scl
+
+const int BUF_LEN = 200;
+const int I2C_ADDR = 0x1E;
+const int I2C_FREQ = 400000;
+
+Stingr stingr;
+
+int main() 
+{     
+// I2C variables
+    slave.frequency(I2C_FREQ);      // 400 MHz interface
+    slave.address(I2C_ADDR);        // slave address
+    
+// local vars
+    char buf[BUF_LEN];              // read array from master
+        
+// I2C communication
+    while(1) 
+    {
+        int state = slave.receive();
+        switch(state)
+        {
+// Master reads from slave
+            case I2CSlave::ReadAddressed:              
+                slave.write(stingr.get_resp(), strlen(stingr.get_resp()) + 1);      
+                printf("Writing to Master:\t<<- %s\n", stingr.get_resp()); 
+                break;
+// Master writes to slave
+            case I2CSlave::WriteAddressed:
+                slave.read(buf, 200);                   // Read up to 200 characters from Master
+                printf("\n\nReading from Master:\t->> %s\n", buf);
+                stingr.command(buf);
+                break;
+        }
+    }     
+} 
diff -r 000000000000 -r 5c85e75df952 mbed-rtos.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Mon Oct 29 12:44:05 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed-rtos/#5713cbbdb706
diff -r 000000000000 -r 5c85e75df952 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Oct 29 12:44:05 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/e95d10626187
\ No newline at end of file
diff -r 000000000000 -r 5c85e75df952 stingr.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/stingr.lib	Mon Oct 29 12:44:05 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/jmoreno10/code/stingr/#f10ccc94eb8a