mirror of
https://github.com/whowechina/aic_pico.git
synced 2025-02-25 22:28:04 +01:00
Better naming and readme update
This commit is contained in:
parent
5308521dbc
commit
d6fe8203e0
Binary file not shown.
@ -15,12 +15,13 @@
|
|||||||
* AIC Pico Lib (see notes 1 below)
|
* AIC Pico Lib (see notes 1 below)
|
||||||
* Easy to make.
|
* Easy to make.
|
||||||
* Sega AIME I/O, Bandai Namco I/O and Spicetools CardIO emulation.
|
* Sega AIME I/O, Bandai Namco I/O and Spicetools CardIO emulation.
|
||||||
|
* Automatic detection of I/O protocols above.
|
||||||
* Command line for configurations.
|
* Command line for configurations.
|
||||||
* Supported card:
|
* Supported card:
|
||||||
* FeliCa (Amusement IC)
|
* FeliCa (Amusement IC)
|
||||||
* ISO/IEC 14443 Type A (BanaPassport, Mifare, Amiibo, some IC tags, some ID tags, etc.)
|
* ISO/IEC 14443 Type A (BanaPassport, Mifare, Amiibo, some IC tags, some ID tags, etc.)
|
||||||
* ISO/IEC 15693 (Old E-Amusement cards), only with PN5180 (see notes 2 below)
|
* ISO/IEC 15693 (Old E-Amusement cards), only with PN5180 (see notes 2 below)
|
||||||
* Emulates virtual AIC from any Mifare cards.
|
* Emulates virtual AIC from any Mifare cards (not for Bandai Namco I/O).
|
||||||
* All source files open.
|
* All source files open.
|
||||||
|
|
||||||
**Notes:**
|
**Notes:**
|
||||||
|
@ -18,12 +18,13 @@
|
|||||||
* AIC Pico Lib (参见下面的注释 1)
|
* AIC Pico Lib (参见下面的注释 1)
|
||||||
* 易于制作。
|
* 易于制作。
|
||||||
* Sega AIME I/O, Bandai Namco I/O 和 Spicetools CardIO 模拟。
|
* Sega AIME I/O, Bandai Namco I/O 和 Spicetools CardIO 模拟。
|
||||||
|
* 自动检测上述 I/O 协议。
|
||||||
* 用于参数配置的命令行。
|
* 用于参数配置的命令行。
|
||||||
* 支持的卡:
|
* 支持的卡:
|
||||||
* FeliCa (Amusement IC)
|
* FeliCa (Amusement IC)
|
||||||
* ISO/IEC 14443 类型 A (BanaPassport, Mifare, Amiibo, 一些 IC Tag 和 ID Tag 卡, 等等.)
|
* ISO/IEC 14443 类型 A (BanaPassport, Mifare, Amiibo, 一些 IC Tag 和 ID Tag 卡, 等等.)
|
||||||
* ISO/IEC 15693 (旧的 E-Amusement 卡),仅 PN5180 支持 (参见下面的注释 2)
|
* ISO/IEC 15693 (旧的 E-Amusement 卡),仅 PN5180 支持 (参见下面的注释 2)
|
||||||
* 从任何 Mifare 卡模拟虚拟 AIC。
|
* 从任何 Mifare 卡模拟虚拟 AIC(暂不支持 Bandai Namco I/O 外)。
|
||||||
* 所有源文件开放。
|
* 所有源文件开放。
|
||||||
|
|
||||||
**注释:**
|
**注释:**
|
||||||
|
@ -41,7 +41,7 @@ static void handle_display()
|
|||||||
aic_cfg->light.rgb ? "ON" : "OFF",
|
aic_cfg->light.rgb ? "ON" : "OFF",
|
||||||
aic_cfg->light.led ? "ON" : "OFF");
|
aic_cfg->light.led ? "ON" : "OFF");
|
||||||
printf(" Level: [%d ~ %d]\n", aic_cfg->light.min, aic_cfg->light.max);
|
printf(" Level: [%d ~ %d]\n", aic_cfg->light.min, aic_cfg->light.max);
|
||||||
printf("[AIME]\n");
|
printf("[Reader]]\n");
|
||||||
printf(" Virtual AIC: %s\n", aic_cfg->virtual_aic ? "ON" : "OFF");
|
printf(" Virtual AIC: %s\n", aic_cfg->virtual_aic ? "ON" : "OFF");
|
||||||
|
|
||||||
printf(" Mode: %s\n", mode_name(aic_cfg->mode));
|
printf(" Mode: %s\n", mode_name(aic_cfg->mode));
|
||||||
@ -172,7 +172,8 @@ static void handle_light(int argc, char *argv[])
|
|||||||
|
|
||||||
static void handle_level(int argc, char *argv[])
|
static void handle_level(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
const char *usage = "Usage: level <0..255> <0..255>\n";
|
const char *usage = "Usage: level <dimmed> <active>\n"
|
||||||
|
" dimmed, active: [0..255]\n";
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
printf(usage);
|
printf(usage);
|
||||||
return;
|
return;
|
||||||
@ -214,7 +215,7 @@ void commands_init()
|
|||||||
cli_register("factory", handle_factory_reset, "Reset everything to default.");
|
cli_register("factory", handle_factory_reset, "Reset everything to default.");
|
||||||
cli_register("nfc", handle_nfc, "NFC module.");
|
cli_register("nfc", handle_nfc, "NFC module.");
|
||||||
cli_register("virtual", handle_virtual, "Virtual AIC card.");
|
cli_register("virtual", handle_virtual, "Virtual AIC card.");
|
||||||
cli_register("mode", handle_mode, "AIME version mode.");
|
cli_register("mode", handle_mode, "Reader mode/protocol.");
|
||||||
cli_register("light", handle_light, "Turn on/off lights.");
|
cli_register("light", handle_light, "Turn on/off lights.");
|
||||||
cli_register("level", handle_level, "Set light level.");
|
cli_register("level", handle_level, "Set light level.");
|
||||||
cli_register("debug", handle_debug, "Toggle debug.");
|
cli_register("debug", handle_debug, "Toggle debug.");
|
||||||
|
@ -198,36 +198,36 @@ static void cardio_run()
|
|||||||
update_cardio(&card);
|
update_cardio(&card);
|
||||||
}
|
}
|
||||||
|
|
||||||
const int aime_intf = 1;
|
const int reader_intf = 1;
|
||||||
static struct {
|
static struct {
|
||||||
uint8_t buf[64];
|
uint8_t buf[64];
|
||||||
int pos;
|
int pos;
|
||||||
} aime;
|
} reader;
|
||||||
|
|
||||||
static void cdc_aime_putc(uint8_t byte)
|
static void cdc_reader_putc(uint8_t byte)
|
||||||
{
|
{
|
||||||
tud_cdc_n_write(aime_intf, &byte, 1);
|
tud_cdc_n_write(reader_intf, &byte, 1);
|
||||||
tud_cdc_n_write_flush(aime_intf);
|
tud_cdc_n_write_flush(reader_intf);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void aime_poll_data()
|
static void reader_poll_data()
|
||||||
{
|
{
|
||||||
if (tud_cdc_n_available(aime_intf)) {
|
if (tud_cdc_n_available(reader_intf)) {
|
||||||
int count = tud_cdc_n_read(aime_intf, aime.buf + aime.pos,
|
int count = tud_cdc_n_read(reader_intf, reader.buf + reader.pos,
|
||||||
sizeof(aime.buf) - aime.pos);
|
sizeof(reader.buf) - reader.pos);
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
uint32_t now = time_us_32();
|
uint32_t now = time_us_32();
|
||||||
DEBUG("\n\033[32m%6ld>>", now / 1000);
|
DEBUG("\n\033[32m%6ld>>", now / 1000);
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
DEBUG(" %02X", aime.buf[aime.pos + i]);
|
DEBUG(" %02X", reader.buf[reader.pos + i]);
|
||||||
}
|
}
|
||||||
DEBUG("\033[0m");
|
DEBUG("\033[0m");
|
||||||
aime.pos += count;
|
reader.pos += count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void aime_detect_mode()
|
static void reader_detect_mode()
|
||||||
{
|
{
|
||||||
if (aic_cfg->mode == MODE_AUTO) {
|
if (aic_cfg->mode == MODE_AUTO) {
|
||||||
static bool was_active = true; // so first time mode will be cleared
|
static bool was_active = true; // so first time mode will be cleared
|
||||||
@ -242,16 +242,16 @@ static void aime_detect_mode()
|
|||||||
|
|
||||||
if (aic_runtime.mode == MODE_NONE) {
|
if (aic_runtime.mode == MODE_NONE) {
|
||||||
cdc_line_coding_t coding;
|
cdc_line_coding_t coding;
|
||||||
tud_cdc_n_get_line_coding(aime_intf, &coding);
|
tud_cdc_n_get_line_coding(reader_intf, &coding);
|
||||||
aic_runtime.mode = mode_detect(aime.buf, aime.pos, coding.bit_rate);
|
aic_runtime.mode = mode_detect(reader.buf, reader.pos, coding.bit_rate);
|
||||||
if ((aime.pos > 10) && (aic_runtime.mode == MODE_NONE)) {
|
if ((reader.pos > 10) && (aic_runtime.mode == MODE_NONE)) {
|
||||||
aime.pos = 0; // drop the buffer
|
reader.pos = 0; // drop the buffer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void aime_light()
|
static void reader_light()
|
||||||
{
|
{
|
||||||
static uint32_t old_color = 0;
|
static uint32_t old_color = 0;
|
||||||
if (aime_is_active()) {
|
if (aime_is_active()) {
|
||||||
@ -265,15 +265,15 @@ static void aime_light()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void aime_run()
|
static void reader_run()
|
||||||
{
|
{
|
||||||
aime_poll_data();
|
reader_poll_data();
|
||||||
aime_detect_mode();
|
reader_detect_mode();
|
||||||
|
|
||||||
if (aime.pos > 0) {
|
if (reader.pos > 0) {
|
||||||
uint8_t buf[64];
|
uint8_t buf[64];
|
||||||
memcpy(buf, aime.buf, aime.pos);
|
memcpy(buf, reader.buf, reader.pos);
|
||||||
int count = aime.pos;
|
int count = reader.pos;
|
||||||
switch (aic_runtime.mode) {
|
switch (aic_runtime.mode) {
|
||||||
case MODE_AIME0:
|
case MODE_AIME0:
|
||||||
case MODE_AIME1:
|
case MODE_AIME1:
|
||||||
@ -281,20 +281,20 @@ static void aime_run()
|
|||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
aime_feed(buf[i]);
|
aime_feed(buf[i]);
|
||||||
}
|
}
|
||||||
aime.pos = 0;
|
reader.pos = 0;
|
||||||
break;
|
break;
|
||||||
case MODE_BANA:
|
case MODE_BANA:
|
||||||
for (int i = 0; i < count; i++) {
|
for (int i = 0; i < count; i++) {
|
||||||
bana_feed(buf[i]);
|
bana_feed(buf[i]);
|
||||||
}
|
}
|
||||||
aime.pos = 0;
|
reader.pos = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
aime_light();
|
reader_light();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wait_loop()
|
void wait_loop()
|
||||||
@ -304,7 +304,7 @@ void wait_loop()
|
|||||||
|
|
||||||
tud_task();
|
tud_task();
|
||||||
cli_run();
|
cli_run();
|
||||||
aime_poll_data();
|
reader_poll_data();
|
||||||
|
|
||||||
cli_fps_count(0);
|
cli_fps_count(0);
|
||||||
}
|
}
|
||||||
@ -315,7 +315,7 @@ static void core0_loop()
|
|||||||
tud_task();
|
tud_task();
|
||||||
|
|
||||||
cli_run();
|
cli_run();
|
||||||
aime_run();
|
reader_run();
|
||||||
cardio_run();
|
cardio_run();
|
||||||
|
|
||||||
keypad_update();
|
keypad_update();
|
||||||
@ -347,10 +347,10 @@ void init()
|
|||||||
nfc_init();
|
nfc_init();
|
||||||
nfc_set_wait_loop(wait_loop);
|
nfc_set_wait_loop(wait_loop);
|
||||||
|
|
||||||
aime_init(cdc_aime_putc);
|
aime_init(cdc_reader_putc);
|
||||||
aime_virtual_aic(aic_cfg->virtual_aic);
|
aime_virtual_aic(aic_cfg->virtual_aic);
|
||||||
|
|
||||||
bana_init(cdc_aime_putc);
|
bana_init(cdc_reader_putc);
|
||||||
|
|
||||||
cli_init("aic_pico>", "\n << AIC Pico >>\n"
|
cli_init("aic_pico>", "\n << AIC Pico >>\n"
|
||||||
" https://github.com/whowechina\n\n");
|
" https://github.com/whowechina\n\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user