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: mbed qnode2 MFRC522-2 eeprom Buffer2
Revision 0:031eeed95323, committed 2018-07-27
- Comitter:
- alejo5214416
- Date:
- Fri Jul 27 00:31:50 2018 +0000
- Child:
- 1:4235920f89f8
- Commit message:
- Esclavo Maestro
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Buffer.lib Fri Jul 27 00:31:50 2018 +0000 @@ -0,0 +1,1 @@ +Buffer#9375e70ace0a
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MFRC522.lib Fri Jul 27 00:31:50 2018 +0000 @@ -0,0 +1,1 @@ +MFRC522#4d0b06f52496
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eeprom.lib Fri Jul 27 00:31:50 2018 +0000 @@ -0,0 +1,1 @@ +eeprom#7c54b267cbd3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jul 27 00:31:50 2018 +0000 @@ -0,0 +1,102 @@ +#include "mbed.h" +#include "MFRC522.h" +#include "qnode.h" +#include "Buffer.h" + + +DigitalOut led_3(LED3); +DigitalOut led2(LED2); +DigitalOut LedGreen(LED1); +DigitalOut enable(p19); +Serial pc(USBTX, USBRX); +Serial disp_uno(p9, p10); // tx, rx +MFRC522 RfChip (p5, p6, p7, p8, p21); +circular_buf_t buf; // ---->BUFFER CIRCULAR buf +bool flag1=false; +bool flag2=false; +bool flag3=false; +volatile bool buf1ready=false; +volatile bool buf2ready=false; + + +void disp_unoTx_isr() +{ + enable=0; +} + +void disp_unoRx_isr() +{ + led2=1; + uint8_t b = disp_uno.getc(); + + if(b!=NULL) { + circular_buf_put(&buf, b); + } else { + uint8_t a; + circular_buf_get(&buf,&a); + if(a=='1') { + circular_buf_get(&buf,&a); + if(a=='S') { + flag1=true; + } else if(a=='Y') { + flag2=true; + } else if(a=='N') { + flag3=true; + } + }else + circular_buf_reset(&buf); + + } + +} + + +int main() +{ + struct Queue *q = createQueue(); + pc.printf("Listo para lectura\n"); + buf.size = 5; + buf.buffer = (uint8_t*) malloc(buf.size); + enable=0; + led2=0; + RfChip.PCD_Init(); + disp_uno.attach(&disp_unoRx_isr,Serial::RxIrq); + disp_uno.attach(&disp_unoTx_isr,Serial::TxIrq); + + while(1) { + led2 = !led2; + if ( RfChip.PICC_IsNewCardPresent()) { + led_3=0; + if (RfChip.PICC_ReadCardSerial()) { + + LedGreen = 1; + pc.printf("Tarjeta Numero: "); + uint8_t * c = &RfChip.uid.uidByte[0]; + enQueue(q,c); + pc.printf("\n\r"); + wait_ms(200); + } + } + + + if(flag1==true) { + QNode *c= deQueue(q); + enable=1; + for(int i=0; i<4; i++) { + disp_uno.printf("%02X ",c->uid[i]); + } + enable=1; + disp_uno.putc('\n'); + flag1=false; + } else if(flag2==true) { + //enable=1; + pc.printf("YES\n"); + flag2=false; + } else if(flag3==true) { + //enable=1; + pc.printf("NO\n"); + flag3=false; + } + + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Jul 27 00:31:50 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/a7c7b631e539 \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/qnode.lib Fri Jul 27 00:31:50 2018 +0000 @@ -0,0 +1,1 @@ +qnode#28ba51765608