stm32f4xx_wwdg.c
Go to the documentation of this file.
1 
83 /* Includes ------------------------------------------------------------------*/
84 #include "stm32f4xx_wwdg.h"
85 #include "stm32f4xx_rcc.h"
86 
96 /* Private typedef -----------------------------------------------------------*/
97 /* Private define ------------------------------------------------------------*/
98 
99 /* ----------- WWDG registers bit address in the alias region ----------- */
100 #define WWDG_OFFSET (WWDG_BASE - PERIPH_BASE)
101 /* Alias word address of EWI bit */
102 #define CFR_OFFSET (WWDG_OFFSET + 0x04)
103 #define EWI_BitNumber 0x09
104 #define CFR_EWI_BB (PERIPH_BB_BASE + (CFR_OFFSET * 32) + (EWI_BitNumber * 4))
105 
106 /* --------------------- WWDG registers bit mask ------------------------ */
107 /* CFR register bit mask */
108 #define CFR_WDGTB_MASK ((uint32_t)0xFFFFFE7F)
109 #define CFR_W_MASK ((uint32_t)0xFFFFFF80)
110 #define BIT_MASK ((uint8_t)0x7F)
111 
112 /* Private macro -------------------------------------------------------------*/
113 /* Private variables ---------------------------------------------------------*/
114 /* Private function prototypes -----------------------------------------------*/
115 /* Private functions ---------------------------------------------------------*/
116 
138 void WWDG_DeInit(void)
139 {
142 }
143 
154 void WWDG_SetPrescaler(uint32_t WWDG_Prescaler)
155 {
156  uint32_t tmpreg = 0;
157  /* Check the parameters */
158  assert_param(IS_WWDG_PRESCALER(WWDG_Prescaler));
159  /* Clear WDGTB[1:0] bits */
160  tmpreg = WWDG->CFR & CFR_WDGTB_MASK;
161  /* Set WDGTB[1:0] bits according to WWDG_Prescaler value */
162  tmpreg |= WWDG_Prescaler;
163  /* Store the new value */
164  WWDG->CFR = tmpreg;
165 }
166 
173 void WWDG_SetWindowValue(uint8_t WindowValue)
174 {
175  __IO uint32_t tmpreg = 0;
176 
177  /* Check the parameters */
178  assert_param(IS_WWDG_WINDOW_VALUE(WindowValue));
179  /* Clear W[6:0] bits */
180 
181  tmpreg = WWDG->CFR & CFR_W_MASK;
182 
183  /* Set W[6:0] bits according to WindowValue value */
184  tmpreg |= WindowValue & (uint32_t) BIT_MASK;
185 
186  /* Store the new value */
187  WWDG->CFR = tmpreg;
188 }
189 
196 void WWDG_EnableIT(void)
197 {
198  *(__IO uint32_t *) CFR_EWI_BB = (uint32_t)ENABLE;
199 }
200 
208 void WWDG_SetCounter(uint8_t Counter)
209 {
210  /* Check the parameters */
211  assert_param(IS_WWDG_COUNTER(Counter));
212  /* Write to T[6:0] bits to configure the counter value, no need to do
213  a read-modify-write; writing a 0 to WDGA bit does nothing */
214  WWDG->CR = Counter & BIT_MASK;
215 }
239 void WWDG_Enable(uint8_t Counter)
240 {
241  /* Check the parameters */
242  assert_param(IS_WWDG_COUNTER(Counter));
243  WWDG->CR = WWDG_CR_WDGA | Counter;
244 }
267 {
268  FlagStatus bitstatus = RESET;
269 
270  if ((WWDG->SR) != (uint32_t)RESET)
271  {
272  bitstatus = SET;
273  }
274  else
275  {
276  bitstatus = RESET;
277  }
278  return bitstatus;
279 }
280 
286 void WWDG_ClearFlag(void)
287 {
288  WWDG->SR = (uint32_t)RESET;
289 }
290 
307 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
FlagStatus
Definition: stm32f4xx.h:706
void WWDG_DeInit(void)
Deinitializes the WWDG peripheral registers to their default reset values.
#define BIT_MASK
void WWDG_EnableIT(void)
Enables the WWDG Early Wakeup interrupt(EWI).
#define WWDG_CR_WDGA
Definition: stm32f4xx.h:10901
#define IS_WWDG_COUNTER(COUNTER)
FlagStatus WWDG_GetFlagStatus(void)
Checks whether the Early Wakeup interrupt flag is set or not.
#define WWDG
Definition: stm32f4xx.h:2047
void assert_param(int val)
#define IS_WWDG_WINDOW_VALUE(VALUE)
#define IS_WWDG_PRESCALER(PRESCALER)
void WWDG_SetCounter(uint8_t Counter)
Sets the WWDG counter value.
void WWDG_SetWindowValue(uint8_t WindowValue)
Sets the WWDG window value.
Definition: stm32f4xx.h:706
void WWDG_ClearFlag(void)
Clears Early Wakeup interrupt flag.
void WWDG_Enable(uint8_t Counter)
Enables WWDG and load the counter value.
void RCC_APB1PeriphResetCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)
Forces or releases Low Speed APB (APB1) peripheral reset.
#define __IO
Definition: core_cm0.h:198
void WWDG_SetPrescaler(uint32_t WWDG_Prescaler)
Sets the WWDG Prescaler.
#define CFR_WDGTB_MASK
This file contains all the functions prototypes for the WWDG firmware library.
#define CFR_EWI_BB
#define CFR_W_MASK


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Wed Jul 3 2019 19:59:26