uc-sdk
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
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
{
104
RCC_APB1PeriphResetCmd
(
RCC_APB1Periph_WWDG
,
ENABLE
);
105
RCC_APB1PeriphResetCmd
(
RCC_APB1Periph_WWDG
,
DISABLE
);
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
197
FlagStatus
WWDG_GetFlagStatus
(
void
)
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****/
arch
arm
stm32f10x
Drivers
source
stm32f10x_wwdg.c
Generated on Fri Nov 15 2013 05:00:18 for uc-sdk by
1.8.4