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.
main.cpp
00001 00002 /* 00003 * RC-S620/S sample program for mbed 00004 * 00005 * Copyright 2011 SWITCHSCIENCE 00006 * 00007 */ 00008 00009 #include <inttypes.h> 00010 #include "mbed.h" 00011 #include "RCS620S.h" 00012 00013 static char HEXSTRING[17] = "0123456789ABCDEF"; 00014 char *itoh(uint8_t val, char *ptr); 00015 00016 DigitalOut serialready(LED1); 00017 DigitalOut felicarwready(LED2); 00018 DigitalOut cardread(LED3); 00019 00020 Serial pc(USBTX, USBRX); 00021 Serial serial(p9, p10); 00022 00023 int main() { 00024 int ret; 00025 int loop; 00026 char idbuffer[17]; 00027 char *hexid; 00028 char pmmbuffer[17]; 00029 char *hexpmm; 00030 00031 serial.baud(115200); 00032 serialready = 1; 00033 pc.printf("Serial Ready.\n\r"); 00034 00035 ret = 0; 00036 RCS620S felica; 00037 while (ret == 0) { 00038 wait(1); 00039 ret = felica.initDevice(); 00040 } 00041 felicarwready = 1; 00042 pc.printf("FeliCa Reader/Writer Ready.\n\r"); 00043 00044 wait(2); 00045 00046 while (1) { 00047 00048 pc.printf("Please FeliCa Touch! "); 00049 00050 hexid = idbuffer + sizeof(idbuffer); // hexid = buffer[ last of elements ]; 00051 *--hexid = '\0'; 00052 hexpmm = pmmbuffer + sizeof(pmmbuffer); 00053 *--hexpmm = '\0'; 00054 00055 while (felica.polling(0xffff) == 0); 00056 cardread = 1; 00057 felicarwready = 0; 00058 00059 00060 pc.printf("idm: "); 00061 for (loop = 7; loop >= 0; loop--){ 00062 hexid = itoh(felica.idm[loop], hexid); 00063 } 00064 pc.printf("%s /", hexid); 00065 00066 pc.printf("pmm: "); 00067 for (loop = 7; loop >= 0; loop--){ 00068 hexpmm = itoh(felica.pmm[loop], hexpmm); 00069 } 00070 pc.printf("%s\n\r", hexpmm); 00071 00072 wait(1); 00073 cardread = 0; 00074 felicarwready = 1; 00075 } 00076 } 00077 00078 char *itoh(uint8_t val, char *ptr) { 00079 *--ptr = HEXSTRING[(val % 16)]; // (val & 0x0f) 00080 val /= 16; // val = val >> 4; 00081 *--ptr = HEXSTRING[(val % 16)]; // (val & 0x0f) 00082 return(ptr); 00083 }
Generated on Thu Jul 14 2022 23:56:03 by
1.7.2