Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added watchdog #63

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm gonna trust you on writing to it twice lol. My only concern is that there isn't a delay so it might be too fast for the watchdog to see, but I think its an issue that we will have to address when putting it on hardware

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