mbed code for the Kinoma team's wireless assignment
Dependencies: mbed
Fork of idd_hw5_kinoma_rememberkeys by
main.cpp
00001 #include "mbed.h" 00002 #include "Adafruit_PN532.h " 00003 00004 #define SS PTD0 00005 // PTD1 is also LED_BLUE, it will blink during SPI communication. 00006 #define SCK PTD1 00007 #define MOSI PTD2 00008 #define MISO PTD3 00009 00010 DigitalOut kinoma(D8); 00011 int previous = 0; 00012 00013 Adafruit_PN532 nfc(SCK, MISO, MOSI, SS); 00014 00015 void loop(void); 00016 00017 int main() { 00018 kinoma = 0; 00019 nfc.begin(); 00020 00021 uint32_t versiondata = nfc.getFirmwareVersion(); 00022 if (! versiondata) { 00023 while (1); // halt 00024 } 00025 00026 nfc.SAMConfig(); 00027 00028 while(1) { loop(); } 00029 } 00030 00031 00032 void loop(void) { 00033 uint8_t success; 00034 uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; 00035 uint8_t uidLength; 00036 00037 success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength); 00038 00039 if (success) { 00040 previous = 1; 00041 00042 if (uidLength == 4) 00043 { 00044 uint8_t tag_1 = 250; 00045 uint8_t tag_2 = 186; 00046 uint8_t tag_3 = 106; 00047 uint8_t tag_4 = 10; 00048 kinoma = 1; 00049 } 00050 } else if (previous == 0){ 00051 kinoma = 0; 00052 } else { 00053 previous = 0; 00054 } 00055 }
Generated on Sun Jul 17 2022 01:45:53 by 1.7.2