stm32f30x_wwdg.c
Go to the documentation of this file.
1 
86 /* Includes ------------------------------------------------------------------*/
87 #include "stm32f30x_wwdg.h"
88 #include "stm32f30x_rcc.h"
89 
99 /* Private typedef -----------------------------------------------------------*/
100 /* Private define ------------------------------------------------------------*/
101 /* --------------------- WWDG registers bit mask ---------------------------- */
102 /* CFR register bit mask */
103 #define CFR_WDGTB_MASK ((uint32_t)0xFFFFFE7F)
104 #define CFR_W_MASK ((uint32_t)0xFFFFFF80)
105 #define BIT_MASK ((uint8_t)0x7F)
106 
107 /* Private macro -------------------------------------------------------------*/
108 /* Private variables ---------------------------------------------------------*/
109 /* Private function prototypes -----------------------------------------------*/
110 /* Private functions ---------------------------------------------------------*/
111 
133 void WWDG_DeInit(void)
134 {
137 }
138 
149 void WWDG_SetPrescaler(uint32_t WWDG_Prescaler)
150 {
151  uint32_t tmpreg = 0;
152  /* Check the parameters */
153  assert_param(IS_WWDG_PRESCALER(WWDG_Prescaler));
154  /* Clear WDGTB[1:0] bits */
155  tmpreg = WWDG->CFR & CFR_WDGTB_MASK;
156  /* Set WDGTB[1:0] bits according to WWDG_Prescaler value */
157  tmpreg |= WWDG_Prescaler;
158  /* Store the new value */
159  WWDG->CFR = tmpreg;
160 }
161 
168 void WWDG_SetWindowValue(uint8_t WindowValue)
169 {
170  __IO uint32_t tmpreg = 0;
171 
172  /* Check the parameters */
173  assert_param(IS_WWDG_WINDOW_VALUE(WindowValue));
174  /* Clear W[6:0] bits */
175 
176  tmpreg = WWDG->CFR & CFR_W_MASK;
177 
178  /* Set W[6:0] bits according to WindowValue value */
179  tmpreg |= WindowValue & (uint32_t) BIT_MASK;
180 
181  /* Store the new value */
182  WWDG->CFR = tmpreg;
183 }
184 
191 void WWDG_EnableIT(void)
192 {
193  WWDG->CFR |= WWDG_CFR_EWI;
194 }
195 
203 void WWDG_SetCounter(uint8_t Counter)
204 {
205  /* Check the parameters */
206  assert_param(IS_WWDG_COUNTER(Counter));
207  /* Write to T[6:0] bits to configure the counter value, no need to do
208  a read-modify-write; writing a 0 to WDGA bit does nothing */
209  WWDG->CR = Counter & BIT_MASK;
210 }
211 
235 void WWDG_Enable(uint8_t Counter)
236 {
237  /* Check the parameters */
238  assert_param(IS_WWDG_COUNTER(Counter));
239  WWDG->CR = WWDG_CR_WDGA | Counter;
240 }
241 
264 {
265  FlagStatus bitstatus = RESET;
266 
267  if ((WWDG->SR) != (uint32_t)RESET)
268  {
269  bitstatus = SET;
270  }
271  else
272  {
273  bitstatus = RESET;
274  }
275  return bitstatus;
276 }
277 
283 void WWDG_ClearFlag(void)
284 {
285  WWDG->SR = (uint32_t)RESET;
286 }
287 
304 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
void WWDG_EnableIT(void)
Enables the WWDG Early Wakeup interrupt(EWI).
FlagStatus
Definition: stm32f4xx.h:706
FlagStatus WWDG_GetFlagStatus(void)
Checks whether the Early Wakeup interrupt flag is set or not.
void WWDG_Enable(uint8_t Counter)
Enables WWDG and load the counter value.
This file contains all the functions prototypes for the WWDG firmware library.
#define BIT_MASK
void WWDG_SetWindowValue(uint8_t WindowValue)
Sets the WWDG window value.
#define WWDG_CR_WDGA
Definition: stm32f4xx.h:10901
#define IS_WWDG_COUNTER(COUNTER)
void WWDG_DeInit(void)
Deinitializes the WWDG peripheral registers to their default reset values.
#define WWDG
Definition: stm32f4xx.h:2047
void assert_param(int val)
#define IS_WWDG_WINDOW_VALUE(VALUE)
#define IS_WWDG_PRESCALER(PRESCALER)
#define WWDG_CFR_EWI
Definition: stm32f4xx.h:10917
Definition: stm32f4xx.h:706
void RCC_APB1PeriphResetCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)
Forces or releases Low Speed APB (APB1) peripheral reset.
This file contains all the functions prototypes for the RCC firmware library.
#define __IO
Definition: core_cm0.h:198
#define CFR_WDGTB_MASK
void WWDG_ClearFlag(void)
Clears Early Wakeup interrupt flag.
#define CFR_W_MASK
void WWDG_SetCounter(uint8_t Counter)
Sets the WWDG counter value.
void WWDG_SetPrescaler(uint32_t WWDG_Prescaler)
Sets the WWDG Prescaler.


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