cun
This commit is contained in:
@ -213,7 +213,7 @@ void write_gsensor_data_handle(void)
|
||||
}
|
||||
|
||||
// 临时的设备扫描诊断函数
|
||||
void i2c_scanner_probe(void)
|
||||
void i2c_scanner_probe(u8* device_addr, u8* found_number)
|
||||
{
|
||||
printf("Starting I2C bus scan...\n");
|
||||
int devices_found = 0;
|
||||
@ -230,6 +230,7 @@ void i2c_scanner_probe(void)
|
||||
// iic_tx_byte 返回 1 表示收到了 ACK
|
||||
if (iic_tx_byte(gSensor_info->iic_hdl, write_addr_8bit))
|
||||
{
|
||||
device_addr[devices_found] = addr_7bit;
|
||||
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);
|
||||
@ -240,6 +241,7 @@ void i2c_scanner_probe(void)
|
||||
iic_stop(gSensor_info->iic_hdl);
|
||||
delay(gSensor_info->iic_delay); // 短暂延时
|
||||
}
|
||||
*found_number = devices_found;
|
||||
|
||||
if (devices_found == 0) {
|
||||
printf("Scan finished. No I2C devices found.\n");
|
||||
|
||||
@ -291,8 +291,8 @@ void xtell_task_create(void){
|
||||
|
||||
// MPU9250_Mag_Init();
|
||||
//iic总线设备扫描
|
||||
extern void i2c_scanner_probe(void);
|
||||
i2c_scanner_probe();
|
||||
// extern void i2c_scanner_probe(void);
|
||||
// i2c_scanner_probe();
|
||||
|
||||
xlog("xtell_task_create\n");
|
||||
|
||||
|
||||
@ -214,7 +214,13 @@ void le_user_app_event_handler(struct sys_event* event){
|
||||
if(event->u.app.buffer[2] == 0x01){ //后面的数据长度 1
|
||||
switch (event->u.app.buffer[3]){
|
||||
case 0xff: //测试
|
||||
|
||||
u8 device_buff[10];
|
||||
u8 founds = 0;
|
||||
extern void i2c_scanner_probe(u8* device_addr, u8* found_number);
|
||||
i2c_scanner_probe(device_buff,&founds);
|
||||
for(int i = 0;i < founds;i++){
|
||||
send_data_to_ble_client(&device_buff,founds);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user