Skip to content

Commit

Permalink
Fix stall bug conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
elmot committed Mar 19, 2024
1 parent 8cc4879 commit 71e0fd4
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions main/sensors.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,19 @@ static volatile bool speed_phase = 0;
static volatile uint32_t speed_tick_counter = 0;
static volatile gptimer_handle_t speed_gptimer_handle = 0;

// ReSharper disable once CppDFAConstantFunctionResult
static bool IRAM_ATTR wind_speed_callback(__unused struct gptimer_t* gptimer,__unused const gptimer_alarm_event_data_t* eventData,__unused void* user_data)
{
speed_tick_counter++;
if (speed_tick_counter < CONFIG_SPEED_SENSOR_DEBOUNCE_MS) return false;
if (speed_tick_counter >= WIND_STALL_MS)
bool level = gpio_get_level(CONFIG_SPEED_SENSOR_GPIO);
if ((speed_tick_counter >= WIND_STALL_MS) && (level == speed_phase))
{
wind_speed_info.wind_ticks = -1;
wind_speed_info.wind = 0.0f;
//avoid potential overflow
speed_tick_counter = WIND_STALL_MS + 1;
return false;
}
bool level = gpio_get_level(CONFIG_SPEED_SENSOR_GPIO);
if (level == 1)
{
speed_phase = 1;
Expand Down

0 comments on commit 71e0fd4

Please sign in to comment.