stm32f10x_wwdg.c
Go to the documentation of this file.
1 
22 /* Includes ------------------------------------------------------------------*/
23 #include "stm32f10x_wwdg.h"
24 #include "stm32f10x_rcc.h"
25 
47 /* ----------- WWDG registers bit address in the alias region ----------- */
48 #define WWDG_OFFSET (WWDG_BASE - PERIPH_BASE)
49 
50 /* Alias word address of EWI bit */
51 #define CFR_OFFSET (WWDG_OFFSET + 0x04)
52 #define EWI_BitNumber 0x09
53 #define CFR_EWI_BB (PERIPH_BB_BASE + (CFR_OFFSET * 32) + (EWI_BitNumber * 4))
54 
55 /* --------------------- WWDG registers bit mask ------------------------ */
56 
57 /* CR register bit mask */
58 #define CR_WDGA_Set ((uint32_t)0x00000080)
59 
60 /* CFR register bit mask */
61 #define CFR_WDGTB_Mask ((uint32_t)0xFFFFFE7F)
62 #define CFR_W_Mask ((uint32_t)0xFFFFFF80)
63 #define BIT_Mask ((uint8_t)0x7F)
64 
102 void WWDG_DeInit(void)
103 {
106 }
107 
118 void WWDG_SetPrescaler(uint32_t WWDG_Prescaler)
119 {
120  uint32_t tmpreg = 0;
121  /* Check the parameters */
122  assert_param(IS_WWDG_PRESCALER(WWDG_Prescaler));
123  /* Clear WDGTB[1:0] bits */
124  tmpreg = WWDG->CFR & CFR_WDGTB_Mask;
125  /* Set WDGTB[1:0] bits according to WWDG_Prescaler value */
126  tmpreg |= WWDG_Prescaler;
127  /* Store the new value */
128  WWDG->CFR = tmpreg;
129 }
130 
137 void WWDG_SetWindowValue(uint8_t WindowValue)
138 {
139  __IO uint32_t tmpreg = 0;
140 
141  /* Check the parameters */
142  assert_param(IS_WWDG_WINDOW_VALUE(WindowValue));
143  /* Clear W[6:0] bits */
144 
145  tmpreg = WWDG->CFR & CFR_W_Mask;
146 
147  /* Set W[6:0] bits according to WindowValue value */
148  tmpreg |= WindowValue & (uint32_t) BIT_Mask;
149 
150  /* Store the new value */
151  WWDG->CFR = tmpreg;
152 }
153 
159 void WWDG_EnableIT(void)
160 {
161  *(__IO uint32_t *) CFR_EWI_BB = (uint32_t)ENABLE;
162 }
163 
170 void WWDG_SetCounter(uint8_t Counter)
171 {
172  /* Check the parameters */
173  assert_param(IS_WWDG_COUNTER(Counter));
174  /* Write to T[6:0] bits to configure the counter value, no need to do
175  a read-modify-write; writing a 0 to WDGA bit does nothing */
176  WWDG->CR = Counter & BIT_Mask;
177 }
178 
185 void WWDG_Enable(uint8_t Counter)
186 {
187  /* Check the parameters */
188  assert_param(IS_WWDG_COUNTER(Counter));
189  WWDG->CR = CR_WDGA_Set | Counter;
190 }
191 
198 {
199  return (FlagStatus)(WWDG->SR);
200 }
201 
207 void WWDG_ClearFlag(void)
208 {
209  WWDG->SR = (uint32_t)RESET;
210 }
211 
224 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
FlagStatus
Definition: stm32f4xx.h:706
FlagStatus WWDG_GetFlagStatus(void)
Checks whether the Early Wakeup interrupt flag is set or not.
#define IS_WWDG_COUNTER(COUNTER)
This file contains all the functions prototypes for the WWDG firmware library.
#define CFR_WDGTB_Mask
#define WWDG
Definition: stm32f4xx.h:2047
void assert_param(int val)
#define IS_WWDG_WINDOW_VALUE(VALUE)
void WWDG_EnableIT(void)
Enables the WWDG Early Wakeup interrupt(EWI).
#define CR_WDGA_Set
#define IS_WWDG_PRESCALER(PRESCALER)
#define BIT_Mask
void WWDG_SetPrescaler(uint32_t WWDG_Prescaler)
Sets the WWDG Prescaler.
void RCC_APB1PeriphResetCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)
Forces or releases Low Speed APB (APB1) peripheral reset.
void WWDG_DeInit(void)
Deinitializes the WWDG peripheral registers to their default reset values.
#define __IO
Definition: core_cm0.h:198
This file contains all the functions prototypes for the RCC firmware library.
#define CFR_W_Mask
void WWDG_SetCounter(uint8_t Counter)
Sets the WWDG counter value.
#define CFR_EWI_BB
void WWDG_ClearFlag(void)
Clears Early Wakeup interrupt flag.
void WWDG_SetWindowValue(uint8_t WindowValue)
Sets the WWDG window value.
void WWDG_Enable(uint8_t Counter)
Enables WWDG and load the counter value.


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