NTSTATUS
SensorPower(PDEVICE_CONTEXT SensorCtx, BOOLEAN OnOff)
{
NTSTATUS status = STATUS_SUCCESS;
ULONG dwTimeSlice = 0;
LARGE_INTEGER nCount[2] = {0};
dwTimeSlice = KeQueryTimeIncrement();
if (SensorCtx->SKU.crd == CRD_PMIC)
{
DoTraceMessage(FLAG_ERROR, "%s SensorPower Pmic",DEVICE_NAME);
if (SensorCtx->PmicInterface)
{
SENSOR_CONF conf;
conf.bSetConf = FALSE;
conf.Pld = PANEL_BACK;
if (OnOff)
{
KeQueryTickCount(&nCount[0]);
status = SensorCtx->PmicInterface->SensorOn(SensorCtx->PmicInterface->InterfaceHeader.Context, conf);
KeQueryTickCount(&nCount[1]);
}
else
{
KeQueryTickCount(&nCount[0]);
status = SensorCtx->PmicInterface->SensorOff(SensorCtx->PmicInterface->InterfaceHeader.Context, conf);
KeQueryTickCount(&nCount[1]);
}
DoTraceMessage(FLAG_LOG, "%s power %s, (time elapse %f ms)\n", DEVICE_NAME, OnOff? "On":"Off",
(float)((nCount[1].QuadPart - nCount[0].QuadPart) * dwTimeSlice ) / 10000);
}
else
{
status = STATUS_UNSUCCESSFUL;
}
}
else
{
status = STATUS_BAD_DEVICE_TYPE;
}
if (!CHECK_STATUS_SUCCESS(status))
{
DoTraceMessage(FLAG_ERROR, "%s power on/off fail, (status 0x%x)\n", DEVICE_NAME, status);
}
return status;
}
测试代码,有点问题,off 时得不到时间 <---