Ricardo Kannebley
/
rfid-comunicacao_bluetooth
Repositório para o código RFID utilizando a comunicação Bluetooth.
Revision 1:b3d75b8fc5b7, committed 2018-06-15
- Comitter:
- RickBadKan
- Date:
- Fri Jun 15 22:06:10 2018 +0000
- Parent:
- 0:8ef3c259c9b7
- Commit message:
- Organiza??o do c?digo.
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MFRC522.lib Fri Jun 15 22:06:10 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/AtomX/code/MFRC522/#63d729186747
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jun 15 22:06:10 2018 +0000 @@ -0,0 +1,71 @@ +//Test of cheap 13.56 Mhz RFID-RC522 module from eBay +//This code is based on Martin Olejar's MFRC522 library. Minimal changes +//Adapted for Nucleo STM32 F401RE. Should work on other Nucleos too + +//Connect as follows: +//RFID pins -> Nucleo header CN5 (Arduino-compatible header) +//---------------------------------------- +//RFID IRQ=pin5 -> Not used. Leave open +//RFID MISO=pin4 -> Nucleo SPI_MISO=PA_6=D12 +//RFID MOSI=pin3 -> Nucleo SPI_MOSI=PA_7=D11 +//RFID SCK=pin2 -> Nucleo SPI_SCK =PA_5=D13 +//RFID SDA=pin1 -> Nucleo SPI_CS =PB_6=D10 +//RFID RST=pin7 -> Nucleo =PA_9=D8 +//3.3V and Gnd to the respective pins + +#include "mbed.h" +#include "MFRC522.h" + +// Nucleo Pin for MFRC522 reset (pick another D pin if you need D8) +#define MF_RESET p8 + +DigitalOut LedGreen(p24); + +//Serial connection to PC for output +Serial pc(p9, p10); + +MFRC522 RfChip (p11, p12, p13, p14, MF_RESET); + +int main(void) { + pc.baud(9600); + + pc.printf("starting...\n"); + + wait(1); + + // Init. RC522 Chip + RfChip.PCD_Init(); + + while (true) { + LedGreen = 1; + + // 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; + } + + LedGreen = 0; + + // 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)); + wait_ms(1000); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Jun 15 22:06:10 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/5aab5a7997ee \ No newline at end of file
--- a/rfid-comunicacao_bluetooth/main.cpp Wed Jun 06 19:51:51 2018 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,71 +0,0 @@ -//Test of cheap 13.56 Mhz RFID-RC522 module from eBay -//This code is based on Martin Olejar's MFRC522 library. Minimal changes -//Adapted for Nucleo STM32 F401RE. Should work on other Nucleos too - -//Connect as follows: -//RFID pins -> Nucleo header CN5 (Arduino-compatible header) -//---------------------------------------- -//RFID IRQ=pin5 -> Not used. Leave open -//RFID MISO=pin4 -> Nucleo SPI_MISO=PA_6=D12 -//RFID MOSI=pin3 -> Nucleo SPI_MOSI=PA_7=D11 -//RFID SCK=pin2 -> Nucleo SPI_SCK =PA_5=D13 -//RFID SDA=pin1 -> Nucleo SPI_CS =PB_6=D10 -//RFID RST=pin7 -> Nucleo =PA_9=D8 -//3.3V and Gnd to the respective pins - -#include "mbed.h" -#include "MFRC522.h" - -// Nucleo Pin for MFRC522 reset (pick another D pin if you need D8) -#define MF_RESET p8 - -DigitalOut LedGreen(p24); - -//Serial connection to PC for output -Serial pc(p9, p10); - -MFRC522 RfChip (p11, p12, p13, p14, MF_RESET); - -int main(void) { - pc.baud(9600); - - pc.printf("starting...\n"); - - wait(1); - - // Init. RC522 Chip - RfChip.PCD_Init(); - - while (true) { - LedGreen = 1; - - // 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; - } - - LedGreen = 0; - - // 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)); - wait_ms(1000); - } -} \ No newline at end of file