测试:type A卡 读取代码没问题

This commit is contained in:
lmx
2025-12-22 15:40:19 +08:00
parent 482767064e
commit fe0348bd89
14 changed files with 55 additions and 30 deletions

View File

@ -94,6 +94,7 @@
#define REG_VERSION 0x7F
#define CMD_MASK 0x1F
// #define CMD_MASK 0x0F
#define CMD_IDLE 0x00
#define CMD_LPCD 0x01

View File

@ -21,7 +21,7 @@ struct CPU_CARD_STR CPU_CARD;
static unsigned char FM176XX_TPDU(transmission_struct *tpdu);
/**
* @brief CPU卡事件处理函数(示例)
* @brief CPU卡事件处理函数。
* @details
* 1. 发送RATS (Request for Answer to Select) 命令以激活卡片并获取ATS (Answer to Select)。
* 2. 解析ATS获取卡片能力信息如FSC, FWI等

View File

@ -67,9 +67,9 @@ void Mifare_Clear_Crypto(void)
}
/**
* @brief Mifare卡事件处理函数(示例)
* @brief Mifare卡事件处理函数。
* @details
* 这是一个示例函数,演示了对Mifare Classic卡进行读写操作的完整流程
* Mifare Classic卡进行读写操作的完整流程
* 1. 清除加密状态。
* 2. 对指定的扇区例如扇区1使用密钥A进行认证。
* 3. 如果认证成功则遍历该扇区的数据块块0到块2

View File

@ -19,9 +19,9 @@
unsigned char PAGE_DATA[16];
/**
* @brief NTAG卡事件处理函数(示例)
* @brief NTAG卡事件处理函数。
* @details
* 这是一个示例函数,演示了对NTAG系列卡片进行读写操作的流程
* 对NTAG系列卡片进行读写操作的流程
* 1. 准备要写入的数据4字节
* 2. 调用 `Write_Page()` 函数将数据写入第8页。
* 3. 调用 `Read_Page()` 函数从第8页读回数据并打印以进行验证。

View File

@ -591,7 +591,7 @@ unsigned char ReaderB_Get_SN(struct picc_b_struct *picc_b)
return SUCCESS;
}
extern void debug_command(u8 index);
/**
* @brief 向Type V (ISO15693) 卡片发送Inventory命令。
* @param picc_v [out] 指向存储卡片信息的结构体。
@ -600,8 +600,14 @@ unsigned char ReaderB_Get_SN(struct picc_b_struct *picc_b)
unsigned char ReaderV_Inventory(struct picc_v_struct *picc_v)
{
unsigned char reg_data, i, result; // 新增 result 变量
SetCommand(CMD_IDLE);
unsigned char command = 0;
// debug_command(0);
SetCommand(CMD_IDLE);
//对于command可以在发送第二条指令之前读取一次command寄存器判断是否回到idle再发送第二条,这里直接采用长延迟
rfid_delay_ms(100);
// debug_command(1);
SetReg(REG_TXDATANUM, 0x08);
ModifyReg(REG_FIFOCONTROL, BIT_FIFOFLUSH, FUN_ENABLE);
@ -613,7 +619,8 @@ unsigned char ReaderV_Inventory(struct picc_v_struct *picc_v)
ModifyReg(REG_RXCRCCON, BIT_CRCEN, FUN_ENABLE);
SetCommand(CMD_TRANSCEIVE);
rfid_delay_ms(50);
// debug_command(2);
rfid_delay_ms(100);
GetReg(REG_ERROR, &reg_data);
if ((reg_data & 0x0F) != 0){
@ -623,6 +630,7 @@ unsigned char ReaderV_Inventory(struct picc_v_struct *picc_v)
GetReg(REG_FIFOLENGTH, &reg_data);
if (reg_data != 10){
// debug_command(3);
xlog("FIFO Length is %d, expected 10.\n", reg_data);
return FAIL;
}

View File

@ -82,8 +82,9 @@ void TYPE_A_EVENT(char* uid)
}
xlog("-> SAK = %02X\r\n", PICC_A.SAK[0]);
// 根据SAK值判断卡片类型
if (PICC_A.SAK[0] == 0x08)
// 根据SAK值判断卡片类型并进行写入要存储的数据目前客户使用的是mifare的卡
#if 0
if (PICC_A.SAK[0] == 0x08) //
{
xlog("************* Mifare CARD ************* \r\n");
result = MIFARE_CARD_EVENT();
@ -98,6 +99,7 @@ void TYPE_A_EVENT(char* uid)
xlog("************* NTAG CARD ************* \r\n");
result = NTAG_EVENT();
}
#endif
SetCW(FUN_DISABLE); // 关闭RF场
}

View File

@ -130,6 +130,13 @@ unsigned char SetReg(unsigned char address, unsigned char reg_data){
*/
unsigned char FM176XX_SoftReset(void){
return SetReg(REG_COMMAND, 0x1F);
//
// gpio_set_direction(IO_PORTC_04, 0);
// gpio_write(IO_PORTC_04, 1);
// mdelay(5);
// gpio_write(IO_PORTC_04, 0);
}
#elif INTERFACE_TYPE == 1 //spi
@ -230,3 +237,12 @@ void rfid_delay_ms(unsigned int ms){
// delay(ms);
mdelay(ms);
}
void debug_command(u8 index){
unsigned char reg_data;
unsigned char command = 0;
GetReg(REG_ERROR, &reg_data);
GetReg(REG_COMMAND, &command);
xlog("debug %d -- REG_ERROR = 0x%02X. command = 0x%02X\n",index, reg_data, command);
}

View File

@ -44,7 +44,7 @@
#define SHOW_TX_DATA_RATE 1
//log显示
#define client_log 1
#define client_log 0
#if client_log == 1
/* #define log_info printf */
#define log_info(x, ...) printf("[LE_CLIENT]" x "\n", ## __VA_ARGS__) // 格式化打印日志信息,添加前缀 "[LE_CLIENT]"

View File

@ -448,17 +448,18 @@ void test_task(void){
#if TEST_FUNCTION == 1
unsigned char reg_data = 0;
unsigned char command = 0;
FM176XX_HardInit();
rfid_delay_ms(5); // 硬件初始化后增加一个短暂延时,确保芯片稳定
int result = FM176XX_SoftReset();
if (result != SUCCESS)
{
rc_log("FM176XX HardReset FAIL\r\n");
}
else
{
rc_log("FM176XX HardReset SUCCESS\r\n");
}
// if (result != SUCCESS)
// {
// rc_log("FM176XX HardReset FAIL\r\n");
// }
// else
// {
// rc_log("FM176XX HardReset SUCCESS\r\n");
// }
rfid_delay_ms(10); // 复位后延时
@ -475,9 +476,8 @@ void test_task(void){
while(1){
u8 uid[UID_LENGTH] = {0};
//读id卡
TYPE_V_EVENT((char *)uid);
// TYPE_A_EVENT((char *)uid);
// TYPE_V_EVENT((char *)uid);
TYPE_A_EVENT((char *)uid);
os_time_dly(500);
}
#endif
@ -485,9 +485,9 @@ void test_task(void){
void test_func_main(void){
#if TEST_FUNCTION == 1
// os_task_create(test_task, NULL, 1, 1024, 128, "rfid_test");
os_task_create(test_task, NULL, 1, 1024, 128, "rfid_test");
extern void pwm_test_main(void);
os_task_create(pwm_test_main, NULL, 1, 1024, 128, "pwm_test");
// os_task_create(pwm_test_main, NULL, 1, 1024, 128, "pwm_test"); //pwm测试
// os_task_create(contol_key_task, NULL, 1, 2048, 128, control_key_task_name);
#endif

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -5174,11 +5174,8 @@ objs/apps/earphone/xtell_remote_control/ble_handler/ble_handler.c.o
objs/apps/earphone/xtell_remote_control/ble_handler/ble_test.c.o
objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,clear_bonding_info,pl
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,printf,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,l2cap_connection_update_request_just,pl
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,little_endian_read_16,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,user_client_report_search_result,pl
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,put_buf,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,user_client_report_data_callback,pl
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,ble_get_client_operation_table,pl
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,ble_profile_init,pl
@ -5200,15 +5197,17 @@ objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,swapX,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,bt_get_mac_addr,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,g_send_data_to_ble_server,pl
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,printf,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,syscfg_read,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,syscfg_write,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,memcmp,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,create_key_detect_thread,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,destroy_key_detect_thread,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,little_endian_read_16,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,put_buf,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,user_client_init,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,user_client_set_search_complete,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,sys_timer_add,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,ble_vendor_get_peer_rssi,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,puts,l
-r=objs/apps/earphone/xtell_remote_control/ble_handler/client_handler.c.o,client_user_target,pl
objs/apps/earphone/xtell_remote_control/ble_handler/example/example.c.o
@ -5370,6 +5369,7 @@ objs/apps/earphone/xtell_remote_control/RFID/rfid_hal.c.o
-r=objs/apps/earphone/xtell_remote_control/RFID/rfid_hal.c.o,SetReg,pl
-r=objs/apps/earphone/xtell_remote_control/RFID/rfid_hal.c.o,FM176XX_SoftReset,pl
-r=objs/apps/earphone/xtell_remote_control/RFID/rfid_hal.c.o,rfid_delay_ms,pl
-r=objs/apps/earphone/xtell_remote_control/RFID/rfid_hal.c.o,debug_command,pl
objs/apps/earphone/xtell_remote_control/task_func.c.o
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,rc_rfid_callback_handler,pl
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,TYPE_A_EVENT,l
@ -5409,9 +5409,7 @@ objs/apps/earphone/xtell_remote_control/task_func.c.o
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,rfid_delay_ms,l
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,FM176XX_SoftReset,l
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,GetReg,l
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,TYPE_V_EVENT,l
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,test_func_main,pl
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,pwm_test_main,l
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,puts,l
objs/apps/earphone/xtell_remote_control/xtell_app_main.c.o
-r=objs/apps/earphone/xtell_remote_control/xtell_app_main.c.o,create_process,pl