![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
project van rtos
Dependencies: mbed-os
Fork of MFRC522 by
main.cpp
- Committer:
- Onon
- Date:
- 2018-05-02
- Revision:
- 2:c719944e080b
- Child:
- 3:80837b470692
File content as of revision 2:c719944e080b:
#include "mbed.h" #include "MFRC522.h" //KL25Z Pins for MFRC522 SPI interface #define SPI_MOSI p5 #define SPI_MISO p6 #define SPI_SCLK p7 #define SPI_CS p9 // KL25Z Pin for MFRC522 reset #define MF_RESET p8 /** // KL25Z Pins for Debug UART port #define UART_RX gnd #define UART_TX gnd Serial DebugUART(UART_TX, UART_RX); **/ MFRC522 RfChip(SPI_MOSI, SPI_MISO, SPI_SCLK, SPI_CS, MF_RESET); Serial pc(USBTX, USBRX); DigitalOut led(LED1); int main(void) { pc.printf("Start"); // Set debug UART speed //DebugUART.baud(115200); // Init. RC522 Chip RfChip.PCD_Init(); while (true) { led = 0; // Look for new cards if ( ! RfChip.PICC_IsNewCardPresent()) { wait_ms(500); continue; } // Select one of the cards if ( ! RfChip.PICC_ReadCardSerial()) { wait_ms(500); continue; } // Print Card UID pc.printf("Card UID: "); for (uint8_t i = 0; i < RfChip.uid.size; i++) { led = 1; 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)); wait_ms(1000); } }