1
0
mirror of synced 2024-11-24 08:00:09 +01:00
Arduino-Aime-Reader/Arduino-Aime-Reader.ino

96 lines
1.9 KiB
Arduino
Raw Normal View History

#define high_baudrate
#include "Aime_Redaer.h"
2021-03-15 15:48:12 +01:00
void setup() {
2022-03-06 13:29:21 +01:00
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
2021-08-15 13:56:27 +02:00
FastLED.setBrightness(50);
FastLED.showColor(0);
2021-03-15 15:48:12 +01:00
nfc.begin();
2021-08-15 13:56:27 +02:00
while (!nfc.getFirmwareVersion()) {
FastLED.showColor(0xFF0000);
2021-08-15 13:56:27 +02:00
delay(500);
FastLED.showColor(0);
2021-08-15 13:56:27 +02:00
delay(500);
}
nfc.setPassiveActivationRetries(0x10);
2021-03-15 15:48:12 +01:00
nfc.SAMConfig();
memset(req.bytes, 0, sizeof(req.bytes));
memset(res.bytes, 0, sizeof(res.bytes));
SerialDevice.begin(baudrate);
FastLED.showColor(BootColor);
2021-03-15 15:48:12 +01:00
}
void loop() {
2021-10-09 19:16:03 +02:00
switch (packet_read()) {
case 0:
2021-10-09 19:16:03 +02:00
break;
case CMD_TO_NORMAL_MODE:
sys_to_normal_mode();
2021-10-09 19:16:03 +02:00
break;
case CMD_GET_FW_VERSION:
sys_get_fw_version();
2021-10-09 19:16:03 +02:00
break;
case CMD_GET_HW_VERSION:
sys_get_hw_version();
2021-10-09 19:16:03 +02:00
break;
// Card read
case CMD_START_POLLING:
nfc_start_polling();
2021-10-09 19:16:03 +02:00
break;
case CMD_STOP_POLLING:
nfc_stop_polling();
break;
case CMD_CARD_DETECT:
nfc_card_detect();
2021-10-09 19:16:03 +02:00
break;
// MIFARE
case CMD_MIFARE_KEY_SET_A:
memcpy(KeyA, req.key, 6);
res_init();
2021-10-09 19:16:03 +02:00
break;
case CMD_MIFARE_KEY_SET_B:
res_init();
memcpy(KeyB, req.key, 6);
2021-10-09 19:16:03 +02:00
break;
case CMD_MIFARE_AUTHORIZE_A:
nfc_mifare_authorize_a();
2021-10-09 19:16:03 +02:00
break;
case CMD_MIFARE_AUTHORIZE_B:
nfc_mifare_authorize_b();
2021-10-09 19:16:03 +02:00
break;
case CMD_MIFARE_READ:
nfc_mifare_read();
2021-10-09 19:16:03 +02:00
break;
// FeliCa
case CMD_FELICA_THROUGH:
nfc_felica_through();
2021-10-09 19:16:03 +02:00
break;
// LED
case CMD_EXT_BOARD_LED_RGB:
FastLED.showColor(CRGB(req.color_payload[0], req.color_payload[1], req.color_payload[2]));
2021-10-09 19:16:03 +02:00
break;
case CMD_EXT_BOARD_INFO:
sys_get_led_info();
2021-10-09 19:16:03 +02:00
break;
case CMD_EXT_BOARD_LED_RGB_UNKNOWN:
2021-10-09 19:16:03 +02:00
break;
2021-10-09 19:16:03 +02:00
default:
res_init();
2021-10-09 19:16:03 +02:00
}
packet_write();
2021-10-09 19:16:03 +02:00
}