Skip to content

Commit

Permalink
added watchdog
Browse files Browse the repository at this point in the history
  • Loading branch information
Dylan Donahue committed Nov 30, 2023
1 parent 20f0843 commit 6fd5291
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ---------------------------------------------------------*/
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */

Expand Down Expand Up @@ -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 */

/**
Expand Down

0 comments on commit 6fd5291

Please sign in to comment.