From 6fd5291aaaaae93b810455094426cfefe3fa51b0 Mon Sep 17 00:00:00 2001 From: Dylan Donahue Date: Wed, 29 Nov 2023 20:49:40 -0500 Subject: [PATCH] added watchdog --- Core/Src/main.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Core/Src/main.c b/Core/Src/main.c index fa44283..457e71f 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -75,6 +75,9 @@ static void MX_USB_OTG_FS_PCD_Init(void); static void MX_I2C1_Init(void); /* USER CODE BEGIN PFP */ +void watchdog_init(void); +void watchdog_pet(void); + /* USER CODE END PFP */ /* Private user code ---------------------------------------------------------*/ @@ -195,6 +198,7 @@ int main(void) /* USER CODE BEGIN Init */ compute_set_fault(0); segment_init(); + watchdog_init(); /* USER CODE END Init */ /* Configure the system clock */ @@ -241,7 +245,9 @@ int main(void) #ifdef DEBUG_STATS print_bms_stats(analyzer.bmsdata); #endif - //delay(10); // not sure if we need this in, it was in before + + /* pet the watchdog */ + watchdog_pet(); } /* USER CODE END WHILE */ @@ -690,6 +696,18 @@ static void MX_GPIO_Init(void) /* USER CODE BEGIN 4 */ +void watchdog_init(void) +{ + HAL_GPIO_WritePin(Watchdog_Out_GPIO_Port, Watchdog_Out_Pin, GPIO_PIN_SET); +} +void watchdog_pet(void) +{ + //second iteration maybe redundant, datasheet unclear so we pet twice + HAL_GPIO_WritePin(Watchdog_Out_GPIO_Port, Watchdog_Out_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(Watchdog_Out_GPIO_Port, Watchdog_Out_Pin, GPIO_PIN_SET); + HAL_GPIO_WritePin(Watchdog_Out_GPIO_Port, Watchdog_Out_Pin, GPIO_PIN_RESET); + HAL_GPIO_WritePin(Watchdog_Out_GPIO_Port, Watchdog_Out_Pin, GPIO_PIN_SET); +} /* USER CODE END 4 */ /**