This commit is contained in:
lmx
2025-12-18 18:33:00 +08:00
parent 8775ec8b1a
commit 3fa235d3c2
10 changed files with 100 additions and 19 deletions

View File

@ -34,7 +34,7 @@
/*软件IIC设置*/ //xtell
#define TCFG_SW_I2C0_CLK_PORT IO_PORTA_05//IO_PORTB_04 //软件IIC CLK脚选择 XTELL
#define TCFG_SW_I2C0_DAT_PORT IO_PORTA_06//IO_PORTB_05 //软件IIC DAT脚选择
#define TCFG_SW_I2C0_DELAY_CNT 0 //IIC延时参数影响通讯时钟频率
#define TCFG_SW_I2C0_DELAY_CNT 10 //IIC延时参数影响通讯时钟频率
/*硬件IIC端口选择 -- 具体看手册,这里写的不准 -- lmx
SCL SDA

View File

@ -67,15 +67,18 @@ unsigned char GetReg(unsigned char address, unsigned char *reg_data){
soft_iic_start(0);
if (0 == soft_iic_tx_byte(0, FM176_WRITE_ADDR)) {
soft_iic_stop(0);
xlog("GetReg: 【write】 addr write error\n");
return FAIL;
}
if (0 == soft_iic_tx_byte(0, address)) {
soft_iic_stop(0);
xlog("GetReg: 【reg】 addr write error\n");
return FAIL;
}
soft_iic_start(0);
if (0 == soft_iic_tx_byte(0, FM176_READ_ADDR)) {
soft_iic_stop(0);
xlog("GetReg: 【read】 addr read error\n");
return FAIL;
}
*reg_data = soft_iic_rx_byte(0, 0);
@ -96,14 +99,17 @@ unsigned char SetReg(unsigned char address, unsigned char reg_data){
soft_iic_start(0);
if (0 == soft_iic_tx_byte(0, FM176_WRITE_ADDR)) {
soft_iic_stop(0);
xlog("SetReg: 【write】 addr write error\n");
return FAIL;
}
if (0 == soft_iic_tx_byte(0, address)) {
soft_iic_stop(0);
xlog("SetReg: 【reg】 addr write error\n");
return FAIL;
}
if (0 == soft_iic_tx_byte(0, reg_data)) {
soft_iic_stop(0);
xlog("SetReg: 【reg】 data write error\n");
return FAIL;
}
soft_iic_stop(0);
@ -216,5 +222,5 @@ unsigned char FM176XX_SoftReset(void){
void rfid_delay_ms(unsigned int ms){
// delay(ms);
os_time_dly(ms/10);
mdelay(ms);
}

View File

@ -39,12 +39,12 @@
// 是否使能测试盒 BLE Master 测试功能 (通常用于产线测试)
#define SUPPORT_TEST_BOX_BLE_MASTER_TEST_EN 0
// 是否显示 RX (接收) 数据速率
#define SHOW_RX_DATA_RATE 1
#define SHOW_RX_DATA_RATE 0
// 是否显示 TX (发送) 数据速率
#define SHOW_TX_DATA_RATE 1
#define SHOW_TX_DATA_RATE 0
//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]"
@ -304,7 +304,7 @@ static void default_report_data_deal(att_data_report_t *report_data, target_uuid
// 默认要匹配的远程设备名称 1
static const u8 test_remoter_name1[] = "X100ABCDE";
// static const u8 test_remoter_name1[] = "AC637N_MX(BLE)"; // 备选名称
static const u8 test_remoter_name2[] = "X100_FENG";
// static const u8 test_remoter_name2[] = "AC630N_HID567(BLE)"; //备选名称
// 默认的 Client 写操作使用的 Characteristic Handle
@ -323,7 +323,7 @@ static const client_match_cfg_t match_dev01 = {
.bonding_flag = 0,
};
/*
// 默认的设备匹配配置 02
static const client_match_cfg_t match_dev02 = {
.create_conn_mode = BIT(CLI_CREAT_BY_NAME),
@ -331,7 +331,7 @@ static const client_match_cfg_t match_dev02 = {
.compare_data = test_remoter_name2,
.bonding_flag = 1, // 需要绑定
};
*/
@ -383,9 +383,8 @@ static void default_event_callback(le_client_event_e event, u8 *packet, int size
static const client_conn_cfg_t client_conn_config_default = {
// 配置要匹配的设备,最多支持 CLIENT_MATCH_CONN_MAX 个配置
.match_dev_cfg[0] = &match_dev01, // 使用 match_dev01 配置
.match_dev_cfg[1] = NULL, // 备用匹配配置 1
.match_dev_cfg[1] = &match_dev02, // 备用匹配配置 1
.match_dev_cfg[2] = NULL, // 备用匹配配置 2
/* .match_dev_cfg[1] = &match_dev02, */ // 注释掉的备用配置
// 数据报告回调函数
.report_data_callback = default_report_data_deal,
// 要搜索的 UUID 数量

View File

@ -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, &reg_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
}

View File

@ -139,5 +139,5 @@ void xtell_app_main()
extern void test_func_main(void);
// test_func_main();
test_func_main();
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -5178,11 +5178,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
@ -5204,15 +5201,16 @@ 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
@ -5361,7 +5359,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,os_time_dly,l
-r=objs/apps/earphone/xtell_remote_control/RFID/rfid_hal.c.o,mdelay,l
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
@ -5392,7 +5390,15 @@ objs/apps/earphone/xtell_remote_control/task_func.c.o
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,os_task_del,l
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,rc_app_main_init,pl
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,FM176XX_HardInit,l
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,g_i2c_scanner_probe,pl
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,soft_iic_start,l
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,soft_iic_tx_byte,l
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,soft_iic_stop,l
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,mdelay,l
-r=objs/apps/earphone/xtell_remote_control/task_func.c.o,test_task,pl
-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,puts,l
@ -5412,6 +5418,7 @@ objs/apps/earphone/xtell_remote_control/xtell_app_main.c.o
-r=objs/apps/earphone/xtell_remote_control/xtell_app_main.c.o,start_app,l
-r=objs/apps/earphone/xtell_remote_control/xtell_app_main.c.o,check_power_on_voltage,l
-r=objs/apps/earphone/xtell_remote_control/xtell_app_main.c.o,rcsp_adv_fill_mac_addr,l
-r=objs/apps/earphone/xtell_remote_control/xtell_app_main.c.o,test_func_main,l
-r=objs/apps/earphone/xtell_remote_control/xtell_app_main.c.o,cpu_reset_by_soft,l
-r=objs/apps/earphone/xtell_remote_control/xtell_app_main.c.o,xt_bt_new_name,pl
-r=objs/apps/earphone/xtell_remote_control/xtell_app_main.c.o,app_var,l