|
@@ -6,6 +6,7 @@
|
|
|
* Change Logs:
|
|
|
* Date Author Notes
|
|
|
* 2019-01-31 flybreak first version
|
|
|
+ * 2020-02-22 luhuadong support custom commands
|
|
|
*/
|
|
|
|
|
|
#include "sensor.h"
|
|
@@ -307,7 +308,7 @@ static rt_err_t rt_sensor_control(rt_device_t dev, int cmd, void *args)
|
|
|
case RT_SENSOR_CTRL_GET_ID:
|
|
|
if (args)
|
|
|
{
|
|
|
- sensor->ops->control(sensor, RT_SENSOR_CTRL_GET_ID, args);
|
|
|
+ result = sensor->ops->control(sensor, RT_SENSOR_CTRL_GET_ID, args);
|
|
|
}
|
|
|
break;
|
|
|
case RT_SENSOR_CTRL_GET_INFO:
|
|
@@ -352,7 +353,17 @@ static rt_err_t rt_sensor_control(rt_device_t dev, int cmd, void *args)
|
|
|
result = sensor->ops->control(sensor, RT_SENSOR_CTRL_SELF_TEST, args);
|
|
|
break;
|
|
|
default:
|
|
|
- return -RT_ERROR;
|
|
|
+
|
|
|
+ if (cmd > RT_SENSOR_CTRL_USER_CMD_START)
|
|
|
+ {
|
|
|
+ /* Custom commands */
|
|
|
+ result = sensor->ops->control(sensor, cmd, args);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ result = -RT_ERROR;
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
if (sensor->module)
|