Added watchdog
This commit is contained in:
		| @@ -1,5 +1,5 @@ | |||||||
| [PreviousLibFiles] | [PreviousLibFiles] | ||||||
| LibFiles=Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_gpio.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_i2c.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_dma.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_bus.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_cortex.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_rcc.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_system.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_utils.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_exti.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_pwr.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_crs.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_tim.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_usart.h;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_gpio.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_i2c.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_dma.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_rcc.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_utils.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_exti.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_pwr.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_tim.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_usart.c;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_gpio.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_i2c.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_dma.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_bus.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_cortex.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_rcc.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_system.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_utils.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_exti.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_pwr.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_crs.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_tim.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_usart.h;Drivers/CMSIS/Device/ST/STM32L0xx/Include/stm32l031xx.h;Drivers/CMSIS/Device/ST/STM32L0xx/Include/stm32l0xx.h;Drivers/CMSIS/Device/ST/STM32L0xx/Include/system_stm32l0xx.h;Drivers/CMSIS/Device/ST/STM32L0xx/Source/Templates/system_stm32l0xx.c;Drivers/CMSIS/Include/core_armv8mbl.h;Drivers/CMSIS/Include/cmsis_version.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_cm23.h;Drivers/CMSIS/Include/core_armv8mml.h;Drivers/CMSIS/Include/cmsis_compiler.h;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Include/cmsis_iccarm.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_cm33.h;Drivers/CMSIS/Include/cmsis_armclang.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm1.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/tz_context.h;Drivers/CMSIS/Include/mpu_armv8.h;Drivers/CMSIS/Include/mpu_armv7.h; | LibFiles=Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_gpio.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_i2c.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_dma.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_bus.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_cortex.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_rcc.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_system.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_utils.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_exti.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_pwr.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_crs.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_iwdg.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_tim.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_usart.h;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_gpio.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_i2c.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_dma.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_rcc.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_utils.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_exti.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_pwr.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_tim.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_usart.c;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_gpio.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_i2c.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_dma.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_bus.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_cortex.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_rcc.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_system.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_utils.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_exti.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_pwr.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_crs.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_iwdg.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_tim.h;Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_usart.h;Drivers/CMSIS/Device/ST/STM32L0xx/Include/stm32l031xx.h;Drivers/CMSIS/Device/ST/STM32L0xx/Include/stm32l0xx.h;Drivers/CMSIS/Device/ST/STM32L0xx/Include/system_stm32l0xx.h;Drivers/CMSIS/Device/ST/STM32L0xx/Source/Templates/system_stm32l0xx.c;Drivers/CMSIS/Include/core_armv8mbl.h;Drivers/CMSIS/Include/cmsis_version.h;Drivers/CMSIS/Include/core_cm0plus.h;Drivers/CMSIS/Include/core_sc000.h;Drivers/CMSIS/Include/core_cm23.h;Drivers/CMSIS/Include/core_armv8mml.h;Drivers/CMSIS/Include/cmsis_compiler.h;Drivers/CMSIS/Include/core_sc300.h;Drivers/CMSIS/Include/cmsis_iccarm.h;Drivers/CMSIS/Include/core_cm7.h;Drivers/CMSIS/Include/core_cm33.h;Drivers/CMSIS/Include/cmsis_armclang.h;Drivers/CMSIS/Include/cmsis_armcc.h;Drivers/CMSIS/Include/cmsis_gcc.h;Drivers/CMSIS/Include/core_cm3.h;Drivers/CMSIS/Include/core_cm1.h;Drivers/CMSIS/Include/core_cm0.h;Drivers/CMSIS/Include/core_cm4.h;Drivers/CMSIS/Include/tz_context.h;Drivers/CMSIS/Include/mpu_armv8.h;Drivers/CMSIS/Include/mpu_armv7.h; | ||||||
|  |  | ||||||
| [PreviousUsedCubeIDEFiles] | [PreviousUsedCubeIDEFiles] | ||||||
| SourceFiles=Core/Src/main.c;Core/Src/stm32l0xx_it.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_gpio.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_i2c.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_dma.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_rcc.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_utils.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_exti.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_pwr.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_tim.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_usart.c;Drivers/CMSIS/Device/ST/STM32L0xx/Source/Templates/system_stm32l0xx.c;Core/Src/system_stm32l0xx.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_gpio.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_i2c.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_dma.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_rcc.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_utils.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_exti.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_pwr.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_tim.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_usart.c;Drivers/CMSIS/Device/ST/STM32L0xx/Source/Templates/system_stm32l0xx.c;Core/Src/system_stm32l0xx.c;;; | SourceFiles=Core/Src/main.c;Core/Src/stm32l0xx_it.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_gpio.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_i2c.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_dma.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_rcc.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_utils.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_exti.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_pwr.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_tim.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_usart.c;Drivers/CMSIS/Device/ST/STM32L0xx/Source/Templates/system_stm32l0xx.c;Core/Src/system_stm32l0xx.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_gpio.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_i2c.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_dma.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_rcc.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_utils.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_exti.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_pwr.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_tim.c;Drivers/STM32L0xx_HAL_Driver/Src/stm32l0xx_ll_usart.c;Drivers/CMSIS/Device/ST/STM32L0xx/Source/Templates/system_stm32l0xx.c;Core/Src/system_stm32l0xx.c;;; | ||||||
|   | |||||||
| @@ -29,6 +29,7 @@ extern "C" { | |||||||
|  |  | ||||||
| /* Includes ------------------------------------------------------------------*/ | /* Includes ------------------------------------------------------------------*/ | ||||||
| #include "stm32l0xx_ll_i2c.h" | #include "stm32l0xx_ll_i2c.h" | ||||||
|  | #include "stm32l0xx_ll_iwdg.h" | ||||||
| #include "stm32l0xx_ll_crs.h" | #include "stm32l0xx_ll_crs.h" | ||||||
| #include "stm32l0xx_ll_rcc.h" | #include "stm32l0xx_ll_rcc.h" | ||||||
| #include "stm32l0xx_ll_bus.h" | #include "stm32l0xx_ll_bus.h" | ||||||
|   | |||||||
| @@ -125,6 +125,7 @@ static void MX_USART2_UART_Init(void); | |||||||
| static void MX_TIM21_Init(void); | static void MX_TIM21_Init(void); | ||||||
| static void MX_TIM2_Init(void); | static void MX_TIM2_Init(void); | ||||||
| static void MX_TIM22_Init(void); | static void MX_TIM22_Init(void); | ||||||
|  | static void MX_IWDG_Init(void); | ||||||
| /* USER CODE BEGIN PFP */ | /* USER CODE BEGIN PFP */ | ||||||
| void USART2_TX_Buffer(uint8_t* buffer_tx, uint16_t buffer_tx_len); | void USART2_TX_Buffer(uint8_t* buffer_tx, uint16_t buffer_tx_len); | ||||||
| void CO2_to_color(uint16_t co2, uint16_t co2_limit_yellow, uint16_t co2_limit_red); | void CO2_to_color(uint16_t co2, uint16_t co2_limit_yellow, uint16_t co2_limit_red); | ||||||
| @@ -186,6 +187,7 @@ int main(void) | |||||||
|   MX_TIM21_Init(); |   MX_TIM21_Init(); | ||||||
|   MX_TIM2_Init(); |   MX_TIM2_Init(); | ||||||
|   MX_TIM22_Init(); |   MX_TIM22_Init(); | ||||||
|  |   MX_IWDG_Init(); | ||||||
|   /* USER CODE BEGIN 2 */ |   /* USER CODE BEGIN 2 */ | ||||||
|  |  | ||||||
|   /* Turn on MAGENTA LED to signal startup state */ |   /* Turn on MAGENTA LED to signal startup state */ | ||||||
| @@ -274,6 +276,8 @@ int main(void) | |||||||
|   /* Enter the main loop */ |   /* Enter the main loop */ | ||||||
|   while (1) |   while (1) | ||||||
|   { |   { | ||||||
|  | 	  /* Watchdog is set to 28 s (37 kHz, prescaler 256, 4095 reload value) */ | ||||||
|  | 	  LL_IWDG_ReloadCounter(IWDG); | ||||||
| 	  if (usart2_rx_done == 1) | 	  if (usart2_rx_done == 1) | ||||||
| 	  { | 	  { | ||||||
| 	  /* Process the message */ | 	  /* Process the message */ | ||||||
| @@ -406,6 +410,13 @@ void SystemClock_Config(void) | |||||||
|  |  | ||||||
|   } |   } | ||||||
|   LL_RCC_HSI_SetCalibTrimming(16); |   LL_RCC_HSI_SetCalibTrimming(16); | ||||||
|  |   LL_RCC_LSI_Enable(); | ||||||
|  |  | ||||||
|  |    /* Wait till LSI is ready */ | ||||||
|  |   while(LL_RCC_LSI_IsReady() != 1) | ||||||
|  |   { | ||||||
|  |  | ||||||
|  |   } | ||||||
|   LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI, LL_RCC_PLL_MUL_3, LL_RCC_PLL_DIV_4); |   LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI, LL_RCC_PLL_MUL_3, LL_RCC_PLL_DIV_4); | ||||||
|   LL_RCC_PLL_Enable(); |   LL_RCC_PLL_Enable(); | ||||||
|  |  | ||||||
| @@ -495,6 +506,36 @@ static void MX_I2C1_Init(void) | |||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   * @brief IWDG Initialization Function | ||||||
|  |   * @param None | ||||||
|  |   * @retval None | ||||||
|  |   */ | ||||||
|  | static void MX_IWDG_Init(void) | ||||||
|  | { | ||||||
|  |  | ||||||
|  |   /* USER CODE BEGIN IWDG_Init 0 */ | ||||||
|  |  | ||||||
|  |   /* USER CODE END IWDG_Init 0 */ | ||||||
|  |  | ||||||
|  |   /* USER CODE BEGIN IWDG_Init 1 */ | ||||||
|  |  | ||||||
|  |   /* USER CODE END IWDG_Init 1 */ | ||||||
|  |   LL_IWDG_Enable(IWDG); | ||||||
|  |   LL_IWDG_EnableWriteAccess(IWDG); | ||||||
|  |   LL_IWDG_SetPrescaler(IWDG, LL_IWDG_PRESCALER_256); | ||||||
|  |   LL_IWDG_SetReloadCounter(IWDG, 4095); | ||||||
|  |   while (LL_IWDG_IsReady(IWDG) != 1) | ||||||
|  |   { | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   LL_IWDG_ReloadCounter(IWDG); | ||||||
|  |   /* USER CODE BEGIN IWDG_Init 2 */ | ||||||
|  |  | ||||||
|  |   /* USER CODE END IWDG_Init 2 */ | ||||||
|  |  | ||||||
|  | } | ||||||
|  |  | ||||||
| /** | /** | ||||||
|   * @brief TIM2 Initialization Function |   * @brief TIM2 Initialization Function | ||||||
|   * @param None |   * @param None | ||||||
|   | |||||||
							
								
								
									
										341
									
								
								fw/Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_iwdg.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										341
									
								
								fw/Drivers/STM32L0xx_HAL_Driver/Inc/stm32l0xx_ll_iwdg.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,341 @@ | |||||||
|  | /** | ||||||
|  |   ****************************************************************************** | ||||||
|  |   * @file    stm32l0xx_ll_iwdg.h | ||||||
|  |   * @author  MCD Application Team | ||||||
|  |   * @brief   Header file of IWDG LL module. | ||||||
|  |   ****************************************************************************** | ||||||
|  |   * @attention | ||||||
|  |   * | ||||||
|  |   * <h2><center>© Copyright (c) 2016 STMicroelectronics. | ||||||
|  |   * All rights reserved.</center></h2> | ||||||
|  |   * | ||||||
|  |   * This software component is licensed by ST under BSD 3-Clause license, | ||||||
|  |   * the "License"; You may not use this file except in compliance with the | ||||||
|  |   * License. You may obtain a copy of the License at: | ||||||
|  |   *                        opensource.org/licenses/BSD-3-Clause | ||||||
|  |   * | ||||||
|  |   ****************************************************************************** | ||||||
|  |   */ | ||||||
|  |  | ||||||
|  | /* Define to prevent recursive inclusion -------------------------------------*/ | ||||||
|  | #ifndef STM32L0xx_LL_IWDG_H | ||||||
|  | #define STM32L0xx_LL_IWDG_H | ||||||
|  |  | ||||||
|  | #ifdef __cplusplus | ||||||
|  | extern "C" { | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | /* Includes ------------------------------------------------------------------*/ | ||||||
|  | #include "stm32l0xx.h" | ||||||
|  |  | ||||||
|  | /** @addtogroup STM32L0xx_LL_Driver | ||||||
|  |   * @{ | ||||||
|  |   */ | ||||||
|  |  | ||||||
|  | #if defined(IWDG) | ||||||
|  |  | ||||||
|  | /** @defgroup IWDG_LL IWDG | ||||||
|  |   * @{ | ||||||
|  |   */ | ||||||
|  |  | ||||||
|  | /* Private types -------------------------------------------------------------*/ | ||||||
|  | /* Private variables ---------------------------------------------------------*/ | ||||||
|  |  | ||||||
|  | /* Private constants ---------------------------------------------------------*/ | ||||||
|  | /** @defgroup IWDG_LL_Private_Constants IWDG Private Constants | ||||||
|  |   * @{ | ||||||
|  |   */ | ||||||
|  | #define LL_IWDG_KEY_RELOAD                 0x0000AAAAU               /*!< IWDG Reload Counter Enable   */ | ||||||
|  | #define LL_IWDG_KEY_ENABLE                 0x0000CCCCU               /*!< IWDG Peripheral Enable       */ | ||||||
|  | #define LL_IWDG_KEY_WR_ACCESS_ENABLE       0x00005555U               /*!< IWDG KR Write Access Enable  */ | ||||||
|  | #define LL_IWDG_KEY_WR_ACCESS_DISABLE      0x00000000U               /*!< IWDG KR Write Access Disable */ | ||||||
|  | /** | ||||||
|  |   * @} | ||||||
|  |   */ | ||||||
|  |  | ||||||
|  | /* Private macros ------------------------------------------------------------*/ | ||||||
|  |  | ||||||
|  | /* Exported types ------------------------------------------------------------*/ | ||||||
|  | /* Exported constants --------------------------------------------------------*/ | ||||||
|  | /** @defgroup IWDG_LL_Exported_Constants IWDG Exported Constants | ||||||
|  |   * @{ | ||||||
|  |   */ | ||||||
|  |  | ||||||
|  | /** @defgroup IWDG_LL_EC_GET_FLAG Get Flags Defines | ||||||
|  |   * @brief    Flags defines which can be used with LL_IWDG_ReadReg function | ||||||
|  |   * @{ | ||||||
|  |   */ | ||||||
|  | #define LL_IWDG_SR_PVU                     IWDG_SR_PVU                           /*!< Watchdog prescaler value update */ | ||||||
|  | #define LL_IWDG_SR_RVU                     IWDG_SR_RVU                           /*!< Watchdog counter reload value update */ | ||||||
|  | #define LL_IWDG_SR_WVU                     IWDG_SR_WVU                           /*!< Watchdog counter window value update */ | ||||||
|  | /** | ||||||
|  |   * @} | ||||||
|  |   */ | ||||||
|  |  | ||||||
|  | /** @defgroup IWDG_LL_EC_PRESCALER  Prescaler Divider | ||||||
|  |   * @{ | ||||||
|  |   */ | ||||||
|  | #define LL_IWDG_PRESCALER_4                0x00000000U                           /*!< Divider by 4   */ | ||||||
|  | #define LL_IWDG_PRESCALER_8                (IWDG_PR_PR_0)                        /*!< Divider by 8   */ | ||||||
|  | #define LL_IWDG_PRESCALER_16               (IWDG_PR_PR_1)                        /*!< Divider by 16  */ | ||||||
|  | #define LL_IWDG_PRESCALER_32               (IWDG_PR_PR_1 | IWDG_PR_PR_0)         /*!< Divider by 32  */ | ||||||
|  | #define LL_IWDG_PRESCALER_64               (IWDG_PR_PR_2)                        /*!< Divider by 64  */ | ||||||
|  | #define LL_IWDG_PRESCALER_128              (IWDG_PR_PR_2 | IWDG_PR_PR_0)         /*!< Divider by 128 */ | ||||||
|  | #define LL_IWDG_PRESCALER_256              (IWDG_PR_PR_2 | IWDG_PR_PR_1)         /*!< Divider by 256 */ | ||||||
|  | /** | ||||||
|  |   * @} | ||||||
|  |   */ | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   * @} | ||||||
|  |   */ | ||||||
|  |  | ||||||
|  | /* Exported macro ------------------------------------------------------------*/ | ||||||
|  | /** @defgroup IWDG_LL_Exported_Macros IWDG Exported Macros | ||||||
|  |   * @{ | ||||||
|  |   */ | ||||||
|  |  | ||||||
|  | /** @defgroup IWDG_LL_EM_WRITE_READ Common Write and read registers Macros | ||||||
|  |   * @{ | ||||||
|  |   */ | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   * @brief  Write a value in IWDG register | ||||||
|  |   * @param  __INSTANCE__ IWDG Instance | ||||||
|  |   * @param  __REG__ Register to be written | ||||||
|  |   * @param  __VALUE__ Value to be written in the register | ||||||
|  |   * @retval None | ||||||
|  |   */ | ||||||
|  | #define LL_IWDG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   * @brief  Read a value in IWDG register | ||||||
|  |   * @param  __INSTANCE__ IWDG Instance | ||||||
|  |   * @param  __REG__ Register to be read | ||||||
|  |   * @retval Register value | ||||||
|  |   */ | ||||||
|  | #define LL_IWDG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) | ||||||
|  | /** | ||||||
|  |   * @} | ||||||
|  |   */ | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   * @} | ||||||
|  |   */ | ||||||
|  |  | ||||||
|  |  | ||||||
|  | /* Exported functions --------------------------------------------------------*/ | ||||||
|  | /** @defgroup IWDG_LL_Exported_Functions IWDG Exported Functions | ||||||
|  |   * @{ | ||||||
|  |   */ | ||||||
|  | /** @defgroup IWDG_LL_EF_Configuration Configuration | ||||||
|  |   * @{ | ||||||
|  |   */ | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   * @brief  Start the Independent Watchdog | ||||||
|  |   * @note   Except if the hardware watchdog option is selected | ||||||
|  |   * @rmtoll KR           KEY           LL_IWDG_Enable | ||||||
|  |   * @param  IWDGx IWDG Instance | ||||||
|  |   * @retval None | ||||||
|  |   */ | ||||||
|  | __STATIC_INLINE void LL_IWDG_Enable(IWDG_TypeDef *IWDGx) | ||||||
|  | { | ||||||
|  |   WRITE_REG(IWDGx->KR, LL_IWDG_KEY_ENABLE); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   * @brief  Reloads IWDG counter with value defined in the reload register | ||||||
|  |   * @rmtoll KR           KEY           LL_IWDG_ReloadCounter | ||||||
|  |   * @param  IWDGx IWDG Instance | ||||||
|  |   * @retval None | ||||||
|  |   */ | ||||||
|  | __STATIC_INLINE void LL_IWDG_ReloadCounter(IWDG_TypeDef *IWDGx) | ||||||
|  | { | ||||||
|  |   WRITE_REG(IWDGx->KR, LL_IWDG_KEY_RELOAD); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   * @brief  Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers | ||||||
|  |   * @rmtoll KR           KEY           LL_IWDG_EnableWriteAccess | ||||||
|  |   * @param  IWDGx IWDG Instance | ||||||
|  |   * @retval None | ||||||
|  |   */ | ||||||
|  | __STATIC_INLINE void LL_IWDG_EnableWriteAccess(IWDG_TypeDef *IWDGx) | ||||||
|  | { | ||||||
|  |   WRITE_REG(IWDGx->KR, LL_IWDG_KEY_WR_ACCESS_ENABLE); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   * @brief  Disable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers | ||||||
|  |   * @rmtoll KR           KEY           LL_IWDG_DisableWriteAccess | ||||||
|  |   * @param  IWDGx IWDG Instance | ||||||
|  |   * @retval None | ||||||
|  |   */ | ||||||
|  | __STATIC_INLINE void LL_IWDG_DisableWriteAccess(IWDG_TypeDef *IWDGx) | ||||||
|  | { | ||||||
|  |   WRITE_REG(IWDGx->KR, LL_IWDG_KEY_WR_ACCESS_DISABLE); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   * @brief  Select the prescaler of the IWDG | ||||||
|  |   * @rmtoll PR           PR            LL_IWDG_SetPrescaler | ||||||
|  |   * @param  IWDGx IWDG Instance | ||||||
|  |   * @param  Prescaler This parameter can be one of the following values: | ||||||
|  |   *         @arg @ref LL_IWDG_PRESCALER_4 | ||||||
|  |   *         @arg @ref LL_IWDG_PRESCALER_8 | ||||||
|  |   *         @arg @ref LL_IWDG_PRESCALER_16 | ||||||
|  |   *         @arg @ref LL_IWDG_PRESCALER_32 | ||||||
|  |   *         @arg @ref LL_IWDG_PRESCALER_64 | ||||||
|  |   *         @arg @ref LL_IWDG_PRESCALER_128 | ||||||
|  |   *         @arg @ref LL_IWDG_PRESCALER_256 | ||||||
|  |   * @retval None | ||||||
|  |   */ | ||||||
|  | __STATIC_INLINE void LL_IWDG_SetPrescaler(IWDG_TypeDef *IWDGx, uint32_t Prescaler) | ||||||
|  | { | ||||||
|  |   WRITE_REG(IWDGx->PR, IWDG_PR_PR & Prescaler); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   * @brief  Get the selected prescaler of the IWDG | ||||||
|  |   * @rmtoll PR           PR            LL_IWDG_GetPrescaler | ||||||
|  |   * @param  IWDGx IWDG Instance | ||||||
|  |   * @retval Returned value can be one of the following values: | ||||||
|  |   *         @arg @ref LL_IWDG_PRESCALER_4 | ||||||
|  |   *         @arg @ref LL_IWDG_PRESCALER_8 | ||||||
|  |   *         @arg @ref LL_IWDG_PRESCALER_16 | ||||||
|  |   *         @arg @ref LL_IWDG_PRESCALER_32 | ||||||
|  |   *         @arg @ref LL_IWDG_PRESCALER_64 | ||||||
|  |   *         @arg @ref LL_IWDG_PRESCALER_128 | ||||||
|  |   *         @arg @ref LL_IWDG_PRESCALER_256 | ||||||
|  |   */ | ||||||
|  | __STATIC_INLINE uint32_t LL_IWDG_GetPrescaler(IWDG_TypeDef *IWDGx) | ||||||
|  | { | ||||||
|  |   return (READ_REG(IWDGx->PR)); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   * @brief  Specify the IWDG down-counter reload value | ||||||
|  |   * @rmtoll RLR          RL            LL_IWDG_SetReloadCounter | ||||||
|  |   * @param  IWDGx IWDG Instance | ||||||
|  |   * @param  Counter Value between Min_Data=0 and Max_Data=0x0FFF | ||||||
|  |   * @retval None | ||||||
|  |   */ | ||||||
|  | __STATIC_INLINE void LL_IWDG_SetReloadCounter(IWDG_TypeDef *IWDGx, uint32_t Counter) | ||||||
|  | { | ||||||
|  |   WRITE_REG(IWDGx->RLR, IWDG_RLR_RL & Counter); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   * @brief  Get the specified IWDG down-counter reload value | ||||||
|  |   * @rmtoll RLR          RL            LL_IWDG_GetReloadCounter | ||||||
|  |   * @param  IWDGx IWDG Instance | ||||||
|  |   * @retval Value between Min_Data=0 and Max_Data=0x0FFF | ||||||
|  |   */ | ||||||
|  | __STATIC_INLINE uint32_t LL_IWDG_GetReloadCounter(IWDG_TypeDef *IWDGx) | ||||||
|  | { | ||||||
|  |   return (READ_REG(IWDGx->RLR)); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   * @brief  Specify high limit of the window value to be compared to the down-counter. | ||||||
|  |   * @rmtoll WINR         WIN           LL_IWDG_SetWindow | ||||||
|  |   * @param  IWDGx IWDG Instance | ||||||
|  |   * @param  Window Value between Min_Data=0 and Max_Data=0x0FFF | ||||||
|  |   * @retval None | ||||||
|  |   */ | ||||||
|  | __STATIC_INLINE void LL_IWDG_SetWindow(IWDG_TypeDef *IWDGx, uint32_t Window) | ||||||
|  | { | ||||||
|  |   WRITE_REG(IWDGx->WINR, IWDG_WINR_WIN & Window); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   * @brief  Get the high limit of the window value specified. | ||||||
|  |   * @rmtoll WINR         WIN           LL_IWDG_GetWindow | ||||||
|  |   * @param  IWDGx IWDG Instance | ||||||
|  |   * @retval Value between Min_Data=0 and Max_Data=0x0FFF | ||||||
|  |   */ | ||||||
|  | __STATIC_INLINE uint32_t LL_IWDG_GetWindow(IWDG_TypeDef *IWDGx) | ||||||
|  | { | ||||||
|  |   return (READ_REG(IWDGx->WINR)); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   * @} | ||||||
|  |   */ | ||||||
|  |  | ||||||
|  | /** @defgroup IWDG_LL_EF_FLAG_Management FLAG_Management | ||||||
|  |   * @{ | ||||||
|  |   */ | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   * @brief  Check if flag Prescaler Value Update is set or not | ||||||
|  |   * @rmtoll SR           PVU           LL_IWDG_IsActiveFlag_PVU | ||||||
|  |   * @param  IWDGx IWDG Instance | ||||||
|  |   * @retval State of bit (1 or 0). | ||||||
|  |   */ | ||||||
|  | __STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_PVU(IWDG_TypeDef *IWDGx) | ||||||
|  | { | ||||||
|  |   return ((READ_BIT(IWDGx->SR, IWDG_SR_PVU) == (IWDG_SR_PVU)) ? 1UL : 0UL); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   * @brief  Check if flag Reload Value Update is set or not | ||||||
|  |   * @rmtoll SR           RVU           LL_IWDG_IsActiveFlag_RVU | ||||||
|  |   * @param  IWDGx IWDG Instance | ||||||
|  |   * @retval State of bit (1 or 0). | ||||||
|  |   */ | ||||||
|  | __STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_RVU(IWDG_TypeDef *IWDGx) | ||||||
|  | { | ||||||
|  |   return ((READ_BIT(IWDGx->SR, IWDG_SR_RVU) == (IWDG_SR_RVU)) ? 1UL : 0UL); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   * @brief  Check if flag Window Value Update is set or not | ||||||
|  |   * @rmtoll SR           WVU           LL_IWDG_IsActiveFlag_WVU | ||||||
|  |   * @param  IWDGx IWDG Instance | ||||||
|  |   * @retval State of bit (1 or 0). | ||||||
|  |   */ | ||||||
|  | __STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_WVU(IWDG_TypeDef *IWDGx) | ||||||
|  | { | ||||||
|  |   return ((READ_BIT(IWDGx->SR, IWDG_SR_WVU) == (IWDG_SR_WVU)) ? 1UL : 0UL); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   * @brief  Check if all flags Prescaler, Reload & Window Value Update are reset or not | ||||||
|  |   * @rmtoll SR           PVU           LL_IWDG_IsReady\n | ||||||
|  |   *         SR           RVU           LL_IWDG_IsReady\n | ||||||
|  |   *         SR           WVU           LL_IWDG_IsReady | ||||||
|  |   * @param  IWDGx IWDG Instance | ||||||
|  |   * @retval State of bits (1 or 0). | ||||||
|  |   */ | ||||||
|  | __STATIC_INLINE uint32_t LL_IWDG_IsReady(IWDG_TypeDef *IWDGx) | ||||||
|  | { | ||||||
|  |   return ((READ_BIT(IWDGx->SR, IWDG_SR_PVU | IWDG_SR_RVU | IWDG_SR_WVU) == 0U) ? 1UL : 0UL); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   * @} | ||||||
|  |   */ | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   * @} | ||||||
|  |   */ | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   * @} | ||||||
|  |   */ | ||||||
|  |  | ||||||
|  | #endif /* IWDG */ | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |   * @} | ||||||
|  |   */ | ||||||
|  |  | ||||||
|  | #ifdef __cplusplus | ||||||
|  | } | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | #endif /* STM32L0xx_LL_IWDG_H */ | ||||||
|  |  | ||||||
|  | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ | ||||||
| @@ -3,23 +3,27 @@ File.Version=6 | |||||||
| GPIO.groupedBy=Group By Peripherals | GPIO.groupedBy=Group By Peripherals | ||||||
| I2C1.IPParameters=Timing | I2C1.IPParameters=Timing | ||||||
| I2C1.Timing=0x40000A0B | I2C1.Timing=0x40000A0B | ||||||
|  | IWDG.IPParameters=Prescaler | ||||||
|  | IWDG.Prescaler=IWDG_PRESCALER_256 | ||||||
| KeepUserPlacement=false | KeepUserPlacement=false | ||||||
| Mcu.Family=STM32L0 | Mcu.Family=STM32L0 | ||||||
| Mcu.IP0=I2C1 | Mcu.IP0=I2C1 | ||||||
| Mcu.IP1=NVIC | Mcu.IP1=IWDG | ||||||
| Mcu.IP2=RCC | Mcu.IP2=NVIC | ||||||
| Mcu.IP3=SYS | Mcu.IP3=RCC | ||||||
| Mcu.IP4=TIM2 | Mcu.IP4=SYS | ||||||
| Mcu.IP5=TIM21 | Mcu.IP5=TIM2 | ||||||
| Mcu.IP6=TIM22 | Mcu.IP6=TIM21 | ||||||
| Mcu.IP7=USART2 | Mcu.IP7=TIM22 | ||||||
| Mcu.IPNb=8 | Mcu.IP8=USART2 | ||||||
|  | Mcu.IPNb=9 | ||||||
| Mcu.Name=STM32L031G(4-6)Ux | Mcu.Name=STM32L031G(4-6)Ux | ||||||
| Mcu.Package=UFQFPN28 | Mcu.Package=UFQFPN28 | ||||||
| Mcu.Pin0=PA1 | Mcu.Pin0=PA1 | ||||||
| Mcu.Pin1=PA2 | Mcu.Pin1=PA2 | ||||||
| Mcu.Pin10=VP_SYS_VS_Systick | Mcu.Pin10=VP_IWDG_VS_IWDG | ||||||
| Mcu.Pin11=VP_TIM21_VS_ClockSourceINT | Mcu.Pin11=VP_SYS_VS_Systick | ||||||
|  | Mcu.Pin12=VP_TIM21_VS_ClockSourceINT | ||||||
| Mcu.Pin2=PA3 | Mcu.Pin2=PA3 | ||||||
| Mcu.Pin3=PA5 | Mcu.Pin3=PA5 | ||||||
| Mcu.Pin4=PA6 | Mcu.Pin4=PA6 | ||||||
| @@ -28,7 +32,7 @@ Mcu.Pin6=PA9 | |||||||
| Mcu.Pin7=PA10 | Mcu.Pin7=PA10 | ||||||
| Mcu.Pin8=PA13 | Mcu.Pin8=PA13 | ||||||
| Mcu.Pin9=PA14 | Mcu.Pin9=PA14 | ||||||
| Mcu.PinsNb=12 | Mcu.PinsNb=13 | ||||||
| Mcu.ThirdPartyNb=0 | Mcu.ThirdPartyNb=0 | ||||||
| Mcu.UserConstants= | Mcu.UserConstants= | ||||||
| Mcu.UserName=STM32L031G6Ux | Mcu.UserName=STM32L031G6Ux | ||||||
| @@ -94,7 +98,7 @@ ProjectManager.StackSize=0x400 | |||||||
| ProjectManager.TargetToolchain=STM32CubeIDE | ProjectManager.TargetToolchain=STM32CubeIDE | ||||||
| ProjectManager.ToolChainLocation= | ProjectManager.ToolChainLocation= | ||||||
| ProjectManager.UnderRoot=true | ProjectManager.UnderRoot=true | ||||||
| ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-LL-false,2-MX_GPIO_Init-GPIO-false-LL-true,3-MX_I2C1_Init-I2C1-false-LL-true,4-MX_USART2_UART_Init-USART2-false-LL-true,5-MX_TIM21_Init-TIM21-false-LL-true,6-MX_TIM2_Init-TIM2-false-LL-true,7-MX_TIM22_Init-TIM22-false-LL-true | ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-LL-false,2-MX_GPIO_Init-GPIO-false-LL-true,3-MX_I2C1_Init-I2C1-false-LL-true,4-MX_USART2_UART_Init-USART2-false-LL-true,5-MX_TIM21_Init-TIM21-false-LL-true,6-MX_TIM2_Init-TIM2-false-LL-true,7-MX_TIM22_Init-TIM22-false-LL-true,8-MX_IWDG_Init-IWDG-false-LL-true | ||||||
| RCC.AHBFreq_Value=12000000 | RCC.AHBFreq_Value=12000000 | ||||||
| RCC.APB1Freq_Value=12000000 | RCC.APB1Freq_Value=12000000 | ||||||
| RCC.APB1TimFreq_Value=12000000 | RCC.APB1TimFreq_Value=12000000 | ||||||
| @@ -156,6 +160,8 @@ USART2.Parity=PARITY_EVEN | |||||||
| USART2.VirtualMode-Asynchronous=VM_ASYNC | USART2.VirtualMode-Asynchronous=VM_ASYNC | ||||||
| USART2.VirtualMode-Hardware\ Flow\ Control\ (RS485)=VM_ASYNC | USART2.VirtualMode-Hardware\ Flow\ Control\ (RS485)=VM_ASYNC | ||||||
| USART2.WordLength=WORDLENGTH_9B | USART2.WordLength=WORDLENGTH_9B | ||||||
|  | VP_IWDG_VS_IWDG.Mode=IWDG_Activate | ||||||
|  | VP_IWDG_VS_IWDG.Signal=IWDG_VS_IWDG | ||||||
| VP_SYS_VS_Systick.Mode=SysTick | VP_SYS_VS_Systick.Mode=SysTick | ||||||
| VP_SYS_VS_Systick.Signal=SYS_VS_Systick | VP_SYS_VS_Systick.Signal=SYS_VS_Systick | ||||||
| VP_TIM21_VS_ClockSourceINT.Mode=Internal | VP_TIM21_VS_ClockSourceINT.Mode=Internal | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 mj
					mj