[drivers/sensor]disable irq only when the sensor and module sensors are all cloesed.

This commit is contained in:
Fanming 2019-12-17 17:53:16 +08:00
parent 75a3f3dd3a
commit f3ee2dd186
1 changed files with 5 additions and 6 deletions

View File

@ -211,12 +211,6 @@ static rt_err_t rt_sensor_close(rt_device_t dev)
sensor->config.power = RT_SENSOR_POWER_DOWN; sensor->config.power = RT_SENSOR_POWER_DOWN;
} }
/* Sensor disable interrupt */
if (sensor->config.irq_pin.pin != RT_PIN_NONE)
{
rt_pin_irq_enable(sensor->config.irq_pin.pin, RT_FALSE);
}
if (sensor->module != RT_NULL && sensor->info.fifo_max > 0 && sensor->data_buf != RT_NULL) if (sensor->module != RT_NULL && sensor->info.fifo_max > 0 && sensor->data_buf != RT_NULL)
{ {
for (i = 0; i < sensor->module->sen_num; i ++) for (i = 0; i < sensor->module->sen_num; i ++)
@ -235,6 +229,11 @@ static rt_err_t rt_sensor_close(rt_device_t dev)
} }
} }
} }
/* Sensor disable interrupt */
if (sensor->config.irq_pin.pin != RT_PIN_NONE)
{
rt_pin_irq_enable(sensor->config.irq_pin.pin, RT_FALSE);
}
__exit: __exit:
if (sensor->module) if (sensor->module)