Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: PN532_MK20 USBDevice mbed
Fork of NFC_HTM_READ by
Main.cpp
00001 /* 00002 -------------------------------------------------------------- 00003 ---- DECLARACIONES DE LIBRERIAS 00004 -------------------------------------------------------------- 00005 */ 00006 #include "mbed.h" 00007 #include "PN532_SPI.h" 00008 #include "NfcAdapter.h" 00009 #include "USBSerial.h" 00010 #include "UtilidadesNFC.h" 00011 00012 /* 00013 -------------------------------------------------------------- 00014 ---- DECLARACIONES DE VARIABLES GLOBALES 00015 -------------------------------------------------------------- 00016 */ 00017 00018 //Declaracion de estados 00019 enum estados{ 00020 espera = 0x00, 00021 leerTagID = 0x01, 00022 00023 }; 00024 00025 estados miestado; 00026 00027 00028 00029 // configurando pines del led RGB como salida 00030 DigitalOut red (LED1); 00031 DigitalOut green (LED2); 00032 DigitalOut blue (PTC4); 00033 00034 //INICIALIZANDO PUERTO USB 00035 USBSerial usb; 00036 00037 /* 00038 -------------------------------------------------------------- 00039 ---- ESTADOS 00040 -------------------------------------------------------------- 00041 */ 00042 00043 void estadoEspera() 00044 { 00045 //APAGAR LED RGB 00046 red = 1; 00047 green = 1; 00048 blue = 1; 00049 00050 //VARIABLES LOCALES 00051 char bufferRecibido[10]; 00052 char bufferLeer[10] = "leer"; 00053 00054 00055 00056 00057 usb.scanf("%s", bufferRecibido);//LEE LOS DATOS DE ENTRADA POR CONSOLA 00058 usb.printf("\r\nUsted Escribio - |%s| \r\n ", bufferRecibido);//MUESTRA LOS DATOS RECIBIDOS 00059 00060 //DEPENDIENDO DE LOS DATOS RECIBIDOS SE ENVIA A UN ESTADO DETERMINADO 00061 if(strcmp(bufferRecibido, bufferLeer) == 0) 00062 { 00063 miestado = leerTagID; 00064 } 00065 00066 00067 } 00068 00069 void estadoLeer() 00070 { 00071 int valorRetorno = 0; 00072 00073 while(valorRetorno == 0) 00074 { 00075 valorRetorno = LeerTagNFC(); 00076 00077 } 00078 miestado = espera; 00079 } 00080 00081 00082 /* 00083 -------------------------------------------------------------- 00084 ---- FUNCION MAIN PRINCIPAL 00085 -------------------------------------------------------------- 00086 */ 00087 00088 int main() 00089 { 00090 00091 while(1) 00092 { 00093 00094 switch(miestado) 00095 { 00096 case espera: 00097 estadoEspera(); 00098 break; 00099 00100 case leerTagID: 00101 estadoLeer(); 00102 break; 00103 00104 } 00105 00106 } 00107 00108 00109 00110 }
Generated on Tue Jul 12 2022 14:13:58 by
1.7.2
