Skip to content

Instantly share code, notes, and snippets.

@mugifly
Last active August 29, 2015 13:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mugifly/8689329 to your computer and use it in GitHub Desktop.
Save mugifly/8689329 to your computer and use it in GitHub Desktop.
/**
ArduinoProMini_FelicaPlug_Type3_RW.ino
Felica PlugのArduino向けライブラリに付属されているサンプルを基に改変
(ライブラリ: http://blog.felicalauncher.com/sdk_for_air/?page_id=2419)
**/
#define CONFIG_FELICA_PLUG_EEPROM
#include <EEPROM.h>
#include <FeliCaPlug.h>
#include <inttypes.h>
#define FELICA_PLUG_NO_RF_SUSPEND_TIME 10000
// ピン定義 (一部、ライブラリの初期設定から変更するため)
#define _FELICA_PLUG_RFDET_PIN 3
#define _FELICA_PLUG_SW_PIN 9
#define _FELICA_PLUG_IRQ_PIN 2
#define _FELICA_PLUG_SEL_PIN 4
#define _FELICA_PLUG_DATA_PIN 5
#define _FELICA_PLUG_SPICLK_PIN 6
// FelicaPlug オブジェクト
FeliCaPlug plug;
// 初期のブロックデータ
uint8_t blockData[16 * 12] = {
0x10, 0x0c, 0x0c, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x35
};
void setup() {
// スイッチサイエンスから購入したモジュール向けのデータフォーマットコード : 0x00 0x1c
uint8_t dfc[2] = {0x00, 0x1c};
// 通信内容を識別するためのパラメータ (何でもいいはず)
uint8_t userParam[4] = {0x00, 0x11, 0x22, 0x33};
// ピン(ポート)の設定
plug.initPort(_FELICA_PLUG_SW_PIN, _FELICA_PLUG_SEL_PIN, _FELICA_PLUG_DATA_PIN,
_FELICA_PLUG_SPICLK_PIN, _FELICA_PLUG_IRQ_PIN, _FELICA_PLUG_RFDET_PIN);
// パラメータおよびコードの設定
plug.setParam(FELICA_PLUG_MODE_TYPE3, dfc, userParam); // Type3のFTモードとして設定
// 伝搬波検出を表すLEDの設定
plug.setLEDPin(FELICA_PLUG_LED_PIN); // 13ピン
// ブロックデータの設定 (0, 0 : readOnly=false, syncWithEEPROM=false)
plug.setBlockData(blockData, FELICA_PLUG_EEPROM_MAX_NUM_OF_BLOCKS, 0, 0);
}
void loop() {
// ループ処理の実行
plug.doLoop();
}
@mangalgishreyas
Copy link

can you tell me what this program does ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment