RPMCapture: refactor to clarify when an interrupt happened

This commit is contained in:
Matthias Grob
2024-12-19 07:30:25 +01:00
parent ec4ed75264
commit c406e0a3a2
2 changed files with 5 additions and 5 deletions
+4 -4
View File
@@ -107,11 +107,11 @@ void RPMCapture::Run()
hrt_abstime now = hrt_absolute_time();
if (!_value_processed.load()) {
if (_interrupt_happened.load()) {
// There was an interrupt
_period = _hrt_timestamp - _hrt_timestamp_prev;
_hrt_timestamp_prev = _hrt_timestamp;
_value_processed.store(true);
_interrupt_happened.store(false);
pwm_input_s pwm_input{};
pwm_input.timestamp = now;
@@ -157,12 +157,12 @@ int RPMCapture::gpio_interrupt_callback(int irq, void *context, void *arg)
{
RPMCapture *instance = static_cast<RPMCapture *>(arg);
if (!instance->_value_processed.load()) {
if (instance->_interrupt_happened.load()) {
++instance->_error_count;
}
instance->_hrt_timestamp = hrt_absolute_time();
instance->_value_processed.store(false);
instance->_interrupt_happened.store(true);
instance->ScheduleNow();
return PX4_OK;
+1 -1
View File
@@ -85,7 +85,7 @@ private:
hrt_abstime _hrt_timestamp_prev{0};
uint32_t _period{UINT32_MAX};
uint32_t _error_count{0};
px4::atomic<bool> _value_processed{true};
px4::atomic<bool> _interrupt_happened{false};
hrt_abstime _timestamp_last_update{0}; ///< to caluclate dt
AlphaFilter<float> _rpm_filter;