Suga koubou
/
RFID_FeliCa_sample
Sony FeliCa reader/writer (RC-S620/S) library sample
Revision 0:8fff4bbad366, committed 2012-05-10
- Comitter:
- okini3939
- Date:
- Thu May 10 06:15:14 2012 +0000
- Commit message:
Changed in this revision
diff -r 000000000000 -r 8fff4bbad366 RCS620S.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RCS620S.lib Thu May 10 06:15:14 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/okini3939/code/RCS620S/#ccb5446a6b93
diff -r 000000000000 -r 8fff4bbad366 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu May 10 06:15:14 2012 +0000 @@ -0,0 +1,83 @@ +/* + * RC-S620/S sample program for mbed + * + * Copyright 2011 SWITCHSCIENCE + * https://github.com/SWITCHSCIENCE/mbed-FeliCa + * + * modified by Suga + */ + +#include <inttypes.h> +#include "mbed.h" +#include "RCS620S.h" + +static char HEXSTRING[17] = "0123456789ABCDEF"; +char *itoh(uint8_t val, char *ptr); + +DigitalOut serialready(LED1); +DigitalOut felicarwready(LED2); +DigitalOut cardread(LED3); + +Serial pc(USBTX, USBRX); +RCS620S felica(p9, p10); + +int main() { + int ret; + int loop; + char idbuffer[17]; + char *hexid; + char pmmbuffer[17]; + char *hexpmm; + + serialready = 1; + pc.baud(115200); + pc.printf("Serial Ready.\n\r"); + + ret = 0; + while (ret == 0) { + wait(1); + ret = felica.initDevice(); + } + felicarwready = 1; + pc.printf("FeliCa Reader/Writer Ready.\n\r"); + + wait(2); + + while (1) { + + pc.printf("Please FeliCa Touch! "); + + hexid = idbuffer + sizeof(idbuffer); // hexid = buffer[ last of elements ]; + *--hexid = '\0'; + hexpmm = pmmbuffer + sizeof(pmmbuffer); + *--hexpmm = '\0'; + + while (felica.polling(0xffff) == 0); + cardread = 1; + felicarwready = 0; + + + pc.printf("idm: "); + for (loop = 7; loop >= 0; loop--){ + hexid = itoh(felica.idm[loop], hexid); + } + pc.printf("%s /", hexid); + + pc.printf("pmm: "); + for (loop = 7; loop >= 0; loop--){ + hexpmm = itoh(felica.pmm[loop], hexpmm); + } + pc.printf("%s\n\r", hexpmm); + + wait(1); + cardread = 0; + felicarwready = 1; + } +} + +char *itoh(uint8_t val, char *ptr) { + *--ptr = HEXSTRING[(val % 16)]; // (val & 0x0f) + val /= 16; // val = val >> 4; + *--ptr = HEXSTRING[(val % 16)]; // (val & 0x0f) + return(ptr); +}
diff -r 000000000000 -r 8fff4bbad366 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu May 10 06:15:14 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/5364839841bd