Equipo7 LabMicros / Mbed 2 deprecated I2C_2A

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
micros22eq7
Date:
Tue Apr 26 12:00:36 2022 +0000
Parent:
1:ac7a077c0039
Commit message:
v5

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Apr 25 18:36:36 2022 +0000
+++ b/main.cpp	Tue Apr 26 12:00:36 2022 +0000
@@ -2,41 +2,42 @@
 
 #include "mbed.h"
 
-#define BUFFER_SIZE 8
+#define BUFFER_SIZE 30
 #define SLAVE_ADDR 0xA0
 
 Serial pc(USBTX, USBRX); 
 I2C master(I2C_SDA, I2C_SCL);
 
-static const char* to_send[] = { "abcde", "12345", "EFGHI" };
+static const char* to_send[] = { "me gusta", " el pan ", "de dulce" };
+
 int main() 
 {
-    pc.printf("\x1b[2J");      //CLEAR
-    pc.printf("\r");           //Mueve cursor al origen
-    pc.printf("I'M MASTER\r\n");
+    pc.printf("\x1b[2J");       //CLEAR
+    pc.printf("\033[1;1H");     //Mueve cursor al origen
+            
+    pc.printf("MASTER\r\n");
     
     master.frequency (100000);
     char buf[BUFFER_SIZE];
     int send_index = 0;
     while (1) 
     {
+        wait(0.5);
         strcpy(buf, to_send[send_index]);
         
-        // Write the new message to the slave
-        if (master.write(SLAVE_ADDR, buf, BUFFER_SIZE) == 0) 
-        {
-            pc.printf("Written to slave: %s\r\n", buf);
+        //Master escrbe 
+        if (master.write(SLAVE_ADDR, buf, BUFFER_SIZE) == 0)  {
+            pc.printf("Escribe a slave: %s\r\n", buf);
         } 
-        // Read what the slave has (should be identical)
         
+        //Master lee
         if (master.read(SLAVE_ADDR, buf, BUFFER_SIZE) == 0) {
-            pc.printf("Read from slave: %s\r\n", buf);
+            pc.printf("Lee de slave: %s\r\n", buf);   
         }
         
-        // Change the message we're writing to the slave
         send_index++;
         if (send_index > 2) {
             send_index = 0;
         }
     }
-}
+}
\ No newline at end of file