drivers: sensors: npcx_tach: Clear stale data
The tachometer collects the data continuously setting a "data ready" bit when it's ready. The availability bit has to be cleared before the register is updated. The driver also supports underflow detection, when the bit indicating it is set the reading of "0" is returned. The problem here is that there is that once the underflow bit is cleared we might end up reading stale data. To prevent that clear the "data ready" bit when underflow is detected Signed-off-by: Kornel Dulęba <mindal@semihalf.com>
This commit is contained in:
parent
2b607733e6
commit
057888836e
1 changed files with 2 additions and 0 deletions
|
@ -259,6 +259,8 @@ int tach_npcx_sample_fetch(const struct device *dev, enum sensor_channel chan)
|
|||
if (tach_npcx_is_underflow(dev)) {
|
||||
/* Clear pending flags */
|
||||
tach_npcx_clear_underflow_flag(dev);
|
||||
/* Clear stale captured data */
|
||||
tach_npcx_clear_captured_flag(dev);
|
||||
data->capture = 0;
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue