Piccolo / Mbed 2 deprecated Piccolo_10

Dependencies:   mbed

Revision:
1:c0ff30bf8db2
Parent:
0:02b166bd1478
Child:
2:b0ed0b16b9c8
diff -r 02b166bd1478 -r c0ff30bf8db2 main.cpp
--- a/main.cpp	Sat Nov 18 14:53:56 2017 +0000
+++ b/main.cpp	Thu Nov 23 21:51:48 2017 +0000
@@ -4,11 +4,11 @@
 
 //Serial blue(PA_9, PA_10);  //PA_10=TX , PA_9=RX  ... D8 y D2 respectivamente en la nucleo tx1
 Serial pc(PA_9, PA_10);
-Serial command(USBTX, USBRX ,9600);
+Serial device(D1, D0, 9600); // tx rx
+Serial command(D8,D2);
 DigitalOut led(LED1);
 
-
-void pausa(); 
+ 
 void command_led();
 void punto();
 void linea();
@@ -54,6 +54,7 @@
 //int time = 0;
 int pause = 1;          // Tiempo en us (tiempo entre pasos) nos da la velocidad 
 uint8_t val;
+uint8_t estado = 1;
 // COMANDOS         
 #define LED_NC          0   //ok
 #define DOT_NC          1   //ok
@@ -130,9 +131,11 @@
     
 void print_num(uint8_t val)
 {   if (val <10){
+    device.putc(val+0x30);
     command.putc(val+0x30);
     pc.putc(val+0x30);}
     else {
+    device.putc(val-9+0x40);    
     command.putc(val-9+0x40); 
     pc.putc(val-9+0x40);  }}
     
@@ -146,8 +149,14 @@
 
 void Read_command() // Leer el comando que se digito en CoolTerm
 {
-    for (uint8_t i=0; i<BUFF_SIZE;i++)
-    buffer_command[i]=command.getc();   }
+    for (uint8_t i=0; i<BUFF_SIZE;i++){
+    buffer_command[i]=command.getc();
+       }
+     /*for (uint8_t i=0; i<BUFF_SIZE;i++){
+    buffer_command[i]=device.getc();
+       }*/
+       
+}  
  
 void echo_command()
 {
@@ -273,7 +282,6 @@
         command.printf("Coordenadas x=%i,y=%i for 1\n", xi,y);
         #endif    
         }  
-        wait(10);
     for (uint8_t yi=y; yi<=(y+h); yi+=RSTEP){
         vertex2d(x+a,yi);
         #if DEBUG
@@ -381,24 +389,12 @@
      }
     
 void pausa(){
-   
-   // while(pause == 0){
-        
-        wait(10000);
-        //}
-          /*  #if DEBUG
-    command.printf("piccolo en pausa ");
-    #endif
-    led=0;
-    wait(2);*/
+   estado = 0;
 }
 
 void reanudar(){
  
-    while(pause == 1){
-        
-        wait(0);
-        }
+    estado = 1;
     #if DEBUG
         command.printf("reanuda piccolo ");
     #endif   
@@ -416,6 +412,7 @@
 //*********Interrupcion*******//
 
 void interrup(){
+        //if(estado == 1){
         val=command.getc();
         if (val== '<'){
             Read_command();
@@ -430,7 +427,9 @@
         }
         else command.printf("error inicio trama: %d ",val);
         command.putc(val);
-    return;
+        return;
+        //}
+    
     
  }
  
@@ -526,16 +525,17 @@
 }}
  
 int main() {
+    
+    //command.baud(9600);
+    //device.baud(9600);
     #if DEBUG
     command.printf("inicio con debug\n");
     #else
     command.printf("inicio sin debug\n");
     #endif
-    command.attach(&interrup);
-    /*while(1){
-   
-    //command.printf("%d",buffer_command[0]);
-      wait(1);
-    }*/
+   command.attach(&interrup,Serial::RxIrq);
+    //command.attach(&interrup);
+    while(1);
+    
     
 }