Skip to content

Commit 82f981d

Browse files
committed
[Sensor] Support custom commands for rt_sensor_control
1 parent 5482794 commit 82f981d

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

components/drivers/sensors/sensor.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ static rt_err_t rt_sensor_control(rt_device_t dev, int cmd, void *args)
307307
case RT_SENSOR_CTRL_GET_ID:
308308
if (args)
309309
{
310-
sensor->ops->control(sensor, RT_SENSOR_CTRL_GET_ID, args);
310+
result = sensor->ops->control(sensor, RT_SENSOR_CTRL_GET_ID, args);
311311
}
312312
break;
313313
case RT_SENSOR_CTRL_GET_INFO:
@@ -352,7 +352,10 @@ static rt_err_t rt_sensor_control(rt_device_t dev, int cmd, void *args)
352352
result = sensor->ops->control(sensor, RT_SENSOR_CTRL_SELF_TEST, args);
353353
break;
354354
default:
355-
return -RT_ERROR;
355+
356+
/* Custom commands */
357+
result = sensor->ops->control(sensor, cmd, args);
358+
break;
356359
}
357360

358361
if (sensor->module)

0 commit comments

Comments
 (0)