Skip to content

Commit

Permalink
Fix: AMB iwdg (#128)
Browse files Browse the repository at this point in the history
* Fixed amb build errors. Added iwdg.

* removed startup folder in amb
  • Loading branch information
kcgroulx authored Jun 15, 2024
1 parent 119dcea commit 5873aa0
Show file tree
Hide file tree
Showing 9 changed files with 915 additions and 482 deletions.
52 changes: 52 additions & 0 deletions components/amb/Core/Inc/iwdg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file iwdg.h
* @brief This file contains all the function prototypes for
* the iwdg.c file
******************************************************************************
* @attention
*
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __IWDG_H__
#define __IWDG_H__

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "main.h"

/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

extern IWDG_HandleTypeDef hiwdg;

/* USER CODE BEGIN Private defines */

/* USER CODE END Private defines */

void MX_IWDG_Init(void);

/* USER CODE BEGIN Prototypes */

/* USER CODE END Prototypes */

#ifdef __cplusplus
}
#endif

#endif /* __IWDG_H__ */

2 changes: 1 addition & 1 deletion components/amb/Core/Inc/stm32f1xx_hal_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
/*#define HAL_I2C_MODULE_ENABLED */
/*#define HAL_I2S_MODULE_ENABLED */
/*#define HAL_IRDA_MODULE_ENABLED */
/*#define HAL_IWDG_MODULE_ENABLED */
#define HAL_IWDG_MODULE_ENABLED
/*#define HAL_NOR_MODULE_ENABLED */
/*#define HAL_NAND_MODULE_ENABLED */
/*#define HAL_PCCARD_MODULE_ENABLED */
Expand Down
57 changes: 57 additions & 0 deletions components/amb/Core/Src/iwdg.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file iwdg.c
* @brief This file provides code for the configuration
* of the IWDG instances.
******************************************************************************
* @attention
*
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "iwdg.h"

/* USER CODE BEGIN 0 */

/* USER CODE END 0 */

IWDG_HandleTypeDef hiwdg;

/* IWDG init function */
void MX_IWDG_Init(void)
{

/* USER CODE BEGIN IWDG_Init 0 */
#ifdef DEBUG
return; // Skip IWDG initialization in debug mode
#endif
/* USER CODE END IWDG_Init 0 */

/* USER CODE BEGIN IWDG_Init 1 */

/* USER CODE END IWDG_Init 1 */
hiwdg.Instance = IWDG;
hiwdg.Init.Prescaler = IWDG_PRESCALER_8;
hiwdg.Init.Reload = 4095;
if (HAL_IWDG_Init(&hiwdg) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN IWDG_Init 2 */

/* USER CODE END IWDG_Init 2 */

}

/* USER CODE BEGIN 1 */

/* USER CODE END 1 */
4 changes: 3 additions & 1 deletion components/amb/Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,11 @@ int main(void)

/* USER CODE BEGIN 3 */

// Only refresh watchdog when not in debug mode
#ifndef DEBUG
/*Set the watchdog timer, refer to https://controllerstech.com/iwdg-and-wwdg-in-stm32/ */
HAL_IWDG_Refresh(&hiwdg);

#endif
/* Read ADC, process, then output to CANbus */

/* VSENSE1 */
Expand Down
Loading

0 comments on commit 5873aa0

Please sign in to comment.