Cambio de pin de entrada digital a PA10

Dependencies:   BufferedSerial PinDetect mbed

Fork of DTK-MEGAPACA_NUCLEO by Felícito Manzano

Revision:
9:04f9da6bc784
Parent:
8:f71b44b139f6
Child:
11:780b02b6a035
--- a/main.cpp	Fri Jan 19 19:08:06 2018 +0000
+++ b/main.cpp	Mon Feb 12 14:27:53 2018 -0600
@@ -17,9 +17,9 @@
 
 /*  CONFIGURACIÓN DE HARDWARE
 ************************************** */
-BufferedSerial  gv300(PA_9, PA_10);
-Serial          pcusb(USBTX, USBRX);
-InterruptIn     input(PB_5);
+BufferedSerial  gv300(USBTX, USBRX);
+//Serial          pcusb(USBTX, USBRX);
+InterruptIn     input(PA_9);
 DigitalOut      myled(PB_3);
 
 // DECLARACIÓN DE VARIABLES
@@ -47,10 +47,11 @@
     // CONFIGURAR INTERFACES
     //***********************************
     gv300.baud(115200);
-    pcusb.baud(115200);
+    //pcusb.baud(115200);
+    input.mode(PullUp);
     input.fall(&pressed_f);
     wait(1.0);
-    booting_gtdat(&gv300, &pcusb);
+    iniciando(&gv300);
     
     // Inicio de temporizadores y RTC
     funcionando.start();
@@ -60,16 +61,15 @@
         wait(0.5);
         
         // CONSULTAR SI SE HA PRESIONADO EL BOTÓN 
-        if (apagar) {
-            pcusb.printf("\r\nBoton de panico presionado.\r\n");
-            pcusb.printf("Apagando en T-15\r\n");
+        if ((apagar == 1) && (apagando_cp.read() < 0.5)) {
+            //pcusb.printf("\r\nBoton de panico presionado.\r\n");
+            //pcusb.printf("Apagando en T-15\r\n");
             apagar = 0;
             apagando_cp.start();
             sprintf(skytrack_frame,"%s%s%s%s%04X%s", 
                     CABECERA_TX, CODIGO_INT, INIT_SHUTDOWN, 
                     FIN_CABECERA_TX, contador_tramas, ULTIMO_CARACTER);
             gv300.printf("%s\r\n", skytrack_frame);
-            pcusb.printf("Iniciando temporizador 15 min.\r\n");
             memset(skytrack_frame, '\0', sizeof(skytrack_frame));               // Vaciar el buffer de Skytrack Frame
             incrementar_trama(&contador_tramas);
 
@@ -77,9 +77,8 @@
 
         // VALIDAR SI SE DEBE ABORTAR
         // Leer puerto Serial
-        i = leer_uart(&gv300, buffered_frame);
-        if (i) {
-            pcusb.printf("Trama recibida...\r\n");
+        if (leer_uart(&gv300, buffered_frame)) {
+            //pcusb.printf("Trama recibida...\r\n");
             i = procesar_trama(buffered_frame);
             if(i == 1) { // 1 = ABORTAR
                 apagar = 0;
@@ -90,23 +89,23 @@
                     CABECERA_TX, CODIGO_INT, CANC_SHUTDOWN, 
                     FIN_CABECERA_TX, contador_tramas, ULTIMO_CARACTER);
                 gv300.printf("%s\r\n", skytrack_frame);
-                pcusb.printf("Apagado por panico ABORTADO.\r\n");
+                //pcusb.printf("Apagado por panico ABORTADO.\r\n");
             } else if (i == 3){
                 // Nada por hacer por el OK
             } else {
-                pcusb.printf("Trama DESCONOCIDA.\r\n");
+                // pcusb.printf("Trama DESCONOCIDA.\r\n");
             }
         }
 
         // CONSULTAR SI SE DEBE APAGAR
         tiempo_actual = apagando_cp.read();                              // Leer el temporizador de Heartbeat
         if (tiempo_actual >= (MINUTO * factor)) {
-            pcusb.printf("Apagando en T-%d\r\n", (T_15 - factor));
+            //pcusb.printf("Apagando en T-%d\r\n", (T_15 - factor));
             factor++;
         }
 
         if (tiempo_actual >= TIME_SHUTDOWN) {
-            pcusb.printf("Apangado en progreso...\r\n");
+            //pcusb.printf("Apangado en progreso...\r\n");
             apagando_cp.stop();
             apagando_cp.reset();
             apagar = 0;
@@ -123,24 +122,24 @@
                         CABECERA_TX, CODIGO_INT, SHUTDOWN_DONE, 
                         FIN_CABECERA_TX, contador_tramas, ULTIMO_CARACTER);
                     gv300.printf("%s\r\n", skytrack_frame);
-                    pcusb.printf("Apagado remoto +EXITOSO!\r\n");
+                    //pcusb.printf("Apagado remoto +EXITOSO!\r\n");
                 } else {
                     sprintf(skytrack_frame,"%s%s%s%s%04X%s", 
                         CABECERA_TX, CODIGO_INT, SHUTDOWN_ERRO, 
                         FIN_CABECERA_TX, contador_tramas, ULTIMO_CARACTER);
                     gv300.printf("%s\r\n", skytrack_frame);
-                    pcusb.printf("Apagado remoto -FALLIDO!\r\n");    
+                    //pcusb.printf("Apagado remoto -FALLIDO!\r\n");    
                 }
             }  else { 
                 gv300.printf("%s\r\n", SHUTDOWN_ERRO);
-                pcusb.printf("Apagado remoto -FALLIDO!\r\n");
+                //pcusb.printf("Apagado remoto -FALLIDO!\r\n");
             }
         }
 
         // ENVIAR HEARTBEAT A SKYTRACK
         tiempo_actual = funcionando.read();                              // Leer el temporizador de Heartbeat
         if (tiempo_actual >= TIME_HEARTBEAT) {
-            pcusb.printf("\r\nMultipuertos estable.\r\n");
+            //pcusb.printf("\r\nMultipuertos estable.\r\n");
             funcionando.reset();
             sprintf(skytrack_frame, "%s%s%04X%s\r\n",
                     ALIVE, FIN_CABECERA_TX, contador_tramas, ULTIMO_CARACTER);