Sony FeliCa reader/writer (RC-S620/S) library sample

Dependencies:   RCS620S mbed

Files at this revision

API Documentation at this revision

Comitter:
okini3939
Date:
Thu May 10 06:15:14 2012 +0000
Commit message:

Changed in this revision

RCS620S.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /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
--- /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);
+}
--- /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