Plausibility delay for SDC measurement

This commit is contained in:
Jasper Blanckenburg 2024-07-17 16:42:32 +02:00
parent 02fb39669a
commit a4fd5d26f5
1 changed files with 11 additions and 2 deletions

View File

@ -88,6 +88,16 @@ static void loop_delay() {
}
last_loop = HAL_GetTick();
}
static void update_sdc() {
static int last[2] = {0, 0};
int current = HAL_GPIO_ReadPin(SDC_VOLTAGE_GPIO_Port, SDC_VOLTAGE_Pin) == GPIO_PIN_SET;
if (last[0] == last[1] && last[0] == current) {
sdc_closed = current;
}
last[0] = last[1];
last[1] = current;
}
/* USER CODE END 0 */
/**
@ -138,8 +148,7 @@ int main(void)
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
sdc_closed = HAL_GPIO_ReadPin(SDC_VOLTAGE_GPIO_Port, SDC_VOLTAGE_Pin) ==
GPIO_PIN_SET;
update_sdc();
slaves_check();
shunt_check();