Prueba con puertos seriales Nucleo F303K8

Dependencies:   BufferedSerial DebounceIn mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include <stdio.h>
00003 #include <string.h>
00004 #include <math.h>
00005 #include "BufferedSerial.h" 
00006 
00007 
00008 extern BufferedSerial GV300(USBTX, USBRX,1536, 1);
00009 extern BufferedSerial LH(PA_9, PA_10,1536 ,1);
00010 extern DigitalOut myled(PB_3);
00011 
00012 
00013 int main() {
00014     
00015     GV300.baud(115200);
00016     LH.baud(115200);
00017     char datoLH[1311];
00018     char datoGV300[1311];
00019     char dato;
00020     char dato1;
00021     int i;
00022     int j;
00023     
00024     wait(2);
00025     
00026     LH.printf("Inicio Lector Huella\n");  
00027     GV300.printf("Inicio GV300\n"); 
00028     
00029 while(1) {
00030 
00031      myled = !myled;   
00032      wait(2);
00033 
00034      i = 0;
00035      j = 0;
00036      
00037      while(GV300.readable()){
00038          dato = GV300.getc();
00039          wait_ms(5); 
00040          datoGV300[i] = dato;
00041          i++;
00042          }
00043                 
00044     while(LH.readable()){
00045          dato1 = LH.getc();
00046          wait_ms(5); 
00047          datoLH[j] = dato1;
00048          j++;
00049          }           
00050                           
00051       if (i != 0){       
00052          datoGV300[i] = '\0';
00053          LH.printf("\n");  
00054          LH.printf("Dato recibido en el puerto GV300: \n\n%s", datoGV300);
00055          LH.printf("\n");
00056          LH.printf("\n");
00057          }                
00058          
00059       if (j !=0){
00060          datoLH[j] = '\0';
00061          GV300.printf("\n");
00062          GV300.printf("Dato recibido en el puerto Lector de Huella: \n\n%s", datoLH);
00063          GV300.printf("\n");
00064          GV300.printf("\n");
00065          }
00066          
00067       else{                                              
00068          LH.printf("No hay datos en el puerto GV300\n");
00069          GV300.printf("No hay datos en el puerto Lector de Huella\n");
00070          }
00071 
00072 }
00073 
00074 }