![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
project van rtos
Dependencies: mbed-os
Fork of MFRC522 by
Diff: main.cpp
- Revision:
- 8:4638e3f14c41
- Parent:
- 6:c034f08291ab
- Parent:
- 7:1c712013123b
- Child:
- 9:f1f71e42e267
diff -r c034f08291ab -r 4638e3f14c41 main.cpp --- a/main.cpp Thu May 17 11:00:46 2018 +0000 +++ b/main.cpp Thu May 17 11:03:21 2018 +0000 @@ -319,6 +319,39 @@ } } +void checkRFID() { + while (true) { + + // Look for new cards + if ( ! RfChip.PICC_IsNewCardPresent()) + { + Thread::wait(500); + continue; + } + + // Select one of the cards + if ( ! RfChip.PICC_ReadCardSerial()) + { + Thread::wait(500); + continue; + } + + // Print Card UID + pc.printf("Card UID: "); + for (uint8_t i = 0; i < RfChip.uid.size; i++) + { + pc.printf(" %X02", RfChip.uid.uidByte[i]); + } + pc.printf("\n\r"); + + // Print Card type + uint8_t piccType = RfChip.PICC_GetType(RfChip.uid.sak); + pc.printf("PICC Type: %s \n\r", RfChip.PICC_GetTypeName(piccType)); + Thread::wait(1000); + } +} + + int main(void) { pc.printf("Start"); @@ -334,6 +367,8 @@ Thread thread_display(osPriorityRealtime); thread_display.start(displayNumber7Seg); + Thread thread_rfid; + thread_rfid.start(checkRFID); // Set debug UART speed //pc.baud(115200); @@ -347,7 +382,6 @@ while (true) { - //printf("%0.4f \n\r", a0.read()); // Look for new cards /*if ( ! RfChip.PICC_IsNewCardPresent()) {