feature: sensor: add set calibration interface for sensor driver.
Add standard sensor interface for setting calibartiion value. Signed-off-by: songnannan <songnannan@xiaomi.com>
This commit is contained in:
parent
bdc157f443
commit
550d2bff32
@ -445,6 +445,18 @@ static int sensor_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SNIOC_SET_CALIBVALUE:
|
||||||
|
{
|
||||||
|
if (lower->ops->set_calibvalue == NULL)
|
||||||
|
{
|
||||||
|
ret = -ENOTSUP;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = lower->ops->set_calibvalue(lower, arg);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case SNIOC_GET_NEVENTBUF:
|
case SNIOC_GET_NEVENTBUF:
|
||||||
{
|
{
|
||||||
*val = lower->buffer_number + lower->batch_number;
|
*val = lower->buffer_number + lower->batch_number;
|
||||||
|
@ -297,4 +297,14 @@
|
|||||||
|
|
||||||
#define SNIOC_SELFTEST _SNIOC(0x0086)
|
#define SNIOC_SELFTEST _SNIOC(0x0086)
|
||||||
|
|
||||||
|
/* Command: SNIOC_SET_CALIBVALUE
|
||||||
|
* Description: Set calibration value for sensor.
|
||||||
|
* Argument: Calibration value for the sensor.
|
||||||
|
* Note: If setting calibvalue failed, a negated errno value is
|
||||||
|
* returned, otherwise, OK is returned.
|
||||||
|
* This cmd is handled by sensor_ops_s::set_calibvalue.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define SNIOC_SET_CALIBVALUE _SNIOC(0x0087)
|
||||||
|
|
||||||
#endif /* __INCLUDE_NUTTX_SENSORS_IOCTL_H */
|
#endif /* __INCLUDE_NUTTX_SENSORS_IOCTL_H */
|
||||||
|
@ -678,6 +678,26 @@ struct sensor_ops_s
|
|||||||
CODE int (*selftest)(FAR struct sensor_lowerhalf_s *lower,
|
CODE int (*selftest)(FAR struct sensor_lowerhalf_s *lower,
|
||||||
unsigned long arg);
|
unsigned long arg);
|
||||||
|
|
||||||
|
/**************************************************************************
|
||||||
|
* Name: set_calibvalue
|
||||||
|
*
|
||||||
|
* The calibration value to be written in or the non-volatile memory of the
|
||||||
|
* sensor or dedicated registers. At each power-on, so that the values read
|
||||||
|
* from the sensor are already corrected. When the device is calibrated,
|
||||||
|
* the absolute accuracy will be better than before.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* lower - The instance of lower half sensor driver.
|
||||||
|
* arg - The parameters associated with calibration value.
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) on success; a negated errno value on failure.
|
||||||
|
*
|
||||||
|
**************************************************************************/
|
||||||
|
|
||||||
|
CODE int (*set_calibvalue)(FAR struct sensor_lowerhalf_s *lower,
|
||||||
|
unsigned long arg);
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
* Name: control
|
* Name: control
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user