cun
This commit is contained in:
@ -8,6 +8,8 @@
|
||||
#include "le_client_demo.h"
|
||||
#include "le_common.h"
|
||||
#include "./ble_handler/client_handler.h"
|
||||
#include "./RFID/include/rfid_main.h"
|
||||
#include "./RFID/include/READER_REG.h"
|
||||
// ==================================================================================================================================================================
|
||||
// 宏定义与日志
|
||||
// ==================================================================================================================================================================
|
||||
@ -297,7 +299,12 @@ void contol_key_task(void){
|
||||
}
|
||||
|
||||
g_send_data_to_ble_server(ble_data_buff, sizeof(ble_data_buff));
|
||||
os_time_dly(100); //10ms为单位
|
||||
/*
|
||||
1000
|
||||
700
|
||||
500
|
||||
*/
|
||||
os_time_dly(60); //10ms为单位
|
||||
}
|
||||
}
|
||||
|
||||
@ -397,18 +404,80 @@ void rc_app_main_init(void)
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//test
|
||||
#define TEST_FUNCTION 1
|
||||
|
||||
void g_i2c_scanner_probe(u8* device_addr, u8* found_number)
|
||||
{
|
||||
printf("Starting I2C bus scan...\n");
|
||||
int devices_found = 0;
|
||||
|
||||
// I2C地址范围是 0x08 到 0x77
|
||||
for (uint8_t addr_7bit = 0x00; addr_7bit < 0x7F; addr_7bit++)
|
||||
{
|
||||
// 构建8位的写地址
|
||||
uint8_t write_addr_8bit = (addr_7bit << 1);
|
||||
|
||||
//传入使用的iic句柄编号
|
||||
soft_iic_start(0);
|
||||
|
||||
// 尝试发送写地址,并检查返回值
|
||||
// iic_tx_byte 返回 1 表示收到了 ACK
|
||||
if (soft_iic_tx_byte(0, write_addr_8bit))
|
||||
{
|
||||
printf("=====================================================================\n");
|
||||
printf("I2C device found at 7-bit address: 0x%02X\n", addr_7bit);
|
||||
printf("I2C device found at 8-bit address: 0x%02X\n", write_addr_8bit);
|
||||
printf("=====================================================================\n");
|
||||
devices_found++;
|
||||
}
|
||||
|
||||
//传入使用的iic句柄编号
|
||||
soft_iic_stop(0);
|
||||
mdelay(2); // 短暂延时
|
||||
}
|
||||
|
||||
if (devices_found == 0) {
|
||||
printf("Scan finished. No I2C devices found.\n");
|
||||
} else {
|
||||
printf("Scan finished. Found %d device(s).\n", devices_found);
|
||||
}
|
||||
}
|
||||
|
||||
void test_task(void){
|
||||
|
||||
|
||||
#if TEST_FUNCTION == 1
|
||||
unsigned char reg_data = 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");
|
||||
}
|
||||
|
||||
rfid_delay_ms(10); // 复位后延时
|
||||
|
||||
// 读取芯片版本号,确认通信是否正常
|
||||
GetReg(REG_VERSION, ®_data);
|
||||
rc_log("REG_VERSION = %02X\r\n", reg_data);
|
||||
|
||||
|
||||
u8 device_buff[10];
|
||||
u8 founds = 0;
|
||||
extern void g_i2c_scanner_probe(u8* device_addr, u8* found_number);
|
||||
g_i2c_scanner_probe(device_buff,&founds);
|
||||
|
||||
while(1){
|
||||
u8 uid[UID_LENGTH] = {0};
|
||||
//读id卡
|
||||
TYPE_V_EVENT((char *)uid);
|
||||
// TYPE_A_EVENT((char *)uid);
|
||||
|
||||
os_time_dly(100);
|
||||
os_time_dly(500);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user