mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-02-06 22:04:34 +08:00
[Sensor] Add user-commands range limitation
This commit is contained in:
parent
815d231f4a
commit
7c4e70b3b3
@ -354,8 +354,15 @@ static rt_err_t rt_sensor_control(rt_device_t dev, int cmd, void *args)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
||||||
/* Custom commands */
|
if (cmd > RT_SENSOR_CTRL_USER_CMD_START)
|
||||||
result = sensor->ops->control(sensor, cmd, args);
|
{
|
||||||
|
/* Custom commands */
|
||||||
|
result = sensor->ops->control(sensor, cmd, args);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
result = -RT_ERROR;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,6 +111,8 @@ extern "C" {
|
|||||||
#define RT_SENSOR_CTRL_SET_POWER (5) /* Set power mode. args type of sensor power mode. ex. RT_SENSOR_POWER_DOWN,RT_SENSOR_POWER_NORMAL */
|
#define RT_SENSOR_CTRL_SET_POWER (5) /* Set power mode. args type of sensor power mode. ex. RT_SENSOR_POWER_DOWN,RT_SENSOR_POWER_NORMAL */
|
||||||
#define RT_SENSOR_CTRL_SELF_TEST (6) /* Take a self test */
|
#define RT_SENSOR_CTRL_SELF_TEST (6) /* Take a self test */
|
||||||
|
|
||||||
|
#define RT_SENSOR_CTRL_USER_CMD_START 0x100 /* User commands should be greater than 0x100 */
|
||||||
|
|
||||||
struct rt_sensor_info
|
struct rt_sensor_info
|
||||||
{
|
{
|
||||||
rt_uint8_t type; /* The sensor type */
|
rt_uint8_t type; /* The sensor type */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user