1
0
mirror of https://github.com/whowechina/aic_pico.git synced 2024-11-27 23:10:48 +01:00

Better bana timing

This commit is contained in:
whowechina 2024-05-27 10:10:31 +08:00
parent 2036e47aa2
commit bdc64c2d0d
7 changed files with 27 additions and 17 deletions

Binary file not shown.

View File

@ -201,13 +201,12 @@ static void handle_no_card()
send_response_data("\x00\x00\x00", 3);
}
static void cmd_poll_card()
static void cmd_poll_card(bool mifare, bool felica)
{
nfc_card_t card = nfc_detect_card_ex(true, true, false);
nfc_card_t card = nfc_detect_card_ex(mifare, felica, false);
if (debug) {
display_card(&card);
}
switch (card.card_type) {
case NFC_CARD_MIFARE:
handle_mifare(card.uid);
@ -281,8 +280,9 @@ static void cmd_mifare()
static void cmd_select()
{
nfc_select(0);
send_response_data("\x00", 1);
nfc_select();
nfc_select(1);
}
static void cmd_deselect()
@ -386,7 +386,7 @@ static void handle_frame()
send_response_data("\x00\x06\x00", 3);
break;
case 0x4a:
cmd_poll_card();
cmd_poll_card(request.hdr.len == 4, request.hdr.len == 9);
break;
case 0x40:
cmd_mifare();

View File

@ -60,7 +60,7 @@ struct {
bool (*mifare_read)(uint8_t block_id, uint8_t block_data[16]);
bool (*felica_read)(uint16_t svc_code, uint16_t block_id, uint8_t block_data[16]);
void (*set_wait_loop)(nfc_wait_loop_t loop);
void (*select)();
void (*select)(int phase);
void (*deselect)();
} api[3] = {
{
@ -285,10 +285,10 @@ bool nfc_felica_read(uint16_t svc_code, uint16_t block_id, uint8_t block_data[16
return api[nfc_module].felica_read(svc_code, block_id, block_data);
}
void nfc_select()
void nfc_select(int phase)
{
if (api[nfc_module].select) {
api[nfc_module].select();
api[nfc_module].select(phase);
}
}

View File

@ -266,13 +266,16 @@ static bool anti_collision(uint8_t code, uint8_t uid[5], uint8_t *sak)
return true;
}
static void poll_mifare_1()
static void poll_mifare_0()
{
pn5180_reset();
pn5180_load_rf_config(0x00, 0x80);
pn5180_rf_field(true);
rf_crc_off();
}
static void poll_mifare_1()
{
pn5180_and_reg(PN5180_REG_IRQ_CLEAR, 0x000fffff);
pn5180_and_reg(PN5180_REG_SYSTEM_CONFIG, 0xfffffff8);
pn5180_or_reg(PN5180_REG_SYSTEM_CONFIG, 0x03);
@ -317,6 +320,7 @@ static void poll_mifare_2()
bool pn5180_poll_mifare(uint8_t uid[7], int *len)
{
poll_mifare_0();
poll_mifare_1();
poll_mifare_2();
@ -528,14 +532,16 @@ bool pn5180_felica_read(uint16_t svc_code, uint16_t block_id, uint8_t block_data
return true;
}
/* Not real select, just a time distribution of a poll */
void pn5180_select()
void pn5180_select(int phase)
{
poll_mifare_1();
if (phase == 0) {
poll_mifare_0();
} else {
poll_mifare_1();
}
}
/* Not real deselect, just a time distribution of a poll */
void pn5180_deselect()
{
poll_mifare_2();
}
}

View File

@ -52,7 +52,7 @@ bool pn5180_mifare_read(uint8_t block_id, uint8_t block_data[16]);
bool pn5180_felica_read(uint16_t svc_code, uint16_t block_id, uint8_t block_data[16]);
void pn5180_select();
void pn5180_select(int phase);
void pn5180_deselect();
#endif

View File

@ -468,8 +468,12 @@ bool pn532_felica_write(uint16_t svc_code, uint16_t block_id, const uint8_t bloc
return false;
}
void pn532_select()
void pn532_select(int phase)
{
if (phase != 0) {
return;
}
uint8_t param[] = {0x01};
pn532_write_command(0x54, param, sizeof(param));

View File

@ -35,7 +35,7 @@ bool pn532_mifare_read(uint8_t block_id, uint8_t block_data[16]);
bool pn532_felica_read(uint16_t svc_code, uint16_t block_id, uint8_t block_data[16]);
bool pn532_felica_write(uint16_t svc_code, uint16_t block_id, const uint8_t block_data[16]);
void pn532_select();
void pn532_select(int phase);
void pn532_deselect();
#endif