自定义scp与ap数据传输命令

-----欢迎点赞,收藏和关注------

自定义SCP与AP数据传输命令

本文目的与说明

本文章旨在举例说明如何自定义一个数据传输命令,在scp与ap之间。比如,已经实现的命令有enable之类的命令,它们携带的数据大小都有限,一般也就12byte(3个int数据)。

下文举例说明传输一个64byte的数据结构。

sensor框架这方面,1.0和2.0都可以参考本文。

本文在2.0框架下实现,通过命令获取距感信息。

框架图

在这里插入图片描述

AP侧实现

需要从scp获取数据的结构体

struct xjh_sensor_hardware_info_t {
	char chip[16];
	char vendor[16];
	char id[16];
	char more[16];
};

ap侧获取scp数据的接口如下,自定的命令CUST_ACTION_GET_XJH_HARDWARE_INFO是仿照CUST_ACTION_GET_SENSOR_INFO添加的。其中xjhSensorInfo结构体需要自行添加,仿照getInfo结构体添加。xjhHwInfo结构也是需要添加的,仿照sensorInfo结构体添加。代码有删减,只保留说明部分。

//drivers\misc\mediatek\sensor\2.0\mtk_nanohub\mtk_nanohub.c
int mtk_nanohub_set_cmd_to_hub(uint8_t sensor_id,
		enum CUST_ACTION action, void *data)
{
    union SCP_SENSOR_HUB_DATA req;
	int len = 0, err = 0;
	struct SCP_SENSOR_HUB_GET_RAW_DATA *pGetRawData;

	req.get_data_req.sensorType = sensor_id;
	req.get_data_req.action = SENSOR_HUB_SET_CUST;
    switch (sensor_id) {
        case ID_PROXIMITY:
		req.set_cust_req.sensorType = ID_PROXIMITY;
		req.set_cust_req.action = SENSOR_HUB_SET_CUST;
		switch (action) {
            case CUST_ACTION_GET_SENSOR_INFO:
                req.set_cust_req.getInfo.action =
                    CUST_ACTION_GET_SENSOR_INFO;
                len = offsetof(struct SCP_SENSOR_HUB_SET_CUST_REQ,
                    custData) + sizeof(req.set_cust_req.getInfo);
                break;
#ifdef CONFIG_SENSORHUB_XJH_HARDWARE_INFO
            case CUST_ACTION_GET_XJH_HARDWARE_INFO:
                req.set_cust_req.xjhSensorInfo.action =
                    CUST_ACTION_GET_XJH_HARDWARE_INFO;
                len = offsetof(struct SCP_SENSOR_HUB_SET_CUST_REQ,
                    custData) + sizeof(req.set_cust_req.xjhSensorInfo);
                break;
#endif
		default:
			return -1;
		}
    }

    err = mtk_nanohub_req_send(&req);
	if (err < 0) {
		pr_err("set_cust fail!\n");
		return -1;
	}

    switch (action) {
	case CUST_ACTION_GET_SENSOR_INFO:
		if (req.set_cust_rsp.getInfo.action !=
			CUST_ACTION_GET_SENSOR_INFO) {
			pr_info("get_info failed!\n");
			return -1;
		}
		memcpy((struct sensorInfo_t *)data,
			&req.set_cust_rsp.getInfo.sensorInfo,
			sizeof(struct sensorInfo_t));
		break;
#ifdef CONFIG_SENSORHUB_XJH_HARDWARE_INFO
	case CUST_ACTION_GET_XJH_HARDWARE_INFO:
		if (req.set_cust_rsp.xjhSensorInfo.action !=
			CUST_ACTION_GET_XJH_HARDWARE_INFO) {
			pr_info("scp_sensorHub_req_send failed action!\n");
			return -1;
		}
		memcpy((struct xjh_sensor_hardware_info_t *)data,
			&req.set_cust_rsp.xjhSensorInfo.xjhHwInfo,
			sizeof(struct xjh_sensor_hardware_info_t));
break;
#endif	
	default:
		break;
	}
	return err;
}

自定义结构体添加

//drivers\misc\mediatek\sensor\2.0\mtk_nanohub\mtk_nanohub.h
enum CUST_ACTION {
	CUST_ACTION_SET_CUST = 1,
	CUST_ACTION_SET_CALI,
	CUST_ACTION_RESET_CALI,
	CUST_ACTION_SET_TRACE,
	CUST_ACTION_SET_DIRECTION,
	CUST_ACTION_SHOW_REG,
	CUST_ACTION_GET_RAW_DATA,
	CUST_ACTION_SET_PS_THRESHOLD,
	CUST_ACTION_SHOW_ALSLV,
	CUST_ACTION_SHOW_ALSVAL,
	CUST_ACTION_SET_FACTORY,
	CUST_ACTION_GET_SENSOR_INFO,
#ifdef CONFIG_SENSORHUB_XJH_HARDWARE_INFO
	CUST_ACTION_GET_XJH_HARDWARE_INFO,
#endif
};

#ifdef CONFIG_SENSORHUB_XJH_HARDWARE_INFO
struct xjh_sensor_hardware_info_t {
	char chip[16];
	char vendor[16];
	char id[16];
	char more[16];
};

struct scp_sensor_hub_xjh_hardware_info_t {
	enum CUST_ACTION action;
	union {
		int32_t int32_data[0];
		struct xjh_sensor_hardware_info_t cpHwInfo;
	};
};
#endif 

struct SCP_SENSOR_HUB_SET_CUST_REQ {
	uint8_t sensorType;
	uint8_t action;
	uint8_t reserve[2];
	union {
		uint32_t custData[11];
		struct SCP_SENSOR_HUB_CUST cust;
		struct SCP_SENSOR_HUB_SET_CUST setCust;
		struct SCP_SENSOR_HUB_SET_CALI setCali;
		struct SCP_SENSOR_HUB_RESET_CALI resetCali;
		struct SCP_SENSOR_HUB_SET_TRACE setTrace;
		struct SCP_SENSOR_HUB_SET_DIRECTION setDirection;
		struct SCP_SENSOR_HUB_SHOW_REG showReg;
		struct SCP_SENSOR_HUB_GET_RAW_DATA getRawData;
		struct SCP_SENSOR_HUB_SETPS_THRESHOLD setPSThreshold;
		struct SCP_SENSOR_HUB_SHOW_ALSLV showAlslv;
		struct SCP_SENSOR_HUB_SHOW_ALSVAL showAlsval;
		struct SCP_SENSOR_HUB_SET_FACTORY setFactory;
		struct scp_sensor_hub_get_sensor_info getInfo;
#ifdef CONFIG_SENSORHUB_XJH_HARDWARE_INFO
		struct scp_sensor_hub_xjh_hardware_info_t xjhSensorInfo;
#endif
	};
};

struct SCP_SENSOR_HUB_SET_CUST_RSP {
	uint8_t sensorType;
	uint8_t action;
	uint8_t errCode;
	uint8_t reserve[1];
	union {
		uint32_t custData[11];
		struct SCP_SENSOR_HUB_GET_RAW_DATA getRawData;
		struct scp_sensor_hub_get_sensor_info getInfo;
#ifdef CONFIG_SENSORHUB_XJH_HARDWARE_INFO
		struct scp_sensor_hub_xjh_hardware_info_t xjhSensorInfo;
#endif
	};
};

扩充了原有的结构体,有可能会超过数据传输的最大限度。代码要求如下:

  • SENSOR_IPI_SIZE = SCP_SENSOR_HUB_DATA
  • SENSOR_IPI_SIZE = SENSOR_DATA_SIZE - 4
  • SENSOR_DATA_SIZE = struct data_unit_t

注:SENSOR_IPI_SIZE和SENSOR_DATA_SIZE 为宏,SCP_SENSOR_HUB_DATA为共用体。此处的比较为【宏的值】与【结构体的大小】。

SCP_SENSOR_HUB_DATA共用体包含struct SCP_SENSOR_HUB_SET_CUST_RSP结构体,而后者增加了数据,有可能会增加前者的数据大小。这里就不去计算前者中哪个结构最大,直接给出结果:后者在前者中数据最大,后者增加了24byte(68 - 4*11,11来源于SCP_SENSOR_HUB_SET_CUST_REQ结构体成员custData)。

那么就需要增加如下修改:

//drivers\misc\mediatek\sensor\2.0\mtk_nanohub\mtk_nanohub.c
#ifdef CONFIG_SENSORHUB_XJH_HARDWARE_INFO
#define SENSOR_IPI_SIZE 72
#else
#define SENSOR_IPI_SIZE 48
#endif

#ifdef CONFIG_SENSORHUB_XJH_HARDWARE_INFO
#define SENSOR_DATA_SIZE 68
#else
#define SENSOR_DATA_SIZE 44
#endif

//drivers\misc\mediatek\sensor\2.0\mtk_nanohub\mtk_nanohub.h
struct SCP_SENSOR_HUB_REQ {
	uint8_t sensorType;
	uint8_t action;
	uint8_t reserve[2];
#ifdef CONFIG_SENSORHUB_XJH_HARDWARE_INFO
	uint32_t data[17];
#else
 	uint32_t data[11];
#endif
};

struct data_unit_t {
	uint8_t sensor_type;
	uint8_t flush_action;
	uint8_t reserve[2];
	uint64_t time_stamp;
	union {
		...
		struct geofence_event_t geofence_data_t;
		struct sar_event_t sar_event;
#ifdef CONFIG_SENSORHUB_XJH_HARDWARE_INFO
		int32_t data[14];
#else
 		int32_t data[8];
#endif
	};
} __packed;

在2.0代码中没有看到struct SCP_SENSOR_HUB_REQ和struct SCP_SENSOR_HUB_SET_CUST_REQ进行强制转换,所以也可以不对前者做修改,但是scp侧两者是有强制转换的代码,所以这里增加此处修改,可以自行验证。struct data_unit_t结构体做修改是为了和SENSOR_DATA_SIZE保持相等。

SCP侧实现

有了AP侧的一些经验,下面就直接添加结构:

//vendor\mediatek\proprietary\tinysys\scp\middleware\contexthub\contexthub_fw.h
#ifdef CFG_SENSORHUB_XJH_HARDWARE_INFO
#define SENSOR_IPI_SIZE 72
#else
#define SENSOR_IPI_SIZE 48
#endif

#ifdef CFG_SENSORHUB_XJH_HARDWARE_INFO
#define SENSOR_DATA_SIZE 68
#else
#define SENSOR_DATA_SIZE 44
#endif

typedef struct {
    uint8_t    sensorType;
    uint8_t    action;
    uint8_t    event;
    uint8_t    reserve;
#ifdef CFG_SENSORHUB_XJH_HARDWARE_INFO
    uint32_t   data[17];
#else
     uint32_t   data[11];
#endif
} SCP_SENSOR_HUB_REQ;

typedef enum {
    CUST_ACTION_SET_CUST = 1,
	...
    CUST_ACTION_GET_SENSOR_INFO,
#ifdef CFG_SENSORHUB_XJH_HARDWARE_INFO
    CUST_ACTION_GET_XJH_HARDWARE_INFO,
#endif
} CUST_ACTION;

#ifdef CFG_SENSORHUB_XJH_HARDWARE_INFO
struct sensor_hardware_info_t {
	char chip[16];
	char vendor[16];
	char id[16];
	char more[16];
};

typedef struct {
    CUST_ACTION action;
    union {
        int32_t int32_data[0];
        struct sensor_hardware_info_t xjhSensorInfo;
    };
} SCP_SENSOR_HUB_GET_XJH_SENSOR_INFO;
#endif 

typedef struct {
    union {
		...
        SCP_SENSOR_HUB_GET_SENSOR_INFO  getInfo;
#ifdef CFG_SENSORHUB_XJH_HARDWARE_INFO
        SCP_SENSOR_HUB_GET_XJH_SENSOR_INFO getXjhSensorInfo;
#endif 
    };
} CUST_SET_REQ, *CUST_SET_REQ_P;

这些结构和AP侧基本一样的,不做过多说明。

下面在scp源码中搜索CUST_ACTION_GET_SENSOR_INFO宏命令,在下面加入自己的代码:

//vendor\mediatek\proprietary\tinysys\scp\middleware\contexthub\contexthub_fw.c
static int contextHubDispatchCust(uint8_t sensType, uint32_t sequence,
        SCP_SENSOR_HUB_REQ *req)
{
    int ret = 0;
    SCP_SENSOR_HUB_SET_CUST_REQ *set_cust_req = (SCP_SENSOR_HUB_SET_CUST_REQ *)req;
    CUST_SET_REQ_P cust_req = &set_cust_req->cust_set_req;

    switch (cust_req->cust.action) {
        case CUST_ACTION_SET_TRACE:
            ret = sensorCoreSetDebugTrace(sensType, sequence, req, contextHubIpiRxAck);
            break;
        case CUST_ACTION_GET_SENSOR_INFO:
            ret = sensorCoreGetSensorInfo(sensType, sequence, req, contextHubIpiRxAck);
            break;
#ifdef CFG_SENSORHUB_XJH_HARDWARE_INFO
        case CUST_ACTION_GET_XJH_HARDWARE_INFO:
            ret = sensorCoreGetSensorHardwareInfo(sensType, sequence, req, contextHubIpiRxAck);
            break;
#endif
        default:
            ret = -1;
            break;
    }
    return ret;
}

static int contextHubFwSetCustAck(SCP_SENSOR_HUB_REQ *req,
        SCP_SENSOR_HUB_DATA *rsp, void *data, int errCode)
{
    SCP_SENSOR_HUB_SET_CUST_REQ *set_cust_req = (SCP_SENSOR_HUB_SET_CUST_REQ *)req;
    CUST_SET_REQ_P cust_req = &set_cust_req->cust_set_req;

    rsp->set_cust_rsp.sensorType = req->sensorType;
    rsp->set_cust_rsp.action = req->action;
    rsp->rsp.errCode = errCode;

    switch (cust_req->cust.action) {
        case CUST_ACTION_SET_TRACE:
           rsp->set_cust_rsp.cust_set_rsp.setTrace.action =
               set_cust_req->cust_set_req.setTrace.action;
            break;
        case CUST_ACTION_GET_SENSOR_INFO:
            rsp->set_cust_rsp.cust_set_rsp.getInfo.action =
                set_cust_req->cust_set_req.getInfo.action;
            memcpy(&rsp->set_cust_rsp.cust_set_rsp.getInfo.sensorInfo,
                data, sizeof(struct sensorInfo_t));
            break;
#ifdef CFG_SENSORHUB_XJH_HARDWARE_INFO
        case CUST_ACTION_GET_XJH_HARDWARE_INFO:
            rsp->set_cust_rsp.cust_set_rsp.getXjhSensorInfo.action =
                set_cust_req->cust_set_req.getXjhSensorInfo.action;
            memcpy(&rsp->set_cust_rsp.cust_set_rsp.getXjhSensorInfo.xjhSensorInfo,
                data, sizeof(struct sensor_hardware_info_t));
            break;
#endif
        default:
            break;
    }
    return 0;
}

其中sensorCoreGetSensorHardwareInfo函数是需要自行定义的,可以参考sensorCoreGetSensorInfo函数。

//vendor\mediatek\proprietary\tinysys\scp\middleware\contexthub\contexthub_core.c
#ifdef CFG_SENSORHUB_XJH_HARDWARE_INFO
int sensorCoreGetSensorHardwareInfo(uint8_t sensType, uint32_t sequence, SCP_SENSOR_HUB_REQ *req,
        int (*ack)(uint32_t, SCP_SENSOR_HUB_REQ *, void *, int))
{
    struct sensorCoreInfo *mCoreInfo;

    int8_t handle = mSensorCoreList[sensType];

    if (!atomicBitsetGetBit(mSensorCoreUsed, handle))
        return -1;
    mCoreInfo = &mInfoCoreList[handle];

    if (!mCoreInfo->getSensorHardwareInfo)
        return -1;
    mCoreInfo->getSensorHardwareInfo(sequence, req, ack);
    return 0;
}
#endif

上述代码中还需定义struct sensorCoreInfo结构体成员getSensorHardwareInfo,同样可根据成员getSensorInfo来定义。

//vendor\mediatek\proprietary\tinysys\scp\middleware\contexthub\contexthub_core.h
struct sensorCoreInfo {
    uint8_t sensType;
    ...
    void (*getSensorInfo)(uint32_t sequence, SCP_SENSOR_HUB_REQ *req,
        int (*ack)(uint32_t, SCP_SENSOR_HUB_REQ *, void *, int));
#ifdef CFG_SENSORHUB_XJH_HARDWARE_INFO
    void (*getSensorHardwareInfo)(uint32_t sequence, SCP_SENSOR_HUB_REQ *req,
        int (*ack)(uint32_t, SCP_SENSOR_HUB_REQ *, void *, int));
#endif
};

#ifdef CFG_SENSORHUB_XJH_HARDWARE_INFO
int sensorCoreGetSensorHardwareInfo(uint8_t sensType, uint32_t sequence, SCP_SENSOR_HUB_REQ *req,
        int (*ack)(uint32_t, SCP_SENSOR_HUB_REQ *, void *, int));
#endif

定义完后,需要把接口添加到框架中

//\vendor\mediatek\proprietary\tinysys\scp\middleware\contexthub\MEMS_Driver\alsps\alsps.c
static int psInitDone(const uint8_t *data, int size)
{
    struct sensorCoreInfo mInfo;
	...
    /* Register sensor Core */
    mInfo.sensType = SENS_TYPE_PROX;
    mInfo.getData = psGetData;
    mInfo.getSensorInfo = psGetSensorInfo;
    sensorCoreRegister(&mInfo);
#ifdef CFG_SENSORHUB_XJH_HARDWARE_INFO
    mInfo.getSensorHardwareInfo = getSensorHardwareInfo;
#endif
    return 0;
}

#ifdef CFG_SENSORHUB_XJH_HARDWARE_INFO
static void getSensorHardwareInfo(uint32_t sequence, SCP_SENSOR_HUB_REQ *req,
        int (*ack)(uint32_t, SCP_SENSOR_HUB_REQ *, void *, int))
{
    struct broadcast_message *bm = sensor_prepare_event();
    struct factory_param *send = (struct factory_param *)bm->buffer;
    SCP_SENSOR_HUB_SET_CUST_REQ *set_cust_req = (SCP_SENSOR_HUB_SET_CUST_REQ *)req;
    CUST_SET_REQ_P cust_req = &set_cust_req->cust_set_req;

    send->sequence = sequence;
    send->action = req->action;
    send->subaction = cust_req->cust.action;
    send->req = req;
    send->ack = ack;
    sensor_broadcast_event(deputy, bm, SENS_TYPE_PROX, EVENT_FACTORY, sizeof(*send));
}
#endif

static int psFactoryDone(const uint8_t *data, int size)
{
    struct data_unit_t factory_data;
    struct factory_param *recv = (struct factory_param *)data;

    memset(&factory_data, 0, sizeof(factory_data));
    switch (recv->action) {
        case SENSOR_HUB_GET_DATA:
            factory_data.value[0] = recv->data[0];
            recv->ack(recv->sequence, recv->req, &factory_data, 0);
            break;

        case SENSOR_HUB_SET_CUST:
            if (recv->subaction == CUST_ACTION_GET_SENSOR_INFO) {
                recv->ack(recv->sequence, recv->req, recv->data, 0);
            }
#ifdef CFG_SENSORHUB_XJH_HARDWARE_INFO
            if (recv->subaction == CUST_ACTION_GET_XJH_HARDWARE_INFO) {
                recv->ack(recv->sequence, recv->req, (uint32_t *)recv->data[0], 0);
            }
#endif
            break;
        default:
            break;
    }
    return 0;
}

到这里,框架中需要的代码就都添加完成了。后续就是如何在驱动中填写数据。

//vendor\mediatek\proprietary\tinysys\scp\middleware\contexthub\MEMS_Driver\alsps\stk3a5x.c
#ifdef CFG_SENSORHUB_COOLPAD_HARDWARE_INFO
struct sensor_hardware_info_t  stk3a5x_hardware_info;
#endif
static int stk3a5x_ps_factory(const uint8_t *data, int size)
{
    struct factory_param *recv = (struct factory_param *)data;
    struct sensorInfo_t *info;
    struct broadcast_message *bm = NULL;
    struct factory_param *send = NULL;
    osLog(LOG_INFO, "%s[%d]\n", __func__,__LINE__);
    switch (recv->action)
    {
		...
        case SENSOR_HUB_SET_CUST:
            if (recv->subaction == CUST_ACTION_GET_SENSOR_INFO)
            {
                bm = sensor_prepare_event();
                send = (struct factory_param *)bm->buffer;
                memcpy(send, recv, sizeof(*send));
                info = (struct sensorInfo_t*)send->data;
                strncpy(info->name, PS_NAME, sizeof(info->name));
                return sensor_broadcast_event(principal, bm, SENS_TYPE_PROX, EVENT_FACTORY_DONE, sizeof(*send));
            }
#ifdef CFG_SENSORHUB_XJH_HARDWARE_INFO
            if (recv->subaction == CUST_ACTION_GET_XJH_HARDWARE_INFO)
            {
                bm = sensor_prepare_event();
                send = (struct factory_param *)bm->buffer;
                memcpy(send, recv, sizeof(*send));
                send->data[0] = (uint32_t)&stk3a5x_hardware_info;
				strncpy(stk3a5x_hardware_info.chip, "STK33562", sizeof(stk3a5x_hardware_info.chip)-1);
				strncpy(stk3a5x_hardware_info.vendor, "sensortek", sizeof(stk3a5x_hardware_info.vendor)-1);
				snprintf(stk3a5x_hardware_info.id,  sizeof(stk3a5x_hardware_info.id)-1, "%d-%04x", stk3a5x_dev.hw->i2c_num, stk3a5x_dev.i2c_addr);
				strncpy(stk3a5x_hardware_info.more, "ALSPS", sizeof(stk3a5x_hardware_info.more)-1);
                return sensor_broadcast_event(principal, bm, SENS_TYPE_PROX, EVENT_FACTORY_DONE, sizeof(*send));
            }
#endif
            return 0;
        default:
            return 0;
    }
    return 0;
}

这里没有直接使用广播事件传输数据,而是直接传递的数据地址,原因是广播数据的大小限制为64byte,因此需要去做一些修改,这里为了方便,未去做修改。

下面再给出一段1.0框架的修改做参考:

diff --git a/middleware/contexthub/MEMS_Driver/accGyro/icm4n607.c b/middleware/contexthub/MEMS_Driver/accGyro/icm4n607.c
index 1bd0b0d..5b39c01 100755
--- a/middleware/contexthub/MEMS_Driver/accGyro/icm4n607.c
+++ b/middleware/contexthub/MEMS_Driver/accGyro/icm4n607.c
@@ -3777,6 +3777,23 @@ static void accGetSensorInfo(uint32_t sequence, SCP_SENSOR_HUB_REQ *req,
     ack(sequence, req, &info, 0);
 }
 
+#ifdef CFG_SENSORHUB_XJH_HARDWARE_INFO
+static void accgetSensorHardwareInfo(uint32_t sequence, SCP_SENSOR_HUB_REQ *req,
+        int (*ack)(uint32_t, SCP_SENSOR_HUB_REQ *, void *, int))
+{
+    struct sensor_hardware_info_t  acc_hardware_info;
+    memset(&acc_hardware_info, 0, sizeof(acc_hardware_info));
+    
+    strncpy(acc_hardware_info.chip, "ICM-42607-P", sizeof(acc_hardware_info.chip)-1);
+    strncpy(acc_hardware_info.vendor, "TDK invensense", sizeof(acc_hardware_info.vendor)-1);
+    snprintf(acc_hardware_info.id,  sizeof(acc_hardware_info.id)-1, "%d", mTask.hw->i2c_num);
+    strncpy(acc_hardware_info.more, "ACCEL", sizeof(acc_hardware_info.more)-1);
+
+    ack(sequence, req, &acc_hardware_info, 0);
+}
+#endif
+
+
 static void gyroGetSensorInfo(uint32_t sequence, SCP_SENSOR_HUB_REQ *req,
         int (*ack)(uint32_t, SCP_SENSOR_HUB_REQ *, void *, int))
 {
@@ -3788,6 +3805,22 @@ static void gyroGetSensorInfo(uint32_t sequence, SCP_SENSOR_HUB_REQ *req,
     ack(sequence, req, &info, 0);
 }
 
+#ifdef CFG_SENSORHUB_XJH_HARDWARE_INFO
+static void gyrogetSensorHardwareInfo(uint32_t sequence, SCP_SENSOR_HUB_REQ *req,
+        int (*ack)(uint32_t, SCP_SENSOR_HUB_REQ *, void *, int))
+{
+    struct sensor_hardware_info_t  gyro_hardware_info;
+    memset(&gyro_hardware_info, 0, sizeof(gyro_hardware_info));
+    
+    strncpy(gyro_hardware_info.chip, "ICM-42607-P", sizeof(gyro_hardware_info.chip)-1);
+    strncpy(gyro_hardware_info.vendor, "TDK invensense", sizeof(gyro_hardware_info.vendor)-1);
+    snprintf(gyro_hardware_info.id,  sizeof(gyro_hardware_info.id)-1, "%d", mTask.hw->i2c_num);
+    strncpy(gyro_hardware_info.more, "GYRO", sizeof(gyro_hardware_info.more)-1);
+
+    ack(sequence, req, &gyro_hardware_info, 0);
+}
+#endif
+
 static void sensorCoreRegistration(void)
 {
     struct sensorCoreInfo mInfo;
@@ -3804,6 +3837,9 @@ static void sensorCoreRegistration(void)
     mInfo.getData = accGetData;
     mInfo.setDebugTrace = ICM4N607SetDebugTrace;
     mInfo.getSensorInfo = accGetSensorInfo;
+#ifdef CFG_SENSORHUB_XJH_HARDWARE_INFO
+    mInfo.getSensorHardwareInfo = accgetSensorHardwareInfo;
+#endif
     sensorCoreRegister(&mInfo);
 
     memset(&mInfo, 0x00, sizeof(struct sensorCoreInfo));
@@ -3815,6 +3851,9 @@ static void sensorCoreRegistration(void)
    // mInfo.setCalibration = gyroSetCalibration;
     mInfo.getData = gyroGetData;
     mInfo.getSensorInfo = gyroGetSensorInfo;
+#ifdef CFG_SENSORHUB_XJH_HARDWARE_INFO
+    mInfo.getSensorHardwareInfo = gyrogetSensorHardwareInfo;
+#endif
     sensorCoreRegister(&mInfo);
 }

-----欢迎点赞,收藏和关注------

  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值